mirror of
https://github.com/Cacti/cacti.git
synced 2026-10-25 12:37:47 +09:00
* Allow form_selectable_cell to more easily port * Removing exclusion for scripts directory * More fixes for scripts * Some issues with ss_host_disk.php that passed locally * More issues not detected locally * Issues with typing in cacti_snmp_walk * Adding base files for non-savy composer users * One more try on ss_host_disk.php * Aparantly I have to add the lock file * More changes to lib/snmp.php after testing * More changes to lib/snmp.php after testing * Fix number script from Copilot review * More Composer reviews * Update scripts/ss_apache_stats.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update scripts/motorola_surfboard_SB6141.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update scripts/motorola_surfboard_SB6141.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Changing syntax of PHP requirement * Updating composer * Attempt to quiet some warnings * Add Syntax Check * Wrong file name * Wrong file name * Better to report before and after --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
55 lines
1.1 KiB
PHP
55 lines
1.1 KiB
PHP
<?php
|
|
|
|
include_once(__DIR__ . '/../include/cli_check.php');
|
|
include_once(__DIR__ . '/../lib/snmp.php');
|
|
|
|
if (!isset($called_by_script_server)) {
|
|
array_shift($_SERVER['argv']);
|
|
print call_user_func_array('ss_multicpu_avg', $_SERVER['argv']);
|
|
}
|
|
|
|
function ss_multicpu_avg(int $device_id) : string {
|
|
$host = db_fetch_row_prepared('SELECT *
|
|
FROM host
|
|
WHERE id = ?',
|
|
[$device_id]);
|
|
|
|
if (!cacti_sizeof($host)) {
|
|
return "load:0\n";
|
|
}
|
|
|
|
$snmp_retries = read_config_option('snmp_retries');
|
|
|
|
$oid_cpus = '.1.3.6.1.2.1.25.3.3.1.2';
|
|
|
|
$array = cacti_snmp_walk(
|
|
$host['hostname'],
|
|
$host['snmp_community'],
|
|
$oid_cpus,
|
|
$host['snmp_version'],
|
|
$host['snmp_username'],
|
|
$host['snmp_password'],
|
|
$host['snmp_auth_protocol'],
|
|
$host['snmp_priv_passphrase'],
|
|
$host['snmp_priv_protocol'],
|
|
$host['snmp_context'],
|
|
$host['snmp_port'],
|
|
$host['snmp_timeout'],
|
|
$snmp_retries
|
|
);
|
|
|
|
$load = 0;
|
|
|
|
if (cacti_sizeof($array)) {
|
|
foreach ($array as $key=>$value) {
|
|
$load += $value['value'];
|
|
}
|
|
} else {
|
|
return "load:0\n";
|
|
}
|
|
|
|
$load = $load / cacti_count($array);
|
|
|
|
return "load:$load\n";
|
|
}
|