My last patchset added column headers to 'ipmitool sensor list' output and
these headers were shown by default. That could break some scripts, it's
better to don't show the headers by default and add an option to turn them
on.

Let '-D' be the option. All other lucrative options, like '-h' for 'headers',
'-c' for 'column headers' etc. are already taken.

The new option is used only in 'sensor list' command, are there any other
tables worth using this option?

Signed-off-by: Jan Safranek <jsafr...@redhat.com>
---

 doc/ipmitool.1          |    7 +++++--
 include/ipmitool/ipmi.h |    1 +
 lib/ipmi_main.c         |    7 ++++++-
 lib/ipmi_sensor.c       |    3 ++-
 src/ipmievd.c           |    1 +
 src/ipmitool.c          |    1 +
 6 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/doc/ipmitool.1 b/doc/ipmitool.1
index c596feb..a6dfdee 100644
--- a/doc/ipmitool.1
+++ b/doc/ipmitool.1
@@ -5,7 +5,7 @@ ipmitool \- utility for controlling IPMI\-enabled devices
 ipmitool [\fB\-c\fR|\fB\-h\fR|\fB\-d \fIN\fP\fR|\fB\-v\fR|\fB\-V\fR]
 \fB\-I\fR \fIopen\fP <\fIcommand\fP>
 
-ipmitool [\fB\-c\fR|\fB\-h\fR|\fB\-v\fR|\fB\-V\fR]
+ipmitool [\fB\-c\fR|\fB\-h\fR|\fB\-v\fR|\fB\-D\fR|\fB\-V\fR]
 \fB\-I\fR \fIlan\fP \fB\-H\fR <\fIhostname\fP>
          [\fB\-p\fR <\fIport\fP>]
          [\fB\-U\fR <\fIusername\fP>]
@@ -17,7 +17,7 @@ ipmitool [\fB\-c\fR|\fB\-h\fR|\fB\-v\fR|\fB\-V\fR]
          [\fB\-e\fR <\fIesc_char\fP>]
          <\fIcommand\fP>
 
-ipmitool [\fB\-c\fR|\fB\-h\fR|\fB\-v\fR|\fB\-V\fR]
+ipmitool [\fB\-c\fR|\fB\-h\fR|\fB\-v\fR|\fB\-D\fR|\fB\-V\fR]
 \fB\-I\fR \fIlanplus\fP \fB\-H\fR <\fIhostname\fP>
          [\fB\-p\fR <\fIport\fP>]
          [\fB\-U\fR <\fIusername\fP>]
@@ -158,6 +158,9 @@ multiple times to increase the level of debug output.  If 
given
 three times you will get hexdumps of all incoming and
 outgoing packets.
 .TP 
+\fB\-D\fR
+Show column headers when printing tables.
+.TP 
 \fB\-V\fR
 Display version information.
 
diff --git a/include/ipmitool/ipmi.h b/include/ipmitool/ipmi.h
index 2e43793..5b0c333 100644
--- a/include/ipmitool/ipmi.h
+++ b/include/ipmitool/ipmi.h
@@ -63,6 +63,7 @@
 #define IPMI_PAYLOAD_TYPE_RAKP_4             0x15
 
 extern int verbose;
+extern int show_headers;
 extern int csv_output;
 
 struct ipmi_rq {
diff --git a/lib/ipmi_main.c b/lib/ipmi_main.c
index e904986..e5488a9 100644
--- a/lib/ipmi_main.c
+++ b/lib/ipmi_main.c
@@ -73,12 +73,13 @@
 #endif
 
 #ifdef ENABLE_ALL_OPTIONS
-# define OPTION_STRING "I:hVvcgsEKYao:H:d:P:f:U:p:C:L:A:t:T:m:S:l:b:B:e:k:y:O:"
+# define OPTION_STRING 
"I:hVvDcgsEKYao:H:d:P:f:U:p:C:L:A:t:T:m:S:l:b:B:e:k:y:O:"
 #else
 # define OPTION_STRING "I:hVvcH:f:U:p:d:S:"
 #endif
 
 extern int verbose;
+extern int show_headers;
 extern int csv_output;
 extern const struct valstr ipmi_privlvl_vals[];
 extern const struct valstr ipmi_authtype_session_vals[];
@@ -218,6 +219,7 @@ ipmi_option_usage(const char * progname, struct ipmi_cmd * 
cmdlist, struct ipmi_
        lprintf(LOG_NOTICE, "       -h             This help");
        lprintf(LOG_NOTICE, "       -V             Show version information");
        lprintf(LOG_NOTICE, "       -v             Verbose (can use multiple 
times)");
+       lprintf(LOG_NOTICE, "       -D             Show column headers in 
tables");
        lprintf(LOG_NOTICE, "       -c             Display output in comma 
separated format");
        lprintf(LOG_NOTICE, "       -d N           Specify a /dev/ipmiN device 
to use (default=0)");
        lprintf(LOG_NOTICE, "       -I intf        Interface to use");
@@ -428,6 +430,9 @@ ipmi_main(int argc, char ** argv,
                case 'v':
                        verbose++;
                        break;
+               case 'D':
+                       show_headers = 1;
+                       break;
                case 'c':
                        csv_output = 1;
                        break;
diff --git a/lib/ipmi_sensor.c b/lib/ipmi_sensor.c
index d71485f..4cc0311 100644
--- a/lib/ipmi_sensor.c
+++ b/lib/ipmi_sensor.c
@@ -42,6 +42,7 @@
 #include <ipmitool/ipmi_sensor.h>
 
 extern int verbose;
+extern int show_headers;
 
 #define SCANNING_DISABLED       0x40
 #define READING_UNAVAILABLE    0x20
@@ -595,7 +596,7 @@ ipmi_sensor_list(struct ipmi_intf *intf)
                        continue;
                }
 
-               if (!verbose && row == 0) {
+               if (!verbose && row == 0 && show_headers) {
                        printf("SENSOR           | VALUE      | UNITS      "
                                "| STATE | LO NOREC  | LO CRIT   | LO NOCRIT "
                                "| UP NOCRIT | UP CRIT   | UP NOREC\n");
diff --git a/src/ipmievd.c b/src/ipmievd.c
index e726da8..b900715 100644
--- a/src/ipmievd.c
+++ b/src/ipmievd.c
@@ -81,6 +81,7 @@ char pidfile[64];
 
 /* global variables */
 int verbose = 0;
+int show_headers = 0;
 int csv_output = 0;
 uint16_t selwatch_count = 0;   /* number of entries in the SEL */
 uint16_t selwatch_lastid = 0;  /* current last entry in the SEL */
diff --git a/src/ipmitool.c b/src/ipmitool.c
index b252c84..1ebe16d 100644
--- a/src/ipmitool.c
+++ b/src/ipmitool.c
@@ -78,6 +78,7 @@ extern int ipmi_exec_main(struct ipmi_intf * intf, int argc, 
char ** argv);
 
 int csv_output = 0;
 int verbose = 0;
+int show_headers = 0;
 
 struct ipmi_cmd ipmitool_cmd_list[] = {
        { ipmi_raw_main,     "raw",     "Send a RAW IPMI request and print 
response" },


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

Reply via email to