diff --git a/src/collectd.c b/src/collectd.c
index 1b44e1537153afbef6edc546739c6a174791d961..a1e15bf1e7ca52b674632b1308012c91297d2c00 100644 (file)
--- a/src/collectd.c
+++ b/src/collectd.c
" General:\n"
" -C <file> Configuration file.\n"
" Default: "CONFIGFILE"\n"
" General:\n"
" -C <file> Configuration file.\n"
" Default: "CONFIGFILE"\n"
+ " -P <file> PID-file.\n"
+ " Default: "PIDFILE"\n"
#if COLLECT_DAEMON
" -f Don't fork to the background.\n"
#endif
#if COLLECT_DAEMON
" -f Don't fork to the background.\n"
#endif
curtime = time (NULL);
/* Issue all plugins */
curtime = time (NULL);
/* Issue all plugins */
- plugin_read_all ();
+ plugin_read_all (&loop);
if (gettimeofday (&tv_now, NULL) < 0)
{
if (gettimeofday (&tv_now, NULL) < 0)
{
if (timeval_sub_timespec (&tv_next, &tv_now, &ts_wait) != 0)
{
if (timeval_sub_timespec (&tv_next, &tv_now, &ts_wait) != 0)
{
- syslog (LOG_WARNING, "No sleeping because `timeval_sub_timespec' returned non-zero!");
+ syslog (LOG_WARNING, "Not sleeping because `timeval_sub_timespec' returned non-zero!");
continue;
}
continue;
}
- while (nanosleep (&ts_wait, &ts_wait) == -1)
+ while ((loop == 0) && (nanosleep (&ts_wait, &ts_wait) == -1))
{
if (errno != EINTR)
{
{
if (errno != EINTR)
{
return (1);
}
return (1);
}
- fprintf (fh, "%d\n", getpid());
+ fprintf (fh, "%i\n", (int) getpid ());
fclose(fh);
return (0);
fclose(fh);
return (0);
char *configfile = CONFIGFILE;
#if COLLECT_DAEMON
struct sigaction sigChldAction;
char *configfile = CONFIGFILE;
#if COLLECT_DAEMON
struct sigaction sigChldAction;
- char *pidfile = PIDFILE;
+ char *pidfile = NULL;
pid_t pid;
int daemonize = 1;
#endif
pid_t pid;
int daemonize = 1;
#endif
#if HAVE_LIBRRD
operating_mode = MODE_LOCAL;
#if HAVE_LIBRRD
operating_mode = MODE_LOCAL;
+#else
+ operating_mode = MODE_CLIENT;
#endif
/* open syslog */
#endif
/* open syslog */
c = getopt (argc, argv, "hC:"
#if COLLECT_DAEMON
c = getopt (argc, argv, "hC:"
#if COLLECT_DAEMON
- "f"
+ "fP:"
#endif
);
#endif
);
configfile = optarg;
break;
#if COLLECT_DAEMON
configfile = optarg;
break;
#if COLLECT_DAEMON
+ case 'P':
+ pidfile = optarg;
+ break;
case 'f':
daemonize = 0;
break;
case 'f':
daemonize = 0;
break;
sigChldAction.sa_handler = SIG_IGN;
sigaction (SIGCHLD, &sigChldAction, NULL);
sigChldAction.sa_handler = SIG_IGN;
sigaction (SIGCHLD, &sigChldAction, NULL);
- if ((pidfile = cf_get_option ("PIDFile", PIDFILE)) == NULL)
+ if ((pidfile == NULL)
+ && ((pidfile = cf_get_option ("PIDFile", PIDFILE)) == NULL))
{
fprintf (stderr, "Cannot obtain pidfile. This shoud not happen. Ever.");
return (1);
{
fprintf (stderr, "Cannot obtain pidfile. This shoud not happen. Ever.");
return (1);
#endif
start_client ();
#endif
start_client ();
+ plugin_shutdown_all ();
+
#if COLLECT_DEBUG
if (logfile != NULL)
DBG_STOPFILE("debug file closed.");
#if COLLECT_DEBUG
if (logfile != NULL)
DBG_STOPFILE("debug file closed.");