diff options
author | Keuin <[email protected]> | 2023-01-21 01:34:58 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2023-01-21 01:40:19 +0800 |
commit | c3122720152bb00e7c0e0fb86fd2d94a23c4abf9 (patch) | |
tree | 0b5f73c4622e482dab7206dc8b31bf0ccc4bddd6 /netmon.c | |
parent | 2e699d04ad816a401fb481a619e9a3b13dbb9a5e (diff) |
Diffstat (limited to 'netmon.c')
-rw-r--r-- | netmon.c | 29 |
1 files changed, 22 insertions, 7 deletions
@@ -12,15 +12,29 @@ #include "optparse.h" const char *logfile = "netmon.log"; -const char *pingdest = NULL; // which host to ping. If NULL, test tcp instead -const char *failcmd = "reboot"; // cmd to be executed. If NULL, reboot // TODO support blanks -unsigned int check_interval_seconds = 30; // seconds to sleep between checks -int max_check_failure = 5; // how many failures to reboot the system -int as_daemon = 0; // should run as a daemon process -unsigned int failure_sleep_seconds = 60; // seconds to sleep before resuming check after a network failure is detected + +// which host to ping. If NULL, test tcp instead +const char *pingdest = NULL; + +// TODO support blanks +// cmd to be executed. If NULL, reboot +const char *failcmd = "reboot"; + +// seconds to sleep between checks +unsigned int check_interval_seconds = 30; + +// how many failures to reboot the system +int max_check_failure = 5; + +// should run as a daemon process +int as_daemon = 0; + // TODO make failure_sleep_seconds configurable +// seconds to sleep before resuming check after a network failure is detected +unsigned int failure_sleep_seconds = 60; volatile int failure_detected = 0; + void *logger = NULL; void daemonize() { @@ -128,7 +142,8 @@ void loop() { log_info(logger, tmp); system(failcmd); - snprintf(tmp, 255, "Wait %d secs before resume checking.\n", failure_sleep_seconds); + snprintf(tmp, 255, "Wait %d secs before resume checking.\n", + failure_sleep_seconds); log_debug(logger, tmp); unsigned t = failure_sleep_seconds; while ((t = sleep(t))); |