From: Sebastian Harl Date: Wed, 23 May 2007 12:21:19 +0000 (+0200) Subject: collectd.c: Added '-t' command line option. X-Git-Tag: collectd-4.0.0~7^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=91f2edda6b4c26aa79d8746f7b900c6621e7e754;p=collectd.git collectd.c: Added '-t' command line option. This option allows to test the configuration only. The program immediately exits after parsing the config file. A return code not equal to zero indicates an error. Some typos have been fixed as well. Signed-off-by: Sebastian Harl --- diff --git a/ChangeLog b/ChangeLog index 25c75bfd..05772cf6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,7 +4,9 @@ * collectd: The read-function has been changed to read many plugins in parallel, using threads. Thus, plugins generally need to use thread-safe functions from now on. - * csv plugin: The new `csv' plugin handles output to `comma seperated + * collectd: The '-t' command line options allows to perform syntax tests + of the configuration file and exit immediately. + * csv plugin: The new `csv' plugin handles output to `comma separated values'-files. * rrdtool plugin: The new `rrdtool' plugin handles output to RRD-files. Data can be cached to combine multiple updates into one @@ -34,8 +36,8 @@ plugin. * irq plugin: The new `irq' plugin collects the IRQ-counters. Thanks to Peter Holik for contributing this plugin. - * nut plugin: The new `nut' plugin connects the the upsd of the - `network ups tools' and reads information about the connected UPS. + * nut plugin: The new `nut' plugin connects the upsd of the `network + ups tools' and reads information about the connected UPS. * apache plugin: Support for lighttpd's `BusyServers' (aka. connections) field was added by Florent Monbillard. * collectd-nagios: The new `collectd-nagios' binary queries values diff --git a/src/collectd.c b/src/collectd.c index 49998f96..4fbd5c09 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -320,6 +320,7 @@ int main (int argc, char **argv) struct sigaction sigIntAction; struct sigaction sigTermAction; char *configfile = CONFIGFILE; + int test_config = 0; const char *basedir; #if COLLECT_DAEMON struct sigaction sigChldAction; @@ -332,7 +333,7 @@ int main (int argc, char **argv) { int c; - c = getopt (argc, argv, "hC:" + c = getopt (argc, argv, "htC:" #if COLLECT_DAEMON "fP:" #endif @@ -346,6 +347,9 @@ int main (int argc, char **argv) case 'C': configfile = optarg; break; + case 't': + test_config = 1; + break; #if COLLECT_DAEMON case 'P': global_option_set ("PIDFile", optarg); @@ -397,6 +401,9 @@ int main (int argc, char **argv) if (init_global_variables () != 0) return (1); + if (test_config) + return (0); + #if COLLECT_DAEMON /* * fork off child diff --git a/src/collectd.pod b/src/collectd.pod index d7c854e1..aae43154 100644 --- a/src/collectd.pod +++ b/src/collectd.pod @@ -10,7 +10,7 @@ collectd I<[options]> collectd is a daemon that receives system statistics and makes them available in a number of ways. The main daemon itself doesn't have any real functionality -appart from loading, querying and submitting to plugins. For a description of +apart from loading, querying and submitting to plugins. For a description of available plugins please see L below. =head1 OPTIONS @@ -26,6 +26,11 @@ Specify an alternative config file. This is the place to go when you wish to change B's behavior. The path may be relative to the current working directory. +=item B<-t> + +Test the configuration only. The program immediately exits after parsing the +config file. A return code not equal to zero indicates an error. + =item B<-P> Ipid-fileE> Specify an alternative pid file. This overwrites any settings in the config