Skip to content

Commit

Permalink
librenms: Replace deprecated OID 'ssCpuIdle' with 'ssCpuRawIdle'
Browse files Browse the repository at this point in the history
The 'ssCpuIdle' OID has been deprecated in favor of 'ssCpuRawIdle', which
provides more accurate CPU usage metrics over any desired time period.

This commit updates the OID used in LibreNMS from 'ssCpuIdle' to 'ssCpuRawIdle'
in FsSwitch.php to ensure more reliable CPU usage monitoring.

Changes:
- Replaced 'ssCpuIdle' with 'ssCpuRawIdle' in the SNMP walk.
- Updated the CPU usage calculation to use 'ssCpuRawIdle'.

Bug: T285229
Change-Id: I63120ccc03b597d5b9623a77a0f9e6ebd7b6cf3e
  • Loading branch information
denisse-dev committed May 16, 2024
1 parent 245a4d7 commit d20c22f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions LibreNMS/OS/FsSwitch.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,29 @@ public function discoverProcessors()
{
$processors = [];

// Get the number of CPUs
$num_cpus_data = snmpwalk_cache_oid($this->getDeviceArray(), 'ssCpuNumCpus', [], 'UCD-SNMP-MIB');
$num_cpus = isset($num_cpus_data[0]['ssCpuNumCpus']) ? $num_cpus_data[0]['ssCpuNumCpus'] : 1;

// Assuming a tick rate of 100 ticks per second
$ticks_per_second = 100;

// Tests OID from SWITCH MIB.
$processors_data = snmpwalk_cache_oid($this->getDeviceArray(), 'ssCpuIdle', [], 'SWITCH', 'fs');
$processors_data = snmpwalk_cache_oid($this->getDeviceArray(), 'ssCpuRawIdle', [], 'SWITCH', 'fs');

foreach ($processors_data as $index => $entry) {
// Calculate total ticks for all CPUs
$total_ticks = $num_cpus * $ticks_per_second;
$idle_percentage = ($entry['ssCpuRawIdle'] / $total_ticks) * 100;

$processors[] = Processor::discover(
'fs-SWITCHMIB',
$this->getDeviceId(),
'.1.3.6.1.4.1.27975.1.2.11.' . $index,
$index,
'CPU',
-1,
100 - $entry['ssCpuIdle']
100 - $idle_percentage
);
}

Expand Down

0 comments on commit d20c22f

Please sign in to comment.