From 835274145aecbb82e4e09209a47cf5849dbc50d2 Mon Sep 17 00:00:00 2001 From: Sebastien Godard Date: Sun, 27 Feb 2011 15:45:23 +0100 Subject: [PATCH] Option -V from sysstat commands now displays the version number on stdout 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 (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 (C) Sebastien Godard (sysstat 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 " 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 | 3 ++ CREDITS | 1 + common.c | 6 ++-- sar.c | 104 +++++++++++++++++++++++++++---------------------------- 4 files changed, 58 insertions(+), 56 deletions(-) diff --git a/CHANGES b/CHANGES index d89dc19..7096aa3 100644 --- a/CHANGES +++ b/CHANGES @@ -10,8 +10,11 @@ xxxx/xx/xx: Version 10.0.0 - Sebastien Godard (sysstat 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 orange.fr) INFO: stats_queue structure format has changed and is *not* diff --git a/CREDITS b/CREDITS index 07cd359..f4e6c0b 100644 --- a/CREDITS +++ b/CREDITS @@ -137,6 +137,7 @@ I would also thank the following people for their hints or bug reports Chuck Blake Michael Blakeley Pascal Bleser + Lodewijk Bonebakker Jesse Brandeburg Xavier Bru Jason Burnett diff --git a/common.c b/common.c index afa217b..1bf459a 100644 --- 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 orange.fr)\n"); - exit(1); + printf(_("sysstat version %s\n"), VERSION); + printf("(C) Sebastien Godard (sysstat orange.fr)\n"); + exit(0); } /* diff --git a/sar.c b/sar.c index ca998b0..3597167 100644 --- 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 ] [ [ ] ]\n"), + fprintf(fp, _("Usage: %s [ options ] [ [ ] ]\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 { | SUM | ALL | XALL }\n" - "\t\tInterrupts statistics\n")); - fprintf(stderr, _("\t-m { [,...] | 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 { [,...] | 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 { | SUM | ALL | XALL }\n" + "\t\tInterrupts statistics\n")); + printf(_("\t-m { [,...] | 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 { [,...] | 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); } /* -- 2.40.0