Problem with monitor's downtime

Support for the Plugin Architecture

Moderators: Developers, Moderators

Post Reply
hisarack
Posts: 3
Joined: Thu May 22, 2014 4:36 am

Problem with monitor's downtime

Post by hisarack »

Hello all,

My Cacti has wrong downtime problem about Monitor Plugin, please see the attachment.

After tracing plugins/monitor/monitor.php, i found the downtime is calculated by monitor_print_host_downtime function with $row['status_fail_date'] arguments.

$row['status_fail_date'] is captured from host table in database,the default value is "0000-00-00 00:00:00". Then, i check the lib/functions.php, $row['status_fail_date'] is updated by update_host_status function.

this is code snippet of update_host_status function.

if ($status == HOST_DOWN) {
.....skip....
if ($hosts[$host_id]["status"] == HOST_UP) {
/* increment the event failure count */
$hosts[$host_id]["status_event_count"]++;

/* if it's time to issue an error message, indicate so */
if ($hosts[$host_id]["status_event_count"] >= $ping_failure_count) {
/* host is now down, flag it that way */
$hosts[$host_id]["status"] = HOST_DOWN;

$issue_log_message = true;
/* update the failure date only if the failure count is 1 */
if ($ping_failure_count == 1) {
$hosts[$host_id]["status_fail_date"] = date("Y-m-d H:i:s");
}

/* host is down, but not ready to issue log message */
} else {
/* host down for the first time, set event date */
if ($hosts[$host_id]["status_event_count"] == 1) {
$hosts[$host_id]["status_fail_date"] = date("Y-m-d H:i:s");
}
}
}

My problem is why $hosts[$host_id]["status_fail_date"] is only updated when $ping_failure_count equals to 1. Can i remove the if-else statement?

Sorry for my bad english :(
Thanks for any help!!! :D
Attachments
wrong downtime problem at monitor plugin
wrong downtime problem at monitor plugin
pic.png (185.96 KiB) Viewed 16072 times
ajamali
Posts: 4
Joined: Thu Feb 14, 2013 10:46 am

Re: Problem with monitor's downtime

Post by ajamali »

I have the exact same problem, Did you fix it?
ajamali
Posts: 4
Joined: Thu Feb 14, 2013 10:46 am

Re: Problem with monitor's downtime

Post by ajamali »

Please someone help me tp solve this issue!
hisarack
Posts: 3
Joined: Thu May 22, 2014 4:36 am

Re: Problem with monitor's downtime

Post by hisarack »

Hi ajamali,

Following the bug issue(http://bugs.cacti.net/view.php?id=2257),
i add the two if statements by myself.
It's work on me for new alarm host:)
ajamali
Posts: 4
Joined: Thu Feb 14, 2013 10:46 am

Re: Problem with monitor's downtime

Post by ajamali »

hisarack wrote:Hi ajamali,

Following the bug issue(http://bugs.cacti.net/view.php?id=2257),
i add the two if statements by myself.
It's work on me for new alarm host:)
Thank you very much it is working now
raubach
Posts: 1
Joined: Thu Jun 29, 2017 12:12 pm

Re: Problem with monitor's downtime

Post by raubach »

Hey, hisarack and ajamali...

The link of the bug issue is not available anymore. Someone can share this again. I'm with the same problem. :(
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests