Skip to content

Commit

Permalink
Fixing #5282 - ss_host_cpu.php issues
Browse files Browse the repository at this point in the history
Script ss_host_cpu.php does not work as expected when on a remote data collector with hmib enabled
  • Loading branch information
TheWitness committed Mar 26, 2023
1 parent aea3b60 commit db61516
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -9,6 +9,7 @@ Cacti CHANGELOG
-issue#5272: Boost continues to loose data when archive tables are missed due to overloaded MariaDB
-issue#5275: Boost stats can display odd values when running
-issue#5277: Boost should not attempt to start if there are no poller_output_boost records
-issue#5282: Script ss_host_cpu.php does not work as expected when on a remote data collector with hmib enabled
-feature: Upgrade billboard.js to version 3.7.4
-feature: Upgrade d3.js to version 7.8.2

Expand Down
26 changes: 21 additions & 5 deletions scripts/ss_host_cpu.php
Expand Up @@ -66,10 +66,14 @@ function ss_host_cpu($hostname = '', $host_id = 0, $snmp_auth = '', $cmd = 'inde
$oids = array(
'index' => '.1.3.6.1.2.1.25.3.3.1.2',
'usage' => '.1.3.6.1.2.1.25.3.3.1.2'
);
);

if (($cmd == 'index')) {
$value = api_plugin_hook_function('hmib_get_cpu_indexes', array('host_id' => $host_id));
if (db_table_exists('plugin_hmib_hrProcessor')) {
$value = api_plugin_hook_function('hmib_get_cpu_indexes', array('host_id' => $host_id));
} else {
$value = array();
}

if (is_array($value)) {
$arr_index = ss_host_cpu_get_indexes($hostname, $snmp_community, $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids);
Expand All @@ -86,7 +90,11 @@ function ss_host_cpu($hostname = '', $host_id = 0, $snmp_auth = '', $cmd = 'inde
}
}
} elseif (($cmd == 'num_indexes')) {
$value = api_plugin_hook_function('hmib_get_cpu_indexes', array('host_id' => $host_id));
if (db_table_exists('plugin_hmib_hrProcessor')) {
$value = api_plugin_hook_function('hmib_get_cpu_indexes', array('host_id' => $host_id));
} else {
$value = array();
}

if (is_array($value)) {
$arr_index = ss_host_cpu_get_indexes($hostname, $snmp_community, $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids);
Expand All @@ -97,7 +105,11 @@ function ss_host_cpu($hostname = '', $host_id = 0, $snmp_auth = '', $cmd = 'inde
return cacti_sizeof($indexes);
}
} elseif ($cmd == 'query') {
$value = api_plugin_hook_function('hmib_get_cpu_indexes', array('host_id' => $host_id));
if (db_table_exists('plugin_hmib_hrProcessor')) {
$value = api_plugin_hook_function('hmib_get_cpu_indexes', array('host_id' => $host_id));
} else {
$value = array();
}

if (is_array($value)) {
$arg = $arg1;
Expand All @@ -124,7 +136,11 @@ function ss_host_cpu($hostname = '', $host_id = 0, $snmp_auth = '', $cmd = 'inde
$arg = $arg1;
$index = rtrim($arg2);

$value = api_plugin_hook_function('hmib_get_cpu', array('host_id' => $host_id, 'arg' => $arg, 'index' => $index));
if (db_table_exists('plugin_hmib_hrProcessor')) {
$value = api_plugin_hook_function('hmib_get_cpu', array('host_id' => $host_id, 'arg' => $arg, 'index' => $index));
} else {
$value = array();
}

if (is_array($value)) {
$arr_index = ss_host_cpu_get_indexes($hostname, $snmp_community, $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids);
Expand Down

0 comments on commit db61516

Please sign in to comment.