$entry) { if ($entry['pduDevMonInletBid'] == 0 && $entry['pduDevMonInletFwType'] == 0) { unset($oids[$index]); // Remove unused entries } } print_debug_vars($oids); $inlet_count = safe_count($oids); foreach ($oids as $index => $entry) { $name = $inlet_count > 1 ? " #$index" : ''; $phase_count = ($entry['pduDevMonInletVoltPh2'] > 0) || ($entry['pduDevMonInletVoltPh3'] > 0) ? 3 : 1; for ($phase = 1; $phase <= $phase_count; $phase++) { $phase_name = $phase_count > 1 ? " (Phase $phase)" : ''; $descr = "Inlet" . $name . $phase_name . ' B1'; $oid_name = 'pduDevMonInletCurrentPh' . $phase . 'B1'; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; $scale = 0.01; $options = [ 'limit_high' => $entry['pduDevMgmtInletOverCurrB1CritPh' . $phase] * $scale, 'limit_high_warn' => $entry['pduDevMgmtInletOverCurrB1WarnPh' . $phase] * $scale ]; discover_sensor_ng($device, 'current', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options); $descr = "Inlet" . $name . $phase_name . ' B2'; $oid_name = 'pduDevMonInletCurrentPh' . $phase . 'B2'; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; $scale = 0.01; $options = [ 'limit_high' => $entry['pduDevMgmtInletOverCurrB2CritPh' . $phase] * $scale, 'limit_high_warn' => $entry['pduDevMgmtInletOverCurrB2WarnPh' . $phase] * $scale ]; discover_sensor_ng($device, 'current', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options); $descr = "Inlet" . $name . $phase_name; $oid_name = 'pduDevMonInletVoltPh' . $phase; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; $scale = 0.1; $options = [ 'limit_high' => $entry['pduDevMgmtInletOverVoltCritPh' . $phase] * $scale, 'limit_high_warn' => $entry['pduDevMgmtInletOverVoltWarnPh' . $phase] * $scale ]; discover_sensor_ng($device, 'voltage', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options); $descr = "Inlet" . $name . $phase_name . ' B1'; $oid_name = 'pduDevMonInletPfPh' . $phase . 'B1'; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; $scale = 0.01; $options = [ 'limit_low' => $entry['pduDevMgmtInletOverPfB1CritPh' . $phase] * $scale, 'limit_low_warn' => $entry['pduDevMgmtInletOverPfB1WarnPh' . $phase] * $scale ]; discover_sensor_ng($device, 'powerfactor', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options); $descr = "Inlet" . $name . $phase_name . ' B2'; $oid_name = 'pduDevMonInletPfPh' . $phase . 'B2'; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; $scale = 0.01; $options = [ 'limit_low' => $entry['pduDevMgmtInletOverPfB2CritPh' . $phase] * $scale, 'limit_low_warn' => $entry['pduDevMgmtInletOverPfB2WarnPh' . $phase] * $scale ]; discover_sensor_ng($device, 'powerfactor', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options); $descr = "Inlet" . $name . $phase_name; $oid_name = 'pduDevMonInletActPowerPh' . $phase; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; $scale = 0.1; discover_sensor_ng($device, 'power', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value); $descr = "Inlet" . $name . $phase_name; $oid_name = 'pduDevMonInletAppPowerPh' . $phase; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; $scale = 0.1; discover_sensor_ng($device, 'apower', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value); $descr = "Inlet" . $name . $phase_name; $oid_name = 'pduDevMonInletEvtStatusPh' . $phase; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; discover_status_ng($device, $mib, $oid_name, $oid_num, $index, 'inletStatus', $descr, $value); $descr = "Inlet" . $name . $phase_name; $oid_name = 'pduDevMonInletEnergyPh' . $phase; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; $scale = 1000; discover_counter($device, 'energy', $mib, $oid_name, $oid_num, $index, $descr, $scale, $value); } } if ($outlet_count = snmp_get_oid($device, "pduDevMonOutletMasterPortSize.0", 'SPS2v1-MIB')) { $oids = snmpwalk_cache_oid($device, 'pduDevMonOutletMasterPortTable', [], 'SPS2v1-MIB'); $oids = snmpwalk_cache_oid($device, 'pduDevMgmtOutletMasterPortTable', $oids, 'SPS2v1-MIB'); foreach ($oids as $index => $entry) { // PDU reports all outlets as "normal" status, but really only as in count if ($index > $outlet_count) { break; } if ($entry['pduDevMgmtOutletMasterPortValid'] === 'offline') { continue; } $descr = "Outlet $index State"; $oid_name = "duDevMonOutletMasterPortRlyState"; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; discover_status_ng($device, $mib, $oid_name, $oid_num, $index, 'outletPduState', $descr, $value); if ($entry['pduDevMonOutletMasterPortRlyState'] === 'off') { continue; } $descr = "Outlet $index"; $oid_name = 'pduDevMonOutletMasterPortVolt'; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; $scale = 0.1; $options = [ 'measured_entity_label' => "Outlet $index", 'measured_class' => 'outlet' ]; discover_sensor_ng($device, 'voltage', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options); $descr = "Outlet $index"; $oid_name = 'pduDevMonOutletMasterPortCurrent'; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; $scale = 0.01; $options = [ 'limit_high' => $entry['pduDevMgmtOutletMasterPortOverCurrCrit'] * $scale, 'limit_high_warn' => $entry['pduDevMgmtOutletMasterPortOverCurrWarn'] * $scale, 'measured_entity_label' => "Outlet $index", 'measured_class' => 'outlet' ]; discover_sensor_ng($device, 'current', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options); $descr = "Outlet $index"; $oid_name = 'pduDevMonOutletMasterPortActPower'; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; $scale = 0.1; $options = [ 'limit_high' => $entry['pduDevMgmtOutletMasterPortOverPowerCrit'] * $scale, 'limit_high_warn' => $entry['pduDevMgmtOutletMasterPortOverPowerWarn'] * $scale, 'measured_entity_label' => "Outlet $index", 'measured_class' => 'outlet' ]; discover_sensor_ng($device, 'power', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options); $descr = "Outlet $index"; $oid_name = 'pduDevMonOutletMasterPortActPower'; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; $scale = 0.1; $options = [ 'measured_entity_label' => "Outlet $index", 'measured_class' => 'outlet' ]; discover_sensor_ng($device, 'apower', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options); $descr = "Outlet $index"; $oid_name = 'pduDevMonOutletMasterPortEnergy'; $oid_num = snmp_translate($oid_name, $mib) . ".$index"; $value = $entry[$oid_name]; $scale = 1000; $options = [ 'measured_entity_label' => "Outlet $index", 'measured_class' => 'outlet' ]; discover_counter($device, 'energy', $mib, $oid_name, $oid_num, $index, $descr, $scale, $value, $options); } } // EOF