|
|||||||||||
|
system/2982: An atactl(8) improvement
From: Alexander Yurchenko <grange(at)rt.mipt.ru>
Date: Tue Nov 12 2002 - 17:41:45 EST
System : OpenBSD 3.2 Architecture: i386 Machine : i386 >Description: Add new optional parameter ``id'' for the ``readattr'' command to display the value of the specified attribute. It may be used in monitoring shell scripts for example. >How-To-Repeat: >Fix:
RCS file: /home/ftp/cvsup/OpenBSD/src/sbin/atactl/atactl.8,v retrieving revision 1.17 diff -u -r1.17 atactl.8 --- src/sbin/atactl/atactl.8 4 Aug 2002 14:11:41 -0000 1.17 +++ src/sbin/atactl/atactl.8 12 Nov 2002 22:13:45 -0000@@ -430,10 +430,17 @@ .El .Pp .Cm readattr +.Op Ar id .Pp Displays attributes thresholds and values for the specified device. Besides attributes values device vendor can provide additional information shown in the last column ``Raw''. +If +.Ar id +parameter is given the only value of the specified attribute will be +displayed. +In case of non-existent attribute id nothing is displayed and a status +of 2 is returned. Attributes names can be completely wrong since they vary between vendors and even models, so don't rely on it. SMART must be enabled while executing this command or the device will return Index: src/sbin/atactl/atactl.c RCS file: /home/ftp/cvsup/OpenBSD/src/sbin/atactl/atactl.c,v retrieving revision 1.21 diff -u -r1.21 atactl.c
--- src/sbin/atactl/atactl.c 16 Oct 2002 13:00:51 -0000 1.21
+++ src/sbin/atactl/atactl.c 12 Nov 2002 22:10:43 -0000
@@ -1353,10 +1353,11 @@
struct threshold *thr;
const char *attr_name;
static const char hex[]="0123456789abcdef";
- char raw[13], *format;
+ char raw[13], *format, *end;
int i, k, threshold_exceeded = 0;
+ unsigned long id;
- if (argc != 1)
+ if (argc > 2)
goto usage;
memset(&req, 0, sizeof(req));
@@ -1390,6 +1391,23 @@
attr = attr_val.attribute;
thr = attr_thr.threshold;
+ if (argc == 2) {
+ id = strtoul(argv[1], &end, 0);
+ if (*end != '\0' || id < 1 || id > 255) {
+ fprintf(stderr, "Invalid attribute id value: \"%s\" "
+ "(valid values range from 1 to 255)\n", argv[1]);
+ exit(1);
+ }
+
+ for (i = 0; i < 30; i++)
+ if (attr[i].id == id) {
+ printf("%d\n", attr[i].value);
+ return;
+ }
+
+ exit(2);
+ }
+
printf("Attributes table revision: %d\n", attr_val.revision);
printf("ID\tAttribute name\t\t\tThreshold\tValue\tRaw\n");
for (i = 0; i < 30; i++) {
@@ -1421,7 +1439,7 @@
return;
usage:
- fprintf(stderr, "usage: %s } >Release-Note:
This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:29:38 EDT |
||||||||||
|
|||||||||||