Skip to content

Commit

Permalink
Porting #5282: ss_host_cpu.php does not work on remote poller
Browse files Browse the repository at this point in the history
Only when hmib is enabled.
  • Loading branch information
TheWitness committed Apr 1, 2023
1 parent 2fd8c25 commit 9e2f060
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 @@ -59,6 +59,7 @@ Cacti CHANGELOG

1.2.25
-issue#5279: Rebuild poller cache does not work as expected
-issue#5282: Script ss_host_cpu.php does not work as expected when on a remote data collector with hmib enabled
-issue#5283: Trying to access array offset on value of type null in file lib/functions.php on line: 2276

1.2.24
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 @@ -87,7 +91,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 @@ -99,7 +107,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 Down Expand Up @@ -127,7 +139,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 9e2f060

Please sign in to comment.