addDataset('user', 'COUNTER', 0) ->addDataset('system', 'COUNTER', 0) ->addDataset('nice', 'COUNTER', 0) ->addDataset('idle', 'COUNTER', 0); $fields = [ 'user' => $ss['ssCpuRawUser'], 'system' => $ss['ssCpuRawSystem'], 'nice' => $ss['ssCpuRawNice'], 'idle' => $ss['ssCpuRawIdle'], ]; $tags = compact('rrd_def'); data_update($device, 'ucd_cpu', $tags, $fields); $os->enableGraph('ucd_cpu'); } // This is how we'll collect in the future, start now so people don't have zero data. $collect_oids = [ 'ssCpuRawUser', 'ssCpuRawNice', 'ssCpuRawSystem', 'ssCpuRawIdle', 'ssCpuRawInterrupt', 'ssCpuRawSoftIRQ', 'ssCpuRawKernel', 'ssCpuRawWait', 'ssIORawSent', 'ssIORawReceived', 'ssRawInterrupts', 'ssRawContexts', 'ssRawSwapIn', 'ssRawSwapOut', 'ssCpuRawWait', 'ssCpuRawSteal', ]; foreach ($collect_oids as $oid) { if (is_numeric($ss[$oid] ?? null)) { $rrd_name = 'ucd_' . $oid; $rrd_def = RrdDefinition::make()->addDataset('value', 'COUNTER', 0); $fields = [ 'value' => $ss[$oid], ]; $tags = compact('oid', 'rrd_name', 'rrd_def'); data_update($device, 'ucd_cpu', $tags, $fields); $os->enableGraph('ucd_cpu'); } } // Set various graphs if we've seen the right OIDs. if (isset($ss['ssRawSwapIn']) && is_numeric($ss['ssRawSwapIn'])) { $os->enableGraph('ucd_swap_io'); } if (isset($ss['ssIORawSent']) && is_numeric($ss['ssIORawSent'])) { $os->enableGraph('ucd_io'); } if (isset($ss['ssRawContexts']) && is_numeric($ss['ssRawContexts'])) { $os->enableGraph('ucd_contexts'); } if (isset($ss['ssRawInterrupts']) && is_numeric($ss['ssRawInterrupts'])) { $os->enableGraph('ucd_interrupts'); } if (isset($ss['ssCpuRawWait']) && is_numeric($ss['ssCpuRawWait'])) { $os->enableGraph('ucd_io_wait'); } if (isset($ss['ssCpuRawSteal']) && is_numeric($ss['ssCpuRawSteal'])) { $os->enableGraph('ucd_cpu_steal'); } } // // Poll laLoadInt for load averages on UNIX-like hosts running UCD/Net-SNMPd // UCD-SNMP-MIB::laLoadInt.1 = INTEGER: 206 // UCD-SNMP-MIB::laLoadInt.2 = INTEGER: 429 // UCD-SNMP-MIB::laLoadInt.3 = INTEGER: 479 $load_raw = snmp_get_multi($device, ['laLoadInt.1', 'laLoadInt.2', 'laLoadInt.3'], '-OQUs', 'UCD-SNMP-MIB'); // Check to see that the 5-min OID is actually populated before we make the rrd if (is_numeric($load_raw[2]['laLoadInt'] ?? null)) { $rrd_def = RrdDefinition::make() ->addDataset('1min', 'GAUGE', 0) ->addDataset('5min', 'GAUGE', 0) ->addDataset('15min', 'GAUGE', 0); $fields = [ '1min' => $load_raw[1]['laLoadInt'], '5min' => $load_raw[2]['laLoadInt'], '15min' => $load_raw[3]['laLoadInt'], ]; $tags = compact('rrd_def'); data_update($device, 'ucd_load', $tags, $fields); $os->enableGraph('ucd_load'); } unset($ss, $load_raw, $snmpdata); unset($key, $collect_oids, $rrd_name, $rrd_def, $oid);