" -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
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;
{
int c;
- c = getopt (argc, argv, "htC:"
+ c = getopt (argc, argv, "htTC:"
#if COLLECT_DAEMON
"fP:"
#endif
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);
* 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");
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<-T>
+
+Test the plugin read callbacks only. The program immediately exits after invoking
+the read callbacks once. 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
{
int i;
+ if (read_threads == NULL)
+ return;
+
pthread_mutex_lock (&read_lock);
read_loop = 0;
DEBUG ("plugin: stop_threads: Signalling `read_cond'");
int num;
rt = global_option_get ("ReadThreads");
num = atoi (rt);
- start_threads ((num > 0) ? num : 5);
+ if (num != -1)
+ start_threads ((num > 0) ? num : 5);
}
} /* void plugin_init_all */
pthread_mutex_unlock (&read_lock);
} /* void plugin_read_all */
+int plugin_read_all_once (void)
+{
+ llentry_t *le;
+ read_func_t *rf;
+ int status;
+
+ if (list_read == NULL)
+ return (0);
+
+ for (le = llist_head (list_read);
+ le != NULL;
+ le = le->next)
+ {
+ rf = (read_func_t *) le->value;
+ status = rf->callback ();
+ if (status != 0)
+ {
+ NOTICE ("read-function of plugin `%s' failed.",
+ le->key);
+ return status;
+ }
+ }
+
+ return (0);
+} /* void plugin_read_all_once */
+
int plugin_write (const char *plugin, /* {{{ */
const data_set_t *ds, const value_list_t *vl)
{
void plugin_init_all (void);
void plugin_read_all (void);
+int plugin_read_all_once (void);
void plugin_shutdown_all (void);
/*