|
version 1.1.1.2, 2013/07/21 23:54:41
|
version 1.1.1.3, 2016/11/02 10:09:12
|
|
Line 215 usage(const char *progname, int status)
|
Line 215 usage(const char *progname, int status)
|
| if (status != 0) |
if (status != 0) |
| fprintf(stderr, "Try `%s --help' for more information.\n", progname); |
fprintf(stderr, "Try `%s --help' for more information.\n", progname); |
| else |
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\ |
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\ |
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\ |
up based on whether it can connect to the daemon's vty unix stream socket.\n\ |
|
Line 259 the -m and -M options allow you to control the minimum
|
Line 260 the -m and -M options allow you to control the minimum
|
| restart commands. The minimum restart delay is recalculated each time\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\ |
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\ |
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\ | Otherwise, the interval is doubled (but capped at the -M value).\n\n", |
| Options:\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\ |
-d, --daemon Run in daemon mode. In this mode, error messages are sent\n\ |
| to syslog instead of stdout.\n\ |
to syslog instead of stdout.\n\ |
| -S, --statedir Set the vty socket directory (default is %s)\n\ |
-S, --statedir Set the vty socket directory (default is %s)\n\ |
|
Line 318 Options:\n\
|
Line 323 Options:\n\
|
| it with a space. This is an ugly hack to circumvent problems\n\ |
it with a space. This is an ugly hack to circumvent problems\n\ |
| passing command-line arguments with embedded spaces.\n\ |
passing command-line arguments with embedded spaces.\n\ |
| -v, --version Print program version\n\ |
-v, --version Print program version\n\ |
| -h, --help Display this help and exit\n\ | -h, --help Display this help and exit\n", |
| ", progname,mode_str[0],progname,mode_str[1],progname,mode_str[2], | VTYDIR,DEFAULT_LOGLEVEL,LOG_EMERG,LOG_DEBUG,LOG_DEBUG, |
| progname,mode_str[3],progname,mode_str[4],progname,mode_str[2],mode_str[3], | DEFAULT_MIN_RESTART,DEFAULT_MAX_RESTART, |
| VTYDIR,DEFAULT_LOGLEVEL,LOG_EMERG,LOG_DEBUG,LOG_DEBUG, | DEFAULT_PERIOD,DEFAULT_TIMEOUT,DEFAULT_RESTART_TIMEOUT, |
| DEFAULT_MIN_RESTART,DEFAULT_MAX_RESTART, | DEFAULT_PIDFILE); |
| DEFAULT_PERIOD,DEFAULT_TIMEOUT,DEFAULT_RESTART_TIMEOUT,DEFAULT_PIDFILE); | } |
| |
|
| return status; |
return status; |
| } |
} |
| |
|
| static pid_t |
static pid_t |
| run_background(const char *shell_cmd) | run_background(char *shell_cmd) |
| { |
{ |
| pid_t child; |
pid_t child; |
| |
|
|
Line 345 run_background(const char *shell_cmd)
|
Line 350 run_background(const char *shell_cmd)
|
| if (setpgid(0,0) < 0) |
if (setpgid(0,0) < 0) |
| zlog_warn("warning: setpgid(0,0) failed: %s",safe_strerror(errno)); |
zlog_warn("warning: setpgid(0,0) failed: %s",safe_strerror(errno)); |
| { |
{ |
| const char *argv[4] = { "sh", "-c", shell_cmd, NULL}; | char shell[] = "sh"; |
| execv("/bin/sh",(char *const *)argv); | char dashc[] = "-c"; |
| | char *const argv[4] = { shell, dashc, shell_cmd, NULL}; |
| | execv("/bin/sh", argv); |
| zlog_err("execv(/bin/sh -c '%s') failed: %s", |
zlog_err("execv(/bin/sh -c '%s') failed: %s", |
| shell_cmd,safe_strerror(errno)); |
shell_cmd,safe_strerror(errno)); |
| _exit(127); |
_exit(127); |
|
Line 381 restart_kill(struct thread *t_kill)
|
Line 388 restart_kill(struct thread *t_kill)
|
| time_elapsed(&delay,&restart->time); |
time_elapsed(&delay,&restart->time); |
| zlog_warn("Warning: %s %s child process %d still running after " |
zlog_warn("Warning: %s %s child process %d still running after " |
| "%ld seconds, sending signal %d", |
"%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)); |
(restart->kills ? SIGKILL : SIGTERM)); |
| kill(-restart->pid,(restart->kills ? SIGKILL : SIGTERM)); |
kill(-restart->pid,(restart->kills ? SIGKILL : SIGTERM)); |
| restart->kills++; |
restart->kills++; |
|
Line 654 handle_read(struct thread *t_read)
|
Line 661 handle_read(struct thread *t_read)
|
| { |
{ |
| dmn->state = DAEMON_UP; |
dmn->state = DAEMON_UP; |
| zlog_warn("%s state -> up : echo response received after %ld.%06ld " |
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 |
else |
| zlog_warn("%s: slow echo response finally received after %ld.%06ld " |
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) |
else if (gs.loglevel > LOG_DEBUG+1) |
| zlog_debug("%s: echo response received after %ld.%06ld seconds", |
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); |
SET_READ_HANDLER(dmn); |
| if (dmn->t_wakeup) |
if (dmn->t_wakeup) |