Skip to content

Commit

Permalink
Porting #5160 - device time status'
Browse files Browse the repository at this point in the history
Host table status_fail_date and Status_rec_date can appear wrong
  • Loading branch information
TheWitness committed Jan 22, 2023
1 parent 001b504 commit 9c198da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Cacti CHANGELOG
-issue#5147: Error 500 on apache when changing languages
-issue#5155: Local Linux Machine Device Package Damaged
-issue#5160: Translations on debian 'Bullseye' systems may cause server errors
-issue#5169: Host table status_fail_date and Status_rec_date can appear wrong
-issue#5184: Cacti permission checks generate SQL errors is the user has been deleted

1.2.23
Expand Down
34 changes: 9 additions & 25 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1845,15 +1845,9 @@ function update_host_status(int $status, int $host_id, Net_Ping &$ping, int $pin

$issue_log_message = true;

/* update the failure date only if the failure count is 1 */
if ($host['status_event_count'] == $ping_failure_count) {
$host['status_fail_date'] = time();
}
} else {
/* host down for the first time, set event date */
if ($host['status_event_count'] == $ping_failure_count) {
$host['status_fail_date'] = time();
}
$host['status_fail_date'] = time();

$host['status_event_count'] = 0;
}
} elseif ($host['status'] == HOST_RECOVERING) {
/* host is recovering, put back in failed state */
Expand All @@ -1867,8 +1861,7 @@ function update_host_status(int $status, int $host_id, Net_Ping &$ping, int $pin
$host['status_event_count']++;
}
} else {
/* host is up!! */
/* update total polls and availability */
/* host is up! Update total polls and availability */
$host['total_polls']++;
$host['availability'] = 100 * ($host['total_polls'] - $host['failed_polls']) / $host['total_polls'];

Expand Down Expand Up @@ -1943,34 +1936,25 @@ function update_host_status(int $status, int $host_id, Net_Ping &$ping, int $pin

$issue_log_message = true;

/* update the recovery date only if the recovery count is 1 */
if ($host['status_event_count'] == $ping_recovery_count) {
$host['status_rec_date'] = time();
}

/* reset the event counter */
$host['status_rec_date'] = time();
$host['status_event_count'] = 0;
} else {
/* host recovering for the first time, set event date */
if ($host['status_event_count'] == $ping_recovery_count) {
$host['status_rec_date'] = time();
}
}
} else {
/* host was unknown and now is up */
$host['status'] = HOST_UP;
$host['status'] = HOST_UP;

$host['status_event_count'] = 0;
}
}

/* if the user wants a flood of information then flood them */
if (($host['status'] == HOST_UP) || ($host['status'] == HOST_RECOVERING)) {
if ($host['status'] == HOST_UP || $host['status'] == HOST_RECOVERING) {
/* log ping result if we are to use a ping for reachability testing */
if ($ping_availability == AVAIL_SNMP_AND_PING) {
cacti_log("Device[$host_id] PING: " . $ping->ping_response, $print_data_to_stdout, 'PING', POLLER_VERBOSITY_HIGH);
cacti_log("Device[$host_id] SNMP: " . $ping->snmp_response, $print_data_to_stdout, 'PING', POLLER_VERBOSITY_HIGH);
} elseif ($ping_availability == AVAIL_SNMP) {
if (($host['snmp_community'] == '') && ($host['snmp_version'] != 3)) {
if ($host['snmp_community'] == '' && $host['snmp_version'] != 3) {
cacti_log("Device[$host_id] SNMP: Device does not require SNMP", $print_data_to_stdout, 'PING', POLLER_VERBOSITY_HIGH);
} else {
cacti_log("Device[$host_id] SNMP: " . $ping->snmp_response, $print_data_to_stdout, 'PING', POLLER_VERBOSITY_HIGH);
Expand Down

0 comments on commit 9c198da

Please sign in to comment.