[collectd] [PATCH] collectd.c: Added '-t' command line option.

Sebastian Harl sh at tokkee.org
Wed May 23 14:21:19 CEST 2007


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 <sh at tokkee.org>
---
 ChangeLog        |    8 +++++---
 src/collectd.c   |    9 ++++++++-
 src/collectd.pod |    7 ++++++-
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 25c75bf..05772cf 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 49998f9..4fbd5c0 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 d7c854e..aae4315 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</PLUGINS> below.
 
 =head1 OPTIONS
@@ -26,6 +26,11 @@ Specify an alternative config file. This is the place to go when you wish to
 change B<collectd>'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> I<E<lt>pid-fileE<gt>>
 
 Specify an alternative pid file. This overwrites any settings in the config 
-- 
1.4.4.3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20070523/1f1f3780/attachment.pgp 


More information about the collectd mailing list