Skip to content

Commit

Permalink
Fixing #470 from Thold
Browse files Browse the repository at this point in the history
Making Cacti compatible with Cacti/plugin_thold#470
  • Loading branch information
TheWitness committed Apr 6, 2024
1 parent 9d55544 commit 54eb643
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
10 changes: 8 additions & 2 deletions host.php
Expand Up @@ -1469,8 +1469,14 @@ function get_device_records(&$total_rows, $rows) {
$sql_where .= ($sql_where != '' ? " AND host.disabled=''" : " WHERE host.disabled=''");
} elseif (get_request_var('host_status') == '-4') {
$sql_where .= ($sql_where != '' ? " AND (host.status!='3' OR host.disabled='on')" : " WHERE (host.status!='3' OR host.disabled='on')");
} else {
$sql_where .= ($sql_where != '' ? ' AND (host.status=' . get_request_var('host_status') . " AND host.disabled = '')" : 'where (host.status=' . get_request_var('host_status') . " AND host.disabled = '')");
} else { // Host Down

if (db_column_exists('host', 'thold_failure_count')) {
$sql_where .= ($sql_where != '' ? ' AND ':'WHERE ') .
"((host.status=" . get_request_var('host_status') . " OR (status != 2 AND thold_failure_count > 0 AND status_event_count > thold_failure_count) AND host.disabled = ''))";
} else {
$sql_where .= ($sql_where != '' ? ' AND (host.status=' . get_request_var('host_status') . " AND host.disabled = '')" : 'where (host.status=' . get_request_var('host_status') . " AND host.disabled = '')");
}
}

if (get_request_var('host_template_id') == '-1') {
Expand Down
24 changes: 18 additions & 6 deletions lib/html_utility.php
Expand Up @@ -923,15 +923,27 @@ function load_current_session_value($request_var_name, $session_var_name, $defau
}
}

/* get_colored_device_status - given a device's status, return the colored text in HTML
format suitable for display
@arg $disabled (bool) - true if the device is disabled, false is it is not
@arg $status - the status type of the device as defined in global_constants.php
@returns - a string containing html that represents the device's current status */
function get_colored_device_status($disabled, $status) {
/**
* get_colored_device_status - given a device's status, return the colored text in HTML
* format suitable for display
*
* @param bool - true if the device is disabled, false is it is not
* @param int - The device status as defined in global_constants.php
* @param int - The thold failure count is thold is installed
* @param int - The host status event count is thold is installed
*
* @return - a string containing html that represents the device's current status
*/
function get_colored_device_status($disabled, $status, $thold_failure_count = -1, $status_event_count = -1) {
if ($disabled) {
return "<span class='deviceDisabled'>" . __('Disabled') . "</span>";
} else {
if ($status != HOST_RECOVERING && $thold_failure_count > 0) {
if ($status_event_count >= $thold_failure_count) {
return "<span class='deviceDown'>" . __('Down (Thold)') . "</span>";
}
}

switch ($status) {
case HOST_DOWN:
return "<span class='deviceDown'>" . __('Down') . "</span>";
Expand Down

0 comments on commit 54eb643

Please sign in to comment.