]> granicus.if.org Git - sysstat/commitdiff
Option -V from sysstat commands now displays the version number on stdout
authorSebastien Godard <sysstat@orange.fr>
Sun, 27 Feb 2011 14:45:23 +0000 (15:45 +0100)
committerSebastien Godard <sysstat@orange.fr>
Sun, 27 Feb 2011 14:45:23 +0000 (15:45 +0100)
and returns 0 for the exit code.

Option -V used to display the version number on stderr and returns 1 for
the exit code.
This is not the expected behavior as it has done everything we asked properly.
So change this: Display on stdout and returns 0.
The same change has been applied to sar's option -h, which displays a
help message.

Mail from Lodewijk Bonebakker <jlbonebakker@gmail.com> (15/02/2011):
Subject: Systat version reporting

Dear Sebastian,

I have question related to the way you report the version number in sysstat. At the moment, it seems that you write:

sysstat version <versionno>
(C) Sebastien Godard (sysstat <at> orange.fr)

to stderr, and set the error-code to 1.

Given the significant changes between 7/8 and 9, we have a tremendous headache in automatically dealing with the different sar data files, collected during the day on different machines (some which we prefer not to upgrade). Currently in our environment we can work with this way of reporting your version number, but I would like to make a suggestion:

It would greatly help us if the version command returns only "sysstat version <versionno>" to stdout and sets the return code to 0. Our reasoning behind this is that 'sar -V' should print the version number and exit 0, since it has done everything we have asked it to do correctly. A non-zero exit code is then reserved for error-conditions. This way we can efficiently get the version-number, check for proper installation/kernel versioning etc.

Thank you for your time in considering this suggestion,

Kind regards,

Lodewijk Bonebakker

CHANGES
CREDITS
common.c
sar.c

diff --git a/CHANGES b/CHANGES
index d89dc198912d3e7bc38c02706fade5594fb56072..7096aa3050f66819304ccc43dad0e2b8ce7dd8ab 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -10,8 +10,11 @@ xxxx/xx/xx: Version 10.0.0 - Sebastien Godard (sysstat <at> orange.fr)
        * [Jan Kaluza]: Added --debuginfo option to cifsiostat and
          nfsiostat.
        * cifsiostat and nfsiostat manual pages updated.
+       * Sysstat's commands option -V now displays the version number
+         on stdout and returns 0 for the exit code.
        * sysstat_panic function is now defined only in DEBUG mode.
        * NLS updated. Ukrainian translation added.
+       * CREDITS file updated.
 
 2010/12/26: Version 9.1.7 - Sebastien Godard (sysstat <at> orange.fr)
          INFO: stats_queue structure format has changed and is *not*
diff --git a/CREDITS b/CREDITS
index 07cd3597a7f470cf5ffbdee6c8b1791c44e1e254..f4e6c0bd5c6f36908eb8ad3ceb3b0b6f057838fa 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -137,6 +137,7 @@ I would also thank the following people for their hints or bug reports
        Chuck Blake <cb@mit[...].edu>
        Michael Blakeley <mike@bla[...].com>
        Pascal Bleser <pbleser@ato[...].com>
+       Lodewijk Bonebakker <jlbonebakker@gma[...].com>
        Jesse Brandeburg <jesse.brandeburg@int[...].com>
        Xavier Bru <xavier.bru@bul[...].net>
        Jason Burnett <jason@jnj[...].org>
index afa217b0a3ad14ec248feefd1aa434999c0ae820..1bf459a5daf8cbf449cca8cef55e1aa56521fcf5 100644 (file)
--- a/common.c
+++ b/common.c
@@ -54,9 +54,9 @@ unsigned int kb_shift;
  */
 void print_version(void)
 {
-       fprintf(stderr, _("sysstat version %s\n"), VERSION);
-       fprintf(stderr, "(C) Sebastien Godard (sysstat <at> orange.fr)\n");
-       exit(1);
+       printf(_("sysstat version %s\n"), VERSION);
+       printf("(C) Sebastien Godard (sysstat <at> orange.fr)\n");
+       exit(0);
 }
 
 /*
diff --git a/sar.c b/sar.c
index ca998b02830d3e13360264f04cb0d00df7820a19..35971674498821da91f65cf4f7ad41e2b65630e8 100644 (file)
--- a/sar.c
+++ b/sar.c
@@ -85,9 +85,9 @@ extern struct activity *act[];
  * @progname   Name of sysstat command
  ***************************************************************************
  */
-void print_usage_title(char *progname)
+void print_usage_title(FILE *fp, char *progname)
 {
-       fprintf(stderr, _("Usage: %s [ options ] [ <interval> [ <count> ] ]\n"),
+       fprintf(fp, _("Usage: %s [ options ] [ <interval> [ <count> ] ]\n"),
                progname);
 }
 
@@ -101,8 +101,7 @@ void print_usage_title(char *progname)
  */
 void usage(char *progname)
 {
-
-       print_usage_title(progname);
+       print_usage_title(stderr, progname);
        fprintf(stderr, _("Options are:\n"
                          "[ -A ] [ -b ] [ -B ] [ -C ] [ -d ] [ -h ] [ -H ] [ -p ] [ -q ] [ -r ]\n"
                          "[ -R ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -v ] [ -V ] [ -w ] [ -W ] [ -y ]\n"
@@ -123,55 +122,54 @@ void usage(char *progname)
  */
 void display_help(char *progname)
 {
-
-       print_usage_title(progname);
-       fprintf(stderr, _("Main options and reports:\n"));
-       fprintf(stderr, _("\t-b\tI/O and transfer rate statistics\n"));
-       fprintf(stderr, _("\t-B\tPaging statistics\n"));
-       fprintf(stderr, _("\t-d\tBlock device statistics\n"));
-       fprintf(stderr, _("\t-H\tHugepages utilization statistics\n"));
-       fprintf(stderr, _("\t-I { <int> | SUM | ALL | XALL }\n"
-                         "\t\tInterrupts statistics\n"));
-       fprintf(stderr, _("\t-m { <keyword> [,...] | ALL }\n"
-                         "\t\tPower management statistics\n"
-                         "\t\tKeywords are:\n"
-                         "\t\tCPU\tCPU instantaneous clock frequency\n"
-                         "\t\tFAN\tFans speed\n"
-                         "\t\tFREQ\tCPU average clock frequency\n"
-                         "\t\tIN\tVoltage inputs\n"
-                         "\t\tTEMP\tDevices temperature\n"));
-       fprintf(stderr, _("\t-n { <keyword> [,...] | ALL }\n"
-                         "\t\tNetwork statistics\n"
-                         "\t\tKeywords are:\n"
-                         "\t\tDEV\tNetwork interfaces\n"
-                         "\t\tEDEV\tNetwork interfaces (errors)\n"
-                         "\t\tNFS\tNFS client\n"
-                         "\t\tNFSD\tNFS server\n"
-                         "\t\tSOCK\tSockets\t(v4)\n"
-                         "\t\tIP\tIP traffic\t(v4)\n"
-                         "\t\tEIP\tIP traffic\t(v4) (errors)\n"
-                         "\t\tICMP\tICMP traffic\t(v4)\n"
-                         "\t\tEICMP\tICMP traffic\t(v4) (errors)\n"
-                         "\t\tTCP\tTCP traffic\t(v4)\n"
-                         "\t\tETCP\tTCP traffic\t(v4) (errors)\n"
-                         "\t\tUDP\tUDP traffic\t(v4)\n"
-                         "\t\tSOCK6\tSockets\t(v6)\n"
-                         "\t\tIP6\tIP traffic\t(v6)\n"
-                         "\t\tEIP6\tIP traffic\t(v6) (errors)\n"
-                         "\t\tICMP6\tICMP traffic\t(v6)\n"
-                         "\t\tEICMP6\tICMP traffic\t(v6) (errors)\n"
-                         "\t\tUDP6\tUDP traffic\t(v6)\n"));
-       fprintf(stderr, _("\t-q\tQueue length and load average statistics\n"));
-       fprintf(stderr, _("\t-r\tMemory utilization statistics\n"));
-       fprintf(stderr, _("\t-R\tMemory statistics\n"));
-       fprintf(stderr, _("\t-S\tSwap space utilization statistics\n"));
-       fprintf(stderr, _("\t-u [ ALL ]\n"
-                         "\t\tCPU utilization statistics\n"));
-       fprintf(stderr, _("\t-v\tKernel table statistics\n"));
-       fprintf(stderr, _("\t-w\tTask creation and system switching statistics\n"));
-       fprintf(stderr, _("\t-W\tSwapping statistics\n"));
-       fprintf(stderr, _("\t-y\tTTY device statistics\n"));
-       exit(1);
+       print_usage_title(stdout, progname);
+       printf(_("Main options and reports:\n"));
+       printf(_("\t-b\tI/O and transfer rate statistics\n"));
+       printf(_("\t-B\tPaging statistics\n"));
+       printf(_("\t-d\tBlock device statistics\n"));
+       printf(_("\t-H\tHugepages utilization statistics\n"));
+       printf(_("\t-I { <int> | SUM | ALL | XALL }\n"
+                "\t\tInterrupts statistics\n"));
+       printf(_("\t-m { <keyword> [,...] | ALL }\n"
+                "\t\tPower management statistics\n"
+                "\t\tKeywords are:\n"
+                "\t\tCPU\tCPU instantaneous clock frequency\n"
+                "\t\tFAN\tFans speed\n"
+                "\t\tFREQ\tCPU average clock frequency\n"
+                "\t\tIN\tVoltage inputs\n"
+                "\t\tTEMP\tDevices temperature\n"));
+       printf(_("\t-n { <keyword> [,...] | ALL }\n"
+                "\t\tNetwork statistics\n"
+                "\t\tKeywords are:\n"
+                "\t\tDEV\tNetwork interfaces\n"
+                "\t\tEDEV\tNetwork interfaces (errors)\n"
+                "\t\tNFS\tNFS client\n"
+                "\t\tNFSD\tNFS server\n"
+                "\t\tSOCK\tSockets\t(v4)\n"
+                "\t\tIP\tIP traffic\t(v4)\n"
+                "\t\tEIP\tIP traffic\t(v4) (errors)\n"
+                "\t\tICMP\tICMP traffic\t(v4)\n"
+                "\t\tEICMP\tICMP traffic\t(v4) (errors)\n"
+                "\t\tTCP\tTCP traffic\t(v4)\n"
+                "\t\tETCP\tTCP traffic\t(v4) (errors)\n"
+                "\t\tUDP\tUDP traffic\t(v4)\n"
+                "\t\tSOCK6\tSockets\t(v6)\n"
+                "\t\tIP6\tIP traffic\t(v6)\n"
+                "\t\tEIP6\tIP traffic\t(v6) (errors)\n"
+                "\t\tICMP6\tICMP traffic\t(v6)\n"
+                "\t\tEICMP6\tICMP traffic\t(v6) (errors)\n"
+                "\t\tUDP6\tUDP traffic\t(v6)\n"));
+       printf(_("\t-q\tQueue length and load average statistics\n"));
+       printf(_("\t-r\tMemory utilization statistics\n"));
+       printf(_("\t-R\tMemory statistics\n"));
+       printf(_("\t-S\tSwap space utilization statistics\n"));
+       printf(_("\t-u [ ALL ]\n"
+                "\t\tCPU utilization statistics\n"));
+       printf(_("\t-v\tKernel table statistics\n"));
+       printf(_("\t-w\tTask creation and system switching statistics\n"));
+       printf(_("\t-W\tSwapping statistics\n"));
+       printf(_("\t-y\tTTY device statistics\n"));
+       exit(0);
 }
 
 /*