The -T switch:
- implies -f
- does not start any read threads
- invokes callback() foreach list_read and will exit 1 on failure, 0
otherwise
Makes for a nicer dryrun than -f + ^C, also makes it possible to wrap
with a test harness such as Test.pm
Signed-off-by: Doug MacEachern <dougm@hyperic.com>
Signed-off-by: Florian Forster <octo@leeloo.lan.home.verplant.org>
" -C <file> Configuration file.\n"
" Default: "CONFIGFILE"\n"
" -t Test config and exit.\n"
" -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
" -P <file> PID-file.\n"
" Default: "PIDFILE"\n"
#if COLLECT_DAEMON
struct sigaction sig_pipe_action;
char *configfile = CONFIGFILE;
int test_config = 0;
struct sigaction sig_pipe_action;
char *configfile = CONFIGFILE;
int test_config = 0;
const char *basedir;
#if COLLECT_DAEMON
struct sigaction sig_chld_action;
const char *basedir;
#if COLLECT_DAEMON
struct sigaction sig_chld_action;
- c = getopt (argc, argv, "htC:"
+ c = getopt (argc, argv, "htTC:"
#if COLLECT_DAEMON
"fP:"
#endif
#if COLLECT_DAEMON
"fP:"
#endif
case 't':
test_config = 1;
break;
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);
#if COLLECT_DAEMON
case 'P':
global_option_set ("PIDFile", optarg);
* run the actual loops
*/
do_init ();
* run the actual loops
*/
do_init ();
+ if (test_readall)
+ {
+ if (plugin_read_all_once ())
+ return (1);
+ }
+ else
+ do_loop ();
/* close syslog */
INFO ("Exiting normally");
/* 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.
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
=item B<-P> I<E<lt>pid-fileE<gt>>
Specify an alternative pid file. This overwrites any settings in the config
+ if (read_threads == NULL)
+ return;
+
pthread_mutex_lock (&read_lock);
read_loop = 0;
DEBUG ("plugin: stop_threads: Signalling `read_cond'");
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);
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 */
}
} /* void plugin_init_all */
pthread_mutex_unlock (&read_lock);
} /* void plugin_read_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)
{
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);
void plugin_init_all (void);
void plugin_read_all (void);
+int plugin_read_all_once (void);
void plugin_shutdown_all (void);
/*
void plugin_shutdown_all (void);
/*