Uptime test error message contain the pid file name
Issue #1082
resolved
Hello Tildeslash,
the uptime test error message/event contain the pid file name and not the uptime watermark.
Snipped from the "monit.log" file.
[2023-07-10T20:25:05+0200] error : 'Mac.local' uptime test failed for (null) -- current uptime is 684339 seconds
[2023-07-10T20:25:05+0200] error : 'Monit' uptime test failed for /var/run/monit.pid -- current uptime is 426678 seconds
[2023-07-10T20:25:35+0200] error : 'Mac.local' uptime test failed for (null) -- current uptime is 684369 seconds
[2023-07-10T20:25:35+0200] error : 'Monit' uptime test failed for /var/run/monit.pid -- current uptime is 426708 seconds
And a snipped with my modifications.
[2023-07-10T20:25:43+0200] info : 'Mac.local' Monit 5.33.0 stopped
[2023-07-10T20:26:48+0200] info : Starting Monit 5.33.0 daemon with http interface at [localhost]:2812
[2023-07-10T20:26:48+0200] info : 'Mac.local' Monit 5.33.0 started
[2023-07-10T20:26:48+0200] error : 'Mac.local' uptime test failed for 1.920 m -- current uptime is 11.407 m
[2023-07-10T20:26:48+0200] error : 'Monit' uptime test failed for 3.600 s -- current uptime is 7.113 m
[2023-07-10T20:27:18+0200] error : 'Mac.local' uptime test failed for 1.920 m -- current uptime is 11.408 m
[2023-07-10T20:27:18+0200] error : 'Monit' uptime test failed for 3.600 s -- current uptime is 7.114 m
The message point to the wrong data, see "validate.c" and test "_checkUptime".
Event_post(s, Event_Uptime, State_Failed, ul->action, "uptime test failed for %s -- current uptime is %llu seconds", s->path, (unsigned long long)uptime);
} else {
Event_post(s, Event_Uptime, State_Succeeded, ul->action, "uptime test succeeded [current uptime = %llu seconds]", (unsigned long long)uptime);
It should look like this.
Event_post(s, Event_Uptime, State_Failed, ul->action, "uptime test failed for %s -- current uptime is %s", Convert_time2str(ul->uptime, (char[11]){}), Convert_time2str(uptime, (char[11]){}));
} else {
Event_post(s, Event_Uptime, State_Succeeded, ul->action, "uptime test succeeded [current uptime = %s]", Convert_time2str(uptime, (char[11]){}));
The "s->path" should changed to "s->uptime" and "Convert_time2str" is more useful instead of the fix "seconds", like in the other events with a time value, I think.
I will add a pull request soon,
Lutz
p.s.
I had almost forgotten to report, sorry, in addition to Issue #1070 Add host uptime in _status/format=xml page
Comments (3)
-
reporter -
repo owner - changed status to resolved
Thanks for PR
-
repo owner Fixed: Issue
#1082: Wrong error message for the uptime test. Thanks to Lutz Mader.→ <<cset 01f45227d966>>
- Log in to comment
Hello,
I create the pull request #125 to fix the issue.
A suggestion only,
Lutz