#include <sys/un.h>
#include <sys/wait.h>
#include <memory.h>
+#include <systemd.h>
#ifndef MIN
#define MIN(X,Y) (((X) <= (Y)) ? (X) : (Y))
if (status != 0)
fprintf(stderr, "Try `%s --help' for more information.\n", progname);
else
- printf("Usage : %s [OPTION...] <daemon name> ...\n\n\
+ {
+ printf("Usage : %s [OPTION...] <daemon name> ...\n\n\
Watchdog program to monitor status of quagga daemons and try to restart\n\
them if they are down or unresponsive. It determines whether a daemon is\n\
up based on whether it can connect to the daemon's vty unix stream socket.\n\
restart commands. The minimum restart delay is recalculated each time\n\
a restart is attempted: if the time since the last restart attempt exceeds\n\
twice the -M value, then the restart delay is set to the -m value.\n\
-Otherwise, the interval is doubled (but capped at the -M value).\n\n\
-Options:\n\
+Otherwise, the interval is doubled (but capped at the -M value).\n\n",
+ progname,mode_str[0],progname,mode_str[1],progname,mode_str[2],
+ progname,mode_str[3],progname,mode_str[4],progname,mode_str[2],
+ mode_str[3]);
+
+ printf("Options:\n\
-d, --daemon Run in daemon mode. In this mode, error messages are sent\n\
to syslog instead of stdout.\n\
-S, --statedir Set the vty socket directory (default is %s)\n\
it with a space. This is an ugly hack to circumvent problems\n\
passing command-line arguments with embedded spaces.\n\
-v, --version Print program version\n\
--h, --help Display this help and exit\n\
-", progname,mode_str[0],progname,mode_str[1],progname,mode_str[2],
-progname,mode_str[3],progname,mode_str[4],progname,mode_str[2],mode_str[3],
-VTYDIR,DEFAULT_LOGLEVEL,LOG_EMERG,LOG_DEBUG,LOG_DEBUG,
-DEFAULT_MIN_RESTART,DEFAULT_MAX_RESTART,
-DEFAULT_PERIOD,DEFAULT_TIMEOUT,DEFAULT_RESTART_TIMEOUT,DEFAULT_PIDFILE);
+-h, --help Display this help and exit\n",
+ VTYDIR,DEFAULT_LOGLEVEL,LOG_EMERG,LOG_DEBUG,LOG_DEBUG,
+ DEFAULT_MIN_RESTART,DEFAULT_MAX_RESTART,
+ DEFAULT_PERIOD,DEFAULT_TIMEOUT,DEFAULT_RESTART_TIMEOUT,
+ DEFAULT_PIDFILE);
+ }
return status;
}
time_elapsed(&delay,&restart->time);
zlog_warn("Warning: %s %s child process %d still running after "
"%ld seconds, sending signal %d",
- restart->what,restart->name,(int)restart->pid,delay.tv_sec,
+ restart->what,restart->name,(int)restart->pid, (long)delay.tv_sec,
(restart->kills ? SIGKILL : SIGTERM));
kill(-restart->pid,(restart->kills ? SIGKILL : SIGTERM));
restart->kills++;
{
dmn->state = DAEMON_UP;
zlog_warn("%s state -> up : echo response received after %ld.%06ld "
- "seconds", dmn->name,delay.tv_sec,delay.tv_usec);
+ "seconds", dmn->name,
+ (long)delay.tv_sec, (long)delay.tv_usec);
}
else
zlog_warn("%s: slow echo response finally received after %ld.%06ld "
- "seconds", dmn->name,delay.tv_sec,delay.tv_usec);
+ "seconds", dmn->name,
+ (long)delay.tv_sec, (long)delay.tv_usec);
}
else if (gs.loglevel > LOG_DEBUG+1)
zlog_debug("%s: echo response received after %ld.%06ld seconds",
- dmn->name,delay.tv_sec,delay.tv_usec);
+ dmn->name, (long)delay.tv_sec, (long)delay.tv_usec);
SET_READ_HANDLER(dmn);
if (dmn->t_wakeup)
sigint(void)
{
zlog_notice("Terminating on signal");
+ systemd_send_stopping ();
exit(0);
}
gs.restart.interval = gs.min_restart_interval;
master = thread_master_create();
+ systemd_send_started (master, 0);
signal_init (master, array_size(my_signals), my_signals);
srandom(time(NULL));
mode_str[gs.mode],special);
return usage(progname,1);
}
- if (gs.special && (gs.numdaemons < 2))
- {
- fprintf(stderr,"Mode [%s] does not make sense with only 1 daemon "
- "to watch.\n",mode_str[gs.mode]);
- return usage(progname,1);
- }
- zlog_default = openzlog(progname, ZLOG_NONE, 0,
+ zlog_default = openzlog(progname, ZLOG_WATCHQUAGGA, 0,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
zlog_set_level(NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED);
if (daemon_mode)
thread_call (&thread);
}
+ systemd_send_stopping ();
/* Not reached. */
return 0;
}