'memTotalSwap.0', 'availswap' => 'memAvailSwap.0', 'totalreal' => 'memTotalReal.0', 'availreal' => 'memAvailReal.0', 'totalfree' => 'memTotalFree.0', 'shared' => 'memShared.0', 'buffered' => 'memBuffer.0', 'cached' => 'memCached.0']; $mem_array = []; //$snmpdata = snmpwalk_cache_oid($device, "mem", array(), "UCD-SNMP-MIB"); $snmpdata = snmp_get_multi_oid($device, $mem_oids, [], 'UCD-SNMP-MIB'); if (is_array($snmpdata[0])) { $snmpdata = $snmpdata[0]; foreach ($mem_oids as $ds => $oid) { $oid = str_replace('.0', '', $oid); // Fix for some systems (who report negative values) //memShared.0 = 28292 //memBuffer.0 = -3762592 //memCached.0 = 203892 $mem_array[$ds] = ($snmpdata[$oid] < 0) ? 0 : $snmpdata[$oid]; //$mem_array[$ds] = snmp_dewrap32bit($snmpdata[$oid]); //$$key = $snmpdata[$key]; //if (is_numeric($$key) && $$key < 0) { $$key = 0; } } print_debug_vars($mem_array); } // Check to see that the OIDs are actually populated before we make the rrd if (is_numeric($mem_array['totalreal']) && is_numeric($mem_array['availreal']) && is_numeric($mem_array['totalfree'])) { //rrdtool_create($device, $mem_rrd, $mem_rrd_create); //rrdtool_update($device, $mem_rrd, array($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached)); rrdtool_update_ng($device, 'ucd_memory', $mem_array); $graphs['ucd_memory'] = TRUE; $device_state['ucd_mem']['swap_total'] = $mem_array['totalswap']; //$memTotalSwap; $device_state['ucd_mem']['swap_avail'] = $mem_array['availswap']; //$memAvailSwap; $device_state['ucd_mem']['mem_total'] = $mem_array['totalreal']; //$memTotalReal; $device_state['ucd_mem']['mem_avail'] = $mem_array['availreal']; //$memAvailReal; $device_state['ucd_mem']['mem_shared'] = $mem_array['shared']; //$memShared; $device_state['ucd_mem']['mem_buffer'] = $mem_array['buffered']; //$memBuffer; $device_state['ucd_mem']['mem_cached'] = $mem_array['cached']; //$memCached; if (isset($attribs['ucd_memory_bad']) && $attribs['ucd_memory_bad']) { $device_state['ucd_mem']['mem_used'] = $mem_array['totalreal'] - $mem_array['availreal']; } else { $device_state['ucd_mem']['mem_used'] = $mem_array['totalreal'] - $mem_array['availreal'] - $mem_array['cached'] - $mem_array['buffered']; } } /* Moved to mib definition // 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 = snmpwalk_cache_oid($device, "laLoadInt", array(), "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'])) { rrdtool_create($device, $load_rrd, "DS:1min:GAUGE:600:0:500000 DS:5min:GAUGE:600:0:500000 DS:15min:GAUGE:600:0:500000 "); rrdtool_update($device, $load_rrd, array($load_raw[1]['laLoadInt'], $load_raw[2]['laLoadInt'], $load_raw[3]['laLoadInt'])); $graphs['ucd_load'] = TRUE; $device_state['ucd_load'] = $load_raw[2]['laLoadInt']; } */ } unset($ss, $load_rrd, $load_raw, $snmpdata); unset($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached); unset($key, $mem_rrd, $mem_rrd_create, $collect_oids, $value, $filename, $cpu_rrd, $cpu_rrd_create, $oid); // EOF