@cryptotaxi247 / netdata-1 / commits / 0b3b92cdf

added common version options to all C programs; fixes #1927

Costa Tsaousis (ktsaou) committed Mar 11, 2017 at 11:48 UTC 0b3b92cdf87f4b8ddeae69a651c24891112171aa
3 files changed +57 -17
src/apps_plugin.c
+3 -3
@@ -3199,7 +3199,7 @@ static void parse_args(int argc, char **argv)
3199 }
3200 }
3201
3202 - if(strcmp("version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0) {
3202 + if(strcmp("version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0 || strcmp("-V", argv[i]) == 0) {
3203 printf("apps.plugin %s\n", VERSION);
3204 exit(0);
3205 }
@@ -3269,7 +3269,7 @@ static void parse_args(int argc, char **argv)
3269 "\n"
3270 " This program is a data collector plugin for netdata.\n"
3271 "\n"
3272 - " Valid command line options:\n"
3272 + " Available command line options:\n"
3273 "\n"
3274 " SECONDS set the data collection frequency\n"
3275 "\n"
@@ -3292,7 +3292,7 @@ static void parse_args(int argc, char **argv)
3292 " apps_groups.conf\n"
3293 " (default NAME=groups)\n"
3294 "\n"
3295 - " version print program version and exit\n"
3295 + " version or -v or -V print program version and exit\n"
3296 "\n"
3297 , VERSION
3298 );
src/freeipmi_plugin.c
+52 -14
@@ -1434,7 +1434,11 @@ int main (int argc, char **argv) {
1434 }
1435 }
1436
1437 - if(strcmp("debug", argv[i]) == 0) {
1437 + if(strcmp("version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0 || strcmp("-V", argv[i]) == 0) {
1438 + printf("freeipmi.plugin %s\n", VERSION);
1439 + exit(0);
1440 + }
1441 + else if(strcmp("debug", argv[i]) == 0) {
1442 debug = 1;
1443 continue;
1444 }
@@ -1449,21 +1453,55 @@ int main (int argc, char **argv) {
1453 else if(strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
1454 fprintf(stderr,
1455 "\n"
1452 - "netdata freeipmi.plugin " VERSION "\n"
1453 - "Usage:\n"
1456 + " netdata freeipmi.plugin %s\n"
1457 + " Copyright (C) 2016-2017 Costa Tsaousis <costa@tsaousis.gr>\n"
1458 + " Released under GNU General Public License v3 or later.\n"
1459 + " All rights reserved.\n"
1460 + "\n"
1461 + " This program is a data collector plugin for netdata.\n"
1462 + "\n"
1463 + " Available command line options:\n"
1464 + "\n"
1465 + " SECONDS data collection frequency\n"
1466 + " minimum: %d\n"
1467 + "\n"
1468 + " debug enable verbose output\n"
1469 + " default: disabled\n"
1470 + "\n"
1471 + " sel\n"
1472 + " no-sel enable/disable SEL collection\n"
1473 + " default: %s\n"
1474 + "\n"
1475 + " hostname HOST\n"
1476 + " username USER\n"
1477 + " password PASS connect to remote IPMI host\n"
1478 + " default: local IPMI processor\n"
1479 + "\n"
1480 + " sdr-cache-dir PATH directory for SDR cache files\n"
1481 + " default: %s\n"
1482 + "\n"
1483 + " sensor-config-file FILE filename to read sensor configuration\n"
1484 + " default: %s\n"
1485 + "\n"
1486 + " -v\n"
1487 + " -V\n"
1488 + " version print version and exit\n"
1489 + "\n"
1490 + " Linux kernel module for IPMI is CPU hungry.\n"
1491 + " On Linux run this to lower kipmiN CPU utilization:\n"
1492 + " # echo 10 > /sys/module/ipmi_si/parameters/kipmid_max_busy_us\n"
1493 + "\n"
1494 + " or create: /etc/modprobe.d/ipmi.conf with these contents:\n"
1495 + " options ipmi_si kipmid_max_busy_us=10\n"
1496 "\n"
1455 - " freeipmi.plugin [OPTIONS]\n"
1497 + " For more information:\n"
1498 + " https://github.com/firehol/netdata/wiki/monitoring-IPMI\n"
1499 "\n"
1457 - "Available options:\n"
1458 - " NUMBER, sets the data collection frequency\n"
1459 - " debug, enables verbose output\n"
1460 - " sel, enable SEL collection (it is on by default)\n"
1461 - " no-sel, disable SEL collection\n"
1462 - " hostname X, sets the remote host to connect to\n"
1463 - " username X, sets the username to authenticate at the remote host\n"
1464 - " password X, sets the password to authenticate at the remote host\n"
1465 - " sdr-cache-dir X, sets the directory to save SDR cache files\n"
1466 - " sensor-config-file X, set the filename to read sensor configuration\n"
1500 + , VERSION
1501 + , netdata_update_every
1502 + , netdata_do_sel?"enabled":"disabled"
1503 + , sdr_cache_directory?sdr_cache_directory:"system default"
1504 + , sensor_config_file?sensor_config_file:"system default"
1505 );
1506 exit(1);
1507 }
src/main.c
+2
@@ -230,6 +230,7 @@ struct option_def options[] = {
230 { 't', "The internal clock of netdata.", "seconds", "1"},
231 { 'u', "Run as user.", "username", "netdata"},
232 { 'v', "Print netdata version and exit.", NULL, NULL},
233 + { 'V', "Print netdata version and exit.", NULL, NULL},
234 { 'W', "See Advanced options below.", "options", NULL},
235 };
236
@@ -614,6 +615,7 @@ int main(int argc, char **argv) {
615 config_set(CONFIG_SECTION_GLOBAL, "run as user", optarg);
616 break;
617 case 'v':
618 + case 'V':
619 printf("%s %s\n", program_name, program_version);
620 return 0;
621 case 'W':