summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeuin <[email protected]>2021-12-28 06:00:43 +0800
committerKeuin <[email protected]>2021-12-28 06:00:43 +0800
commitfdad8c8db14c87d5a64226e9372b0db7d79bcbfc (patch)
tree7e9e0a8cdbabf1100cc47057d9a99b41dab632f7
parent0a6f3b2c456e54b9bcf0aceb7151d6c989f9d93b (diff)
Log failure count when network failure is detected. Explicit boundary limiting.v1.0.0
-rw-r--r--netmon.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/netmon.c b/netmon.c
index fb8bf66..2c500d9 100644
--- a/netmon.c
+++ b/netmon.c
@@ -28,7 +28,7 @@ void daemonize() {
}
if (pid > 0) {
char buf[32];
- sprintf(buf, "Child process: %d", pid);
+ snprintf(buf, 31, "Child process: %d", pid);
log_info(logger, buf);
exit(0); // exit parent process
}
@@ -180,8 +180,10 @@ void loop() {
while (1) {
log_info(logger, "Check network.");
if (check_network() != 0) {
- log_info(logger, "Network failure detected.");
++failures;
+ char buf[64];
+ snprintf(buf, 63, "Network failure detected. counter=%d", failures);
+ log_info(logger, buf);
} else {
log_info(logger, "Network is OK.");
failures = 0;