collectd: Add the -T option.
[collectd.git] / src / collectd.c
index 9526ec9..57701c0 100644 (file)
@@ -253,6 +253,7 @@ static void exit_usage (int status)
                        "    -C <file>       Configuration file.\n"
                        "                    Default: "CONFIGFILE"\n"
                        "    -t              Test config and exit.\n"
+                       "    -T              Test plugin read and exit.\n"
                        "    -P <file>       PID-file.\n"
                        "                    Default: "PIDFILE"\n"
 #if COLLECT_DAEMON
@@ -398,6 +399,7 @@ int main (int argc, char **argv)
        struct sigaction sig_pipe_action;
        char *configfile = CONFIGFILE;
        int test_config  = 0;
+       int test_readall = 0;
        const char *basedir;
 #if COLLECT_DAEMON
        struct sigaction sig_chld_action;
@@ -410,7 +412,7 @@ int main (int argc, char **argv)
        {
                int c;
 
-               c = getopt (argc, argv, "htC:"
+               c = getopt (argc, argv, "htTC:"
 #if COLLECT_DAEMON
                                "fP:"
 #endif
@@ -427,6 +429,13 @@ int main (int argc, char **argv)
                        case 't':
                                test_config = 1;
                                break;
+                       case 'T':
+                               test_readall = 1;
+                               global_option_set ("ReadThreads", "-1");
+#if COLLECT_DAEMON
+                               daemonize = 0;
+#endif /* COLLECT_DAEMON */
+                               break;
 #if COLLECT_DAEMON
                        case 'P':
                                global_option_set ("PIDFile", optarg);
@@ -580,7 +589,13 @@ int main (int argc, char **argv)
         * run the actual loops
         */
        do_init ();
-       do_loop ();
+       if (test_readall)
+       {
+               if (plugin_read_all_once ())
+                       return (1);
+       }
+       else
+               do_loop ();
 
        /* close syslog */
        INFO ("Exiting normally");