commit version 22.12.12447

This commit is contained in:
2023-01-01 22:36:12 -05:00
parent af1b03d79f
commit b948283a96
744 changed files with 620715 additions and 27381 deletions

View File

@ -1,5 +1,4 @@
<?php
/**
* Observium
*
@ -7,7 +6,7 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -58,20 +57,20 @@ foreach (explode("\n", $oids) as $data)
for ($encNum = 1; $encNum <= 8; $encNum++) {
$table = "hwEnclosure$encNum";
$enclosures = snmpwalk_cache_oid($device, $table, [], "ARECA-SNMP-MIB");
if (!isset($enclosures[0]) || !$enclosures[0]["hwEnclosure0${encNum}Installed"]) {
if (!isset($enclosures[0]) || !$enclosures[0]["hwEnclosure0{$encNum}Installed"]) {
// Index 0 is the main enclosure data, we check if the enclosure is connected, but it will
// not have any sensors of its own, so we skip index 0.
continue;
}
$enclosure = $enclosures[0];
unset($enclosures[0]);
$name = $enclosure["hwEnclosure0${encNum}Description"];
$name = $enclosure["hwEnclosure0{$encNum}Description"];
foreach ($enclosures as $index => $entry) {
if ($entry["hwEnclosure0${encNum}VolIndex"]) {
$descr = $name . ' (' . $encNum . ') ' . $entry["hwEnclosure0${encNum}VolDesc"];
if ($entry["hwEnclosure0{$encNum}VolIndex"]) {
$descr = $name . ' (' . $encNum . ') ' . $entry["hwEnclosure0{$encNum}VolDesc"];
$oid_num = ".1.3.6.1.4.1.18928.1.2.2." . ($encNum+1) . ".8.1.3.$index";
$oid_name = "hwEnclosure0${encNum}VolValue";
$oid_name = "hwEnclosure0{$encNum}VolValue";
$value = $entry[$oid_name];
//discover_sensor('voltage', $device, $oid_num, "$oid_name.$index", 'areca', $descr, 0.001, $value);
@ -79,10 +78,10 @@ for ($encNum = 1; $encNum <= 8; $encNum++) {
discover_sensor_ng($device, 'voltage', $mib, $oid_name, $oid_num, $index, NULL, $descr, 0.001, $value, $options);
}
if ($entry["hwEnclosure0${encNum}FanIndex"]) {
$descr = $name . ' (' . $encNum . ') ' . $entry["hwEnclosure0${encNum}FanDesc"];
if ($entry["hwEnclosure0{$encNum}FanIndex"]) {
$descr = $name . ' (' . $encNum . ') ' . $entry["hwEnclosure0{$encNum}FanDesc"];
$oid_num = ".1.3.6.1.4.1.18928.1.2.2." . ($encNum+1) . ".9.1.3.$index";
$oid_name = "hwEnclosure0${encNum}FanSpeed";
$oid_name = "hwEnclosure0{$encNum}FanSpeed";
$value = $entry[$oid_name];
//discover_sensor('fanspeed', $device, $oid_num, "$oid_name.$index", 'areca', $descr, 1, $value);
@ -90,10 +89,10 @@ for ($encNum = 1; $encNum <= 8; $encNum++) {
discover_sensor_ng($device, 'fanspeed', $mib, $oid_name, $oid_num, $index, NULL, $descr, 1, $value, $options);
}
if ($entry["hwEnclosure0${encNum}TempIndex"]) {
$descr = $name . ' (' . $encNum . ') ' . $entry["hwEnclosure0${encNum}TempDesc"];
if ($entry["hwEnclosure0{$encNum}TempIndex"]) {
$descr = $name . ' (' . $encNum . ') ' . $entry["hwEnclosure0{$encNum}TempDesc"];
$oid_num = ".1.3.6.1.4.1.18928.1.2.2." . ($encNum+1) . ".10.1.3.$index";
$oid_name = "hwEnclosure0${encNum}TempValue";
$oid_name = "hwEnclosure0{$encNum}TempValue";
$value = $entry[$oid_name];
//discover_sensor('temperature', $device, $oid_num, "$oid_name.$index", 'areca', $descr, 1, $value);
@ -101,13 +100,13 @@ for ($encNum = 1; $encNum <= 8; $encNum++) {
discover_sensor_ng($device, 'temperature', $mib, $oid_name, $oid_num, $index, NULL, $descr, 1, $value, $options);
}
if ($entry["hwEnclosure0${encNum}PowerIndex"]) {
$descr = $name . ' (' . $encNum . ') ' . $entry["hwEnclosure0${encNum}PowerDesc"];
if ($entry["hwEnclosure0{$encNum}PowerIndex"]) {
$descr = $name . ' (' . $encNum . ') ' . $entry["hwEnclosure0{$encNum}PowerDesc"];
$oid_num = ".1.3.6.1.4.1.18928.1.2.2." . ($encNum+1) . ".7.1.3.$index";
$oid_name = "hwEnclosure0${encNum}PowerState";
$oid_name = "hwEnclosure0{$encNum}PowerState";
$value = $entry[$oid_name];
//discover_status($device, $oid, "hwEnclosure0${encNum}PowerState.$index", 'areca-power-state', $descr, $value, array('entPhysicalClass' => 'power'));
//discover_status($device, $oid, "hwEnclosure0{$encNum}PowerState.$index", 'areca-power-state', $descr, $value, array('entPhysicalClass' => 'power'));
discover_status_ng($device, $mib, $oid_name, $oid_num, $index, 'areca-power-state', $descr, $value, [ 'entPhysicalClass' => 'power' ]);
}
}
@ -118,21 +117,21 @@ for ($encNum = 1; $encNum <= 8; $encNum++) {
for ($encNum = 1; $encNum <= 8; $encNum++) {
$table = "hddEnclosure$encNum";
$enclosures = snmpwalk_cache_oid($device, $table, [], "ARECA-SNMP-MIB");
if (!isset($enclosures[0]) || !$enclosures[0]["hddEnclosure0${encNum}Installed"]) {
if (!isset($enclosures[0]) || !$enclosures[0]["hddEnclosure0{$encNum}Installed"]) {
// Index 0 is the main enclosure data, we check if the enclosure is connected, but it will
// not have any sensors of its own, so we skip index 0.
continue;
}
$enclosure = $enclosures[0];
unset($enclosures[0]);
$name = $enclosure["hddEnclosure0${encNum}Description"];
$name = $enclosure["hddEnclosure0{$encNum}Description"];
foreach ($enclosures as $index => $entry) {
if ($entry["hddEnclosure0${encNum}Name"] === 'N.A.') { continue; }
if ($entry["hddEnclosure0{$encNum}Name"] === 'N.A.') { continue; }
$descr = 'Slot ' . $entry["hddEnclosure0${encNum}Slots"] . ', ' . trim($entry["hddEnclosure0${encNum}Name"]) . ' (SN: ' . trim($entry["hddEnclosure0${encNum}Serial"]) . ", $name)";
$descr = 'Slot ' . $entry["hddEnclosure0{$encNum}Slots"] . ', ' . trim($entry["hddEnclosure0{$encNum}Name"]) . ' (SN: ' . trim($entry["hddEnclosure0{$encNum}Serial"]) . ", $name)";
$oid_num = ".1.3.6.1.4.1.18928.1.2.3." . $encNum . ".4.1.8.$index";
$oid_name = "hddEnclosure0${encNum}State";
$oid_name = "hddEnclosure0{$encNum}State";
$value = $entry[$oid_name];
discover_status_ng($device, $mib, $oid_name, $oid_num, $index, 'areca-hdd-state', $descr, $value, [ 'entPhysicalClass' => 'storage' ]);

View File

@ -1,5 +1,4 @@
<?php
/**
* Observium
*
@ -7,7 +6,7 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -15,25 +14,19 @@
//AXIS-VIDEO-MIB::tempSensorStatus.common.2 = INTEGER: ok(1)
//AXIS-VIDEO-MIB::tempSensorValue.common.1 = INTEGER: 26
//AXIS-VIDEO-MIB::tempSensorValue.common.2 = INTEGER: 32
//AXIS-VIDEO-MIB::storageName.1 = STRING: SD_DISK
//AXIS-VIDEO-MIB::storageName.2 = STRING: NetworkShare
//AXIS-VIDEO-MIB::storageDisruptionDetected.1 = INTEGER: no(1)
//AXIS-VIDEO-MIB::storageDisruptionDetected.2 = INTEGER: yes(2)
$mib = 'AXIS-VIDEO-MIB';
// Temperature Sensor
$oids = snmpwalk_cache_oid($device, 'tempSensorEntry', array(), $mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
$oids = snmpwalk_cache_oid($device, 'tempSensorEntry', [], $mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
print_debug_vars($oids);
foreach ($oids as $index => $entry)
{
foreach ($oids as $index => $entry) {
//if ($entry['tempSensorStatus'] == 'failure') { continue; } // ok(1), failure(2), outOfBoundary(3)
// common(1), housing(2), rack(3), cpu(4)
list($tempSensorType, $tempSensorId) = explode('.', $index);
switch ($tempSensorType)
{
switch ($tempSensorType) {
case '1':
$descr = 'System temperature';
break;
@ -49,8 +42,7 @@ foreach ($oids as $index => $entry)
default:
$descr = 'Temperature';
}
if (count($oids) > 1)
{
if (count($oids) > 1) {
$descr .= ' ' . $tempSensorId;
}
@ -69,19 +61,17 @@ foreach ($oids as $index => $entry)
$type = 'axisStatus';
$value = $entry[$oid_name];
discover_status_ng($device, $mib, $oid_name, $oid_num, $index, $type, $descr, $value, array('entPhysicalClass' => 'other'));
discover_status_ng($device, $mib, $oid_name, $oid_num, $index, $type, $descr, $value, [ 'entPhysicalClass' => 'other' ]);
}
// Fan Sensor
$oids = snmpwalk_cache_oid($device, 'fanEntry', array(), $mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
$oids = snmpwalk_cache_oid($device, 'fanEntry', [], $mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
print_debug_vars($oids);
foreach ($oids as $index => $entry)
{
foreach ($oids as $index => $entry) {
// common(1), housing(2), rack(3), cpu(4)
list($SensorType, $SensorId) = explode('.', $index);
switch ($SensorType)
{
switch ($SensorType) {
case '1':
$descr = 'System fan';
break;
@ -97,8 +87,7 @@ foreach ($oids as $index => $entry)
default:
$descr = 'Fan';
}
if (count($oids) > 1)
{
if (count($oids) > 1) {
$descr .= ' ' . $SensorId;
}
@ -107,7 +96,7 @@ foreach ($oids as $index => $entry)
$type = 'axisStatus';
$value = $entry[$oid_name];
discover_status_ng($device, $mib, $oid_name, $oid_num, $index, $type, $descr, $value, array('entPhysicalClass' => 'fan'));
discover_status_ng($device, $mib, $oid_name, $oid_num, $index, $type, $descr, $value, [ 'entPhysicalClass' => 'fan' ]);
}
// EOF

View File

@ -6,20 +6,16 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
$entity_array = snmpwalk_cache_oid($device, 'entSensorValueEntry', $entity_array, 'CISCO-ENTITY-SENSOR-MIB');
if ($GLOBALS['snmp_status'])
{
if (is_array($GLOBALS['cache']['snmp']['ENTITY-MIB'][$device['device_id']]))
{
if (snmp_status()) {
if (is_array($GLOBALS['cache']['snmp']['ENTITY-MIB'][$device['device_id']])) {
// If this already received in inventory module, skip walking
foreach ($GLOBALS['cache']['snmp']['ENTITY-MIB'][$device['device_id']] as $index => $entry)
{
if (isset($entity_array[$index]))
{
foreach ($GLOBALS['cache']['snmp']['ENTITY-MIB'][$device['device_id']] as $index => $entry) {
if (isset($entity_array[$index])) {
$entity_array[$index] = array_merge($entity_array[$index], $entry);
} else {
$entity_array[$index] = $entry;
@ -54,10 +50,9 @@ if ($GLOBALS['snmp_status'])
}
}
$t_oids = array('entSensorThresholdSeverity', 'entSensorThresholdRelation', 'entSensorThresholdValue');
$t_entity_array = array();
foreach ($t_oids as $oid)
{
$t_oids = [ 'entSensorThresholdSeverity', 'entSensorThresholdRelation', 'entSensorThresholdValue' ];
$t_entity_array = [];
foreach ($t_oids as $oid) {
$t_entity_array = snmpwalk_cache_twopart_oid($device, $oid, $t_entity_array, 'CISCO-ENTITY-SENSOR-MIB');
}
@ -79,7 +74,7 @@ if ($GLOBALS['snmp_status'])
dBm(14): dB relative to 1mW of power
*/
$c_entitysensor = array(
$c_entitysensor = [
'voltsAC' => 'voltage',
'voltsDC' => 'voltage',
'amperes' => 'current',
@ -92,14 +87,14 @@ if ($GLOBALS['snmp_status'])
'truthvalue' => 'state',
//'specialEnum' => 'gauge', // This sensors seems as useless
'dBm' => 'dbm'
);
];
$i = [];
foreach ($entity_array as $index => $entry) {
if (is_numeric($index) && isset($c_entitysensor[$entry['entSensorType']]) &&
is_numeric($entry['entSensorValue']) && $entry['entSensorStatus'] === 'ok') {
$ok = TRUE;
$options = array('entPhysicalIndex' => $index);
$options = [ 'entPhysicalIndex' => $index ];
$descr = rewrite_entity_name($entry['entPhysicalDescr']);
if ($device['os'] === 'cisco-firepower') {
@ -174,7 +169,7 @@ if ($GLOBALS['snmp_status'])
print_debug_vars($entry);
// Now try to search port bounded with sensor by ENTITY-MIB
if ($ok && in_array($type, array('temperature', 'voltage', 'current', 'dbm', 'power'))) {
if ($ok && in_array($type, [ 'temperature', 'voltage', 'current', 'dbm', 'power' ])) {
$port = get_port_by_ent_index($device, $index);
$options['entPhysicalIndex'] = $index;
if (is_array($port)) {
@ -209,17 +204,22 @@ if ($GLOBALS['snmp_status'])
}
// Set thresholds for numeric sensors
$limits = array();
$limits = [];
$scale = NULL;
if ($c_entitysensor[$entry['entSensorType']] !== 'state') {
$precision = $entry['entSensorPrecision'];
// See: https://jira.observium.org/browse/OBS-3026
// Note, issue not actual on firmware less than 16.11, not sure if fixed on more newer firmwares
// Seems as not actual on 16.12.x, see: https://jira.observium.org/browse/OBS-3707
if ($device['os'] === 'iosxe' && $precision > 0 &&
version_compare($device['version'], '16.11', '>=') && version_compare($device['version'], '16.12', '<')) {
// See: https://jira.observium.org/browse/OBS-3026
// Note, issue not actual on firmware less than 16.11, not sure if fixed on newer firmwares
// Seems as not actual on 16.12.x, see: https://jira.observium.org/browse/OBS-3707
// I not sure that this fully correct, but for issue case - works
$precision -= 1;
} elseif ($device['os'] === 'iosxr' && $precision > 0 && $type === 'power' &&
$device['version'] === '6.4.2' && preg_match('/ASR\-90\d{2}/', $device['hardware'])) {
// See: https://jira.observium.org/browse/OBS-4079
// ASR9k 32bit platform issue for power sensor
$precision -= 1;
}
$scale = si_to_scale($entry['entSensorScale'], $precision);

View File

@ -1,5 +1,4 @@
<?php
/**
* Observium
*
@ -7,17 +6,16 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2014 Adam Armstrong
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
$hpups_array = array();
$hpups_array = [];
$hpups_array = snmpwalk_cache_oid($device, 'upsInput', $hpups_array, 'CPQPOWER-MIB');
$hpups_array = snmpwalk_cache_oid($device, 'upsOutput', $hpups_array, 'CPQPOWER-MIB');
$hpups_array = snmpwalk_cache_oid($device, 'upsBypass', $hpups_array, 'CPQPOWER-MIB');
foreach (array_slice(array_keys($hpups_array),1) as $phase)
{
foreach (array_slice(array_keys($hpups_array),1) as $phase) {
# Skip garbage output:
# upsOutput.6.0 = 0
# upsOutput.7.0 = 0
@ -39,8 +37,7 @@ foreach (array_slice(array_keys($hpups_array),1) as $phase)
$oid = ".1.3.6.1.4.1.232.165.3.3.4.1.3.$index"; # CPQPOWER-MIB:upsInputCurrent.$index
$value = $hpups_array[$phase]['upsInputCurrent'];
if ($value < 10000) # upsInputCurrent.1 = 136137420 ? really? You're nuts.
{
if ($value < 10000) { # upsInputCurrent.1 = 136137420 ? really? You're nuts.
$options = [ 'rename_rrd' => "CPQPOWER-MIB-upsInputEntry.$index" ];
discover_sensor_ng($device, 'current', $mib, 'upsInputCurrent', $oid, $index, NULL, $descr, 1, $value, $options);
}
@ -132,29 +129,26 @@ unset($hpups_array);
//CPQPOWER-MIB::pduOutputPower.2 = INTEGER: 671
//CPQPOWER-MIB::pduOutputNumBreakers.1 = INTEGER: 3
//CPQPOWER-MIB::pduOutputNumBreakers.2 = INTEGER: 3
$hppdu_array = snmpwalk_cache_oid($device, 'pduIdentTable', array(), 'CPQPOWER-MIB');
$hppdu_array = snmpwalk_cache_oid($device, 'pduIdentTable', [], 'CPQPOWER-MIB');
$hppdu_array = snmpwalk_cache_oid($device, 'pduOutputTable', $hppdu_array, 'CPQPOWER-MIB');
foreach ($hppdu_array as $index => $entry)
{
foreach ($hppdu_array as $index => $entry) {
// Monitor PDU Status
$oid = ".1.3.6.1.4.1.232.165.2.1.2.1.8.$index";
$descr = $entry['pduName'].' Status';
if (!empty($entry['pduStatus']))
{
if (!empty($entry['pduStatus'])) {
discover_status_ng($device, $mib, 'pduStatus', $oid, $index, 'cpqpower-pdu-status', $descr, $entry['pduStatus'], array('entPhysicalClass' => 'power', 'rename_rrd' => 'cpqpower-pdu-status-%index%'));
}
// Monitor PDU Output load
$oid = ".1.3.6.1.4.1.232.165.2.3.1.1.2.$index";
$descr = $entry['pduName'].' Load';
$limits = array();
if (!empty($entry['pduOutputLoad']) && $entry['pduOutputLoad'] != '-1')
{
$limits = [];
if (!empty($entry['pduOutputLoad']) && $entry['pduOutputLoad'] != '-1') {
$options = [ 'rename_rrd' => "CPQPOWER-MIB-%index%" ];
discover_sensor_ng($device, 'capacity', $mib, 'pduOutputLoad', $oid, $index, NULL, $descr, 1, $entry['pduOutputLoad'], $options);
// Find power limit by measure the reported output power divided by the reported load of the PDU
$pdu_maxload = 100 * ($entry['pduOutputPower'] / $entry['pduOutputLoad']);
$pdu_maxload = 100 * float_div($entry['pduOutputPower'], $entry['pduOutputLoad']);
$pdu_warnload = 0.8 * $pdu_maxload;
$limits = array('limit_high' => round($pdu_maxload, 2),
'limit_high_warn' => round($pdu_warnload, 2));
@ -164,8 +158,7 @@ foreach ($hppdu_array as $index => $entry)
$oid = ".1.3.6.1.4.1.232.165.2.3.1.1.4.$index";
$descr = $entry['pduName'].' Output Power';
if (!empty($entry['pduOutputPower']) && $entry['pduOutputPower'] != '-1')
{
if (!empty($entry['pduOutputPower']) && $entry['pduOutputPower'] != '-1') {
$options = $limits;
$options['rename_rrd'] = "CPQPOWER-MIB-%index%";
discover_sensor_ng($device, 'power', $mib, 'pduOutputPower', $oid, $index, NULL, $descr, 1, $entry['pduOutputPower'], $options);
@ -182,9 +175,8 @@ foreach ($hppdu_array as $index => $entry)
//CPQPOWER-MIB::breakerPercentLoad.2.6 = INTEGER: 0
//CPQPOWER-MIB::breakerStatus.1.1 = INTEGER: 0
//CPQPOWER-MIB::breakerStatus.2.6 = INTEGER: 0
$hppdu_breaker_array = snmpwalk_cache_oid($device, 'pduOutputBreakerTable', array(), 'CPQPOWER-MIB');
foreach ($hppdu_breaker_array as $index => $entry)
{
$hppdu_breaker_array = snmpwalk_cache_oid($device, 'pduOutputBreakerTable', [], 'CPQPOWER-MIB');
foreach ($hppdu_breaker_array as $index => $entry) {
if ($entry['breakerVoltage'] <= 0) { continue; }
list($breaker_output, $breaker_unit) = explode('.', $index, 2);
@ -192,7 +184,7 @@ foreach ($hppdu_breaker_array as $index => $entry)
// Find powerlimit by measure the reported output power devivded by the reported load of the PDU
//$breaker_maxload = 100 * ($entry['breakerCurrent'] / $entry['breakerPercentLoad']);
$breaker_maxload = $entry['breakerCurrent'] / $entry['breakerPercentLoad']; // breakerCurrent already scaled by 100
$breaker_maxload = float_div($entry['breakerCurrent'], $entry['breakerPercentLoad']); // breakerCurrent already scaled by 100
$breaker_warnload = 0.8 * $breaker_maxload;
$limits = array('limit_high' => round($breaker_maxload, 2),
'limit_high_warn' => round($breaker_warnload, 2));

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -113,12 +113,18 @@ foreach ($oids as $index => $entry) {
$oid_num = '.1.3.6.1.4.1.171.12.72.2.1.1.1.2.'.$index;
$scale = 1;
$value = $entry[$oid_name];
$limits = [
'limit_high' => $oids_limit[$index]['temperature']['swDdmHighAlarm'],
'limit_low' => $oids_limit[$index]['temperature']['swDdmLowAlarm'],
'limit_high_warn' => $oids_limit[$index]['temperature']['swDdmHighWarning'],
'limit_low_warn' => $oids_limit[$index]['temperature']['swDdmLowWarning']
];
$limits = [];
$limit_type = 'temperature';
$limits_oids = [ 'limit_high' => 'swDdmHighAlarm', 'limit_high_warn' => 'swDdmHighWarning',
'limit_low' => 'swDdmLowAlarm', 'limit_low_warn' => 'swDdmLowWarning' ];
foreach ($limits_oids as $limit => $limit_oid) {
// Prevent php8 fatal errors
if (!is_numeric($oids_limit[$index][$limit_type][$limit_oid])) { continue; }
$limits[$limit] = $oids_limit[$index][$limit_type][$limit_oid] * $scale;
}
discover_sensor_ng($device, $class, $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, array_merge($options, $limits));
// Voltage
@ -128,12 +134,18 @@ foreach ($oids as $index => $entry) {
$oid_num = '.1.3.6.1.4.1.171.12.72.2.1.1.1.3.'.$index;
$scale = 1;
$value = $entry[$oid_name];
$limits = [
'limit_high' => $oids_limit[$index]['voltage']['swDdmHighAlarm'],
'limit_low' => $oids_limit[$index]['voltage']['swDdmLowAlarm'],
'limit_high_warn' => $oids_limit[$index]['voltage']['swDdmHighWarning'],
'limit_low_warn' => $oids_limit[$index]['voltage']['swDdmLowWarning']
];
$limits = [];
$limit_type = 'voltage';
$limits_oids = [ 'limit_high' => 'swDdmHighAlarm', 'limit_high_warn' => 'swDdmHighWarning',
'limit_low' => 'swDdmLowAlarm', 'limit_low_warn' => 'swDdmLowWarning' ];
foreach ($limits_oids as $limit => $limit_oid) {
// Prevent php8 fatal errors
if (!is_numeric($oids_limit[$index][$limit_type][$limit_oid])) { continue; }
$limits[$limit] = $oids_limit[$index][$limit_type][$limit_oid] * $scale;
}
discover_sensor_ng($device, $class, $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, array_merge($options, $limits));
// Tx Bias
@ -143,12 +155,18 @@ foreach ($oids as $index => $entry) {
$oid_num = '.1.3.6.1.4.1.171.12.72.2.1.1.1.4.'.$index;
$scale = 0.001;
$value = $entry[$oid_name];
$limits = [
'limit_high' => $oids_limit[$index]['bias']['swDdmHighAlarm'] * $scale,
'limit_low' => $oids_limit[$index]['bias']['swDdmLowAlarm'] * $scale,
'limit_high_warn' => $oids_limit[$index]['bias']['swDdmHighWarning'] * $scale,
'limit_low_warn' => $oids_limit[$index]['bias']['swDdmLowWarning'] * $scale
];
$limits = [];
$limit_type = 'bias';
$limits_oids = [ 'limit_high' => 'swDdmHighAlarm', 'limit_high_warn' => 'swDdmHighWarning',
'limit_low' => 'swDdmLowAlarm', 'limit_low_warn' => 'swDdmLowWarning' ];
foreach ($limits_oids as $limit => $limit_oid) {
// Prevent php8 fatal errors
if (!is_numeric($oids_limit[$index][$limit_type][$limit_oid])) { continue; }
$limits[$limit] = $oids_limit[$index][$limit_type][$limit_oid] * $scale;
}
discover_sensor_ng($device, $class, $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, array_merge($options, $limits));
// Tx Power
@ -158,12 +176,18 @@ foreach ($oids as $index => $entry) {
$oid_num = '.1.3.6.1.4.1.171.12.72.2.1.1.1.5.'.$index;
$scale = $power_unit === 'mw' ? 0.001 : 1;
$value = $entry[$oid_name];
$limits = [
'limit_high' => $oids_limit[$index]['txPower']['swDdmHighAlarm'] * $scale,
'limit_low' => $oids_limit[$index]['txPower']['swDdmLowAlarm'] * $scale,
'limit_high_warn' => $oids_limit[$index]['txPower']['swDdmHighWarning'] * $scale,
'limit_low_warn' => $oids_limit[$index]['txPower']['swDdmLowWarning'] * $scale
];
$limits = [];
$limit_type = 'txPower';
$limits_oids = [ 'limit_high' => 'swDdmHighAlarm', 'limit_high_warn' => 'swDdmHighWarning',
'limit_low' => 'swDdmLowAlarm', 'limit_low_warn' => 'swDdmLowWarning' ];
foreach ($limits_oids as $limit => $limit_oid) {
// Prevent php8 fatal errors
if (!is_numeric($oids_limit[$index][$limit_type][$limit_oid])) { continue; }
$limits[$limit] = $oids_limit[$index][$limit_type][$limit_oid] * $scale;
}
discover_sensor_ng($device, $class, $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, array_merge($options, $limits));
// Rx Power
@ -173,12 +197,18 @@ foreach ($oids as $index => $entry) {
$oid_num = '.1.3.6.1.4.1.171.12.72.2.1.1.1.6.'.$index;
$scale = $power_unit === 'mw' ? 0.001 : 1;
$value = $entry[$oid_name];
$limits = [
'limit_high' => $oids_limit[$index]['rxPower']['swDdmHighAlarm'] * $scale,
'limit_low' => $oids_limit[$index]['rxPower']['swDdmLowAlarm'] * $scale,
'limit_high_warn' => $oids_limit[$index]['rxPower']['swDdmHighWarning'] * $scale,
'limit_low_warn' => $oids_limit[$index]['rxPower']['swDdmLowWarning'] * $scale
];
$limits = [];
$limit_type = 'rxPower';
$limits_oids = [ 'limit_high' => 'swDdmHighAlarm', 'limit_high_warn' => 'swDdmHighWarning',
'limit_low' => 'swDdmLowAlarm', 'limit_low_warn' => 'swDdmLowWarning' ];
foreach ($limits_oids as $limit => $limit_oid) {
// Prevent php8 fatal errors
if (!is_numeric($oids_limit[$index][$limit_type][$limit_oid])) { continue; }
$limits[$limit] = $oids_limit[$index][$limit_type][$limit_oid] * $scale;
}
discover_sensor_ng($device, $class, $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, array_merge($options, $limits));
}

View File

@ -99,6 +99,7 @@ foreach ($cache_discovery['DKSF-48-4-X-X-1']['temphum'] as $index => $entry)
}
}
/* Moved to DEF
$cache_discovery['DKSF-48-4-X-X-1']['thermo'] = snmpwalk_cache_oid($device, 'npThermoTable', array(), 'DKSF-48-4-X-X-1');
foreach ($cache_discovery['DKSF-48-4-X-X-1']['thermo'] as $index => $entry)
{
@ -113,6 +114,7 @@ foreach ($cache_discovery['DKSF-48-4-X-X-1']['thermo'] as $index => $entry)
discover_sensor('temperature', $device, $oid, "npThermoValue.$index", 'dskf-mib', $descr, 1, $value, $limits);
}
}
*/
$cache_discovery['DKSF-48-4-X-X-1']['io'] = snmpwalk_cache_oid($device, 'npIoTable', array(), 'DKSF-48-4-X-X-1');
foreach ($cache_discovery['DKSF-48-4-X-X-1']['io'] as $index => $entry)

View File

@ -73,6 +73,7 @@ foreach ($cache_discovery['DKSF-50-11-X-X-X']['loop'] as $index => $entry)
}
}
/* Moved to DEF
$cache_discovery['DKSF-50-11-X-X-X']['temphum'] = snmpwalk_cache_oid($device, 'npRelHumTable', array(), 'DKSF-50-11-X-X-X');
foreach ($cache_discovery['DKSF-50-11-X-X-X']['temphum'] as $index => $entry)
{
@ -113,6 +114,7 @@ foreach ($cache_discovery['DKSF-50-11-X-X-X']['thermo'] as $index => $entry)
discover_sensor('temperature', $device, $oid, "npThermoValue.$index", 'dskf-mib', $descr, 1, $value, $limits);
}
}
*/
$cache_discovery['DKSF-50-11-X-X-X']['io'] = snmpwalk_cache_oid($device, 'npIoTable', array(), 'DKSF-50-11-X-X-X');
foreach ($cache_discovery['DKSF-50-11-X-X-X']['io'] as $index => $entry)

View File

@ -110,6 +110,7 @@ foreach ($cache_discovery['DKSF-60-4-X-X-X']['temphum'] as $index => $entry)
}
}
/* Moved to DEF
$cache_discovery['DKSF-60-4-X-X-X']['thermo'] = snmpwalk_cache_oid($device, 'npThermoTable', array(), 'DKSF-60-4-X-X-X');
foreach ($cache_discovery['DKSF-60-4-X-X-X']['thermo'] as $index => $entry)
{
@ -124,6 +125,7 @@ foreach ($cache_discovery['DKSF-60-4-X-X-X']['thermo'] as $index => $entry)
discover_sensor('temperature', $device, $oid, "npThermoValue.$index", 'dskf-mib', $descr, 1, $value, $limits);
}
}
*/
$cache_discovery['DKSF-60-4-X-X-X']['io'] = snmpwalk_cache_oid($device, 'npIoTable', array(), 'DKSF-60-4-X-X-X');
foreach ($cache_discovery['DKSF-60-4-X-X-X']['io'] as $index => $entry)

View File

@ -1,5 +1,4 @@
<?php
/**
* Observium
*
@ -7,14 +6,15 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// FIXME migrate to definitions
$cache_discovery['DKSF-70-5-X-X-1']['smoke'] = snmpwalk_cache_oid($device, 'npSmokeTable', array(), 'DKSF-70-5-X-X-1');
foreach ($cache_discovery['DKSF-70-5-X-X-1']['smoke'] as $index => $entry)
/* It's broken and renamed, need device access
$cache_discovery['DKSF-70-MIB']['smoke'] = snmpwalk_cache_oid($device, 'npSmokeTable', array(), 'DKSF-70-MIB');
foreach ($cache_discovery['DKSF-70-MIB']['smoke'] as $index => $entry)
{
if ($entry['npSmokePower'] == 'off') { continue; }
@ -27,9 +27,10 @@ foreach ($cache_discovery['DKSF-70-5-X-X-1']['smoke'] as $index => $entry)
discover_status($device, $oid, 'npSmokeStatus.'.$index, 'dskf-mib-smoke-state', $descr, $value, array('entPhysicalClass' => 'other'));
}
}
*/
$cache_discovery['DKSF-70-5-X-X-1']['loop'] = snmpwalk_cache_oid($device, 'npCurLoopTable', array(), 'DKSF-70-5-X-X-1');
foreach ($cache_discovery['DKSF-70-5-X-X-1']['loop'] as $index => $entry)
$cache_discovery['DKSF-70-MIB']['loop'] = snmpwalk_cache_oid($device, 'npCurLoopTable', array(), 'DKSF-70-MIB');
foreach ($cache_discovery['DKSF-70-MIB']['loop'] as $index => $entry)
{
if ($entry['npCurLoopPower'] == 'off' || $entry['npCurLoopStatus'] == 'notPowered') { continue; }
@ -72,8 +73,9 @@ foreach ($cache_discovery['DKSF-70-5-X-X-1']['loop'] as $index => $entry)
}
}
$cache_discovery['DKSF-70-5-X-X-1']['temphum'] = snmpwalk_cache_oid($device, 'npRelHumTable', array(), 'DKSF-70-5-X-X-1');
foreach ($cache_discovery['DKSF-70-5-X-X-1']['temphum'] as $index => $entry)
/* Moved to DEF
$cache_discovery['DKSF-70-MIB']['temphum'] = snmpwalk_cache_oid($device, 'npRelHumTable', array(), 'DKSF-70-MIB');
foreach ($cache_discovery['DKSF-70-MIB']['temphum'] as $index => $entry)
{
// Temperature
$descr = ($entry['npRelHumMemo'] ? $entry['npRelHumMemo'] : 'Temperature '.$index);
@ -98,8 +100,8 @@ foreach ($cache_discovery['DKSF-70-5-X-X-1']['temphum'] as $index => $entry)
}
}
$cache_discovery['DKSF-70-5-X-X-1']['thermo'] = snmpwalk_cache_oid($device, 'npThermoTable', array(), 'DKSF-70-5-X-X-1');
foreach ($cache_discovery['DKSF-70-5-X-X-1']['thermo'] as $index => $entry)
$cache_discovery['DKSF-70-MIB']['thermo'] = snmpwalk_cache_oid($device, 'npThermoTable', array(), 'DKSF-70-MIB');
foreach ($cache_discovery['DKSF-70-MIB']['thermo'] as $index => $entry)
{
// Temperature
$descr = ($entry['npThermoMemo'] ? $entry['npThermoMemo'] : 'Thermo '.$index);
@ -112,9 +114,10 @@ foreach ($cache_discovery['DKSF-70-5-X-X-1']['thermo'] as $index => $entry)
discover_sensor('temperature', $device, $oid, "npThermoValue.$index", 'dskf-mib', $descr, 1, $value, $limits);
}
}
*/
$cache_discovery['DKSF-70-5-X-X-1']['io'] = snmpwalk_cache_oid($device, 'npIoTable', array(), 'DKSF-70-5-X-X-1');
foreach ($cache_discovery['DKSF-70-5-X-X-1']['io'] as $index => $entry)
$cache_discovery['DKSF-70-MIB']['io'] = snmpwalk_cache_oid($device, 'npIoTable', array(), 'DKSF-70-MIB');
foreach ($cache_discovery['DKSF-70-MIB']['io'] as $index => $entry)
{
if ($entry['npIoLevelIn'] == '0') { continue; }
@ -127,8 +130,8 @@ foreach ($cache_discovery['DKSF-70-5-X-X-1']['io'] as $index => $entry)
discover_counter($device, 'counter', $mib, $oid_name, $oid, $index, $descr, 1, $value);
}
print_debug_vars($cache_discovery['DKSF-70-5-X-X-1']);
print_debug_vars($cache_discovery['DKSF-70-MIB']);
unset($cache_discovery['DKSF-70-5-X-X-1']);
unset($cache_discovery['DKSF-70-MIB']);
// EOF

View File

@ -1,5 +1,4 @@
<?php
/**
* Observium
*
@ -7,7 +6,7 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -156,32 +155,39 @@ $outlets = snmpwalk_cache_twopart_oid($device, 'outletCurrentTable', $outle
// Power statistics currently not collected.
//$outlets = snmpwalk_cache_twopart_oid($device, 'outletCurrentTable', $outlets, 'EATON-EPDU-MIB');
foreach ($outlets AS $unit_id => $unit_data)
{
foreach ($unit_data AS $outlet_id => $outlet)
{
foreach ($outlets as $unit_id => $unit_data) {
foreach ($unit_data as $outlet_id => $entry) {
$outlet_index = $unit_id.".".$outlet_id;
$outlet_descr = "Unit $unit_id ".$outlet['outletName'] . " (".$outlet['outletType'].")";
$outlet_capacity = $outlet['outletCurrentCapacity'] * 0.001;
$outlet_descr = "Unit $unit_id ".$entry['outletName'] . " (".$entry['outletType'].")";
$outlet_capacity = $entry['outletCurrentCapacity'] * 0.001;
$current_value = $outlet['outletCurrent'];
$percent_value = $outlet['outletCurrentPercentLoad'];
$status_value = $outlet['outletCurrentThStatus'];
$crest_value = $outlet['outletCurrentCrestFactor'];
$current_value = $entry['outletCurrent'];
$percent_value = $entry['outletCurrentPercentLoad'];
$status_value = $entry['outletCurrentThStatus'];
$crest_value = $entry['outletCurrentCrestFactor'];
$current_oid = '.1.3.6.1.4.1.534.6.6.7.6.4.1.3.'.$outlet_index;
$percent_oid = '.1.3.6.1.4.1.534.6.6.7.6.4.1.10.'.$outlet_index;
$status_oid = '.1.3.6.1.4.1.534.6.6.7.6.4.1.4.'.$outlet_index;
$crest_oid = '.1.3.6.1.4.1.534.6.6.7.6.4.1.9.'.$outlet_index;
$crest_oid = '.1.3.6.1.4.1.534.6.6.7.6.4.1.9.'.$outlet_index;
discover_status($device, $status_oid, "outletCurrentThStatus.".$outlet_index, 'outletCurrentThStatus', $outlet_descr, $status_value, array('entPhysicalClass' => 'outlet'));
discover_status($device, $status_oid, "outletCurrentThStatus.".$outlet_index, 'outletCurrentThStatus', $outlet_descr, $status_value, [ 'entPhysicalClass' => 'outlet' ]);
$limits = array('limit_low' => $entry['outletCurrentThLowerCritical']*0.001, 'limit_low_warn' => $entry['outletCurrentThLowerWarning']*0.001,
'limit_high' => $entry['outletCurrentThUpperCritical']*0.001, 'limit_high_warn' => $entry['outletCurrentThUpperWarning']*0.001);
$limits = [
'limit_low' => $entry['outletCurrentThLowerCritical'] * 0.001,
'limit_low_warn' => $entry['outletCurrentThLowerWarning'] * 0.001,
'limit_high' => $entry['outletCurrentThUpperCritical'] * 0.001,
'limit_high_warn' => $entry['outletCurrentThUpperWarning'] * 0.001
];
discover_sensor('current', $device, $current_oid, "outletCurrent.$outlet_index", 'eaton-epdu-mib', $outlet_descr, 0.001, $current_value, $limits);
discover_sensor('load', $device, $percent_oid, "outletCurrentPercentLoad.$outlet_index", 'eaton-epdu-mib', $outlet_descr, 1, $percent_value);
discover_sensor('crestfactor', $device, $crest_oid, "outletCurrentCrestFactor.$outlet_index", 'eaton-epdu-mib', $outlet_descr, 1, $crest_value);
if ($percent_value >= 0) {
discover_sensor('load', $device, $percent_oid, "outletCurrentPercentLoad.$outlet_index", 'eaton-epdu-mib', $outlet_descr, 1, $percent_value);
}
if ($crest_value > 0) {
discover_sensor('crestfactor', $device, $crest_oid, "outletCurrentCrestFactor.$outlet_index", 'eaton-epdu-mib', $outlet_descr, 0.001, $crest_value);
}
}
}

View File

@ -0,0 +1,96 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// EGW4MIB::EGW4GatewaySensorDeviceCount.0 = INTEGER: 2
if (!snmp_get_oid($device, 'EGW4GatewaySensorDeviceCount.0', $mib)) {
return;
}
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceID.856694 = Gauge32: 856694
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceID.875433 = Gauge32: 875433
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceType.856694 = STRING: "WaterDetect"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceType.875433 = STRING: "Temperature+Humidity"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceReadingValuesAll.856694 = STRING: "No"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceReadingValuesAll.875433 = STRING: "24.57, 40.46"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceReadingUnitsAll.856694 = STRING: "Detected"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceReadingUnitsAll.875433 = STRING: "deg. C, RH"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceRptUT.856694 = STRING: "0x00"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceRptUT.875433 = STRING: "0x9909CE0F"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceReadingTime.856694 = STRING: "392901311"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceReadingTime.875433 = STRING: "392900464"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceReadingAge.856694 = Gauge32: 4511
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceReadingAge.875433 = Gauge32: 5358
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceTypeNo.856694 = STRING: "4"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceTypeNo.875433 = STRING: "43"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceRFStrength.856694 = STRING: "96"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceRFStrength.875433 = STRING: "34"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceActive.856694 = STRING: "Active"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceActive.875433 = STRING: "Active"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceAlarming.856694 = STRING: "Not alarming"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceAlarming.875433 = STRING: "Not alarming"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceVoltage.856694 = STRING: "3.02"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceVoltage.875433 = STRING: "3.04"
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceWDIndexNo.856694 = Wrong Type (should be OCTET STRING): INTEGER: 1
// EGW4MIB::EGW4SensorInfoTranslatedFormatSensorDeviceWDIndexNo.875433 = Wrong Type (should be OCTET STRING): INTEGER: 2
// EGW4MIB::EGW4SensorInfoTranslatedFormatByDatumNumberSensorDeviceID.856694.1 = Gauge32: 856694
// EGW4MIB::EGW4SensorInfoTranslatedFormatByDatumNumberSensorDeviceID.875433.1 = Gauge32: 875433
// EGW4MIB::EGW4SensorInfoTranslatedFormatByDatumNumberSensorDeviceID.875433.2 = Gauge32: 875433
// EGW4MIB::EGW4SensorInfoTranslatedFormatByDatumNumberDatumNumber.856694.1 = INTEGER: 1
// EGW4MIB::EGW4SensorInfoTranslatedFormatByDatumNumberDatumNumber.875433.1 = INTEGER: 1
// EGW4MIB::EGW4SensorInfoTranslatedFormatByDatumNumberDatumNumber.875433.2 = INTEGER: 2
// EGW4MIB::EGW4SensorInfoTranslatedFormatByDatumNumberReadingValue.856694.1 = STRING: "No"
// EGW4MIB::EGW4SensorInfoTranslatedFormatByDatumNumberReadingValue.875433.1 = STRING: "24.57"
// EGW4MIB::EGW4SensorInfoTranslatedFormatByDatumNumberReadingValue.875433.2 = STRING: "40.46"
// EGW4MIB::EGW4SensorInfoTranslatedFormatByDatumNumberReadingUnits.856694.1 = STRING: "Detected"
// EGW4MIB::EGW4SensorInfoTranslatedFormatByDatumNumberReadingUnits.875433.1 = STRING: "deg. C"
// EGW4MIB::EGW4SensorInfoTranslatedFormatByDatumNumberReadingUnits.875433.2 = STRING: "RH"
$egw4 = snmpwalk_cache_oid($device, 'EGW4SensorInfoTranslatedFormatEntry', [], $mib);
$oids = snmpwalk_cache_twopart_oid($device, 'EGW4SensorInfoTranslatedFormatByDatumNumberEntry', [], $mib);
foreach ($oids as $egw4deviceid => $egw4device) {
if ($egw4[$egw4deviceid]['EGW4SensorInfoTranslatedFormatSensorDeviceActive'] !== 'Active') {
continue;
}
$name = $egw4[$egw4deviceid]['EGW4SensorInfoTranslatedFormatSensorDeviceType'];
$egw4count = count($egw4device);
foreach ($egw4device as $sensorid => $entry) {
//$entry = array_merge($entry, (array)$egw4[$egw4deviceid]);
$descr = $name;
if ($egw4count > 1) {
$descr .= " #$sensorid";
}
$index = "$egw4deviceid.$sensorid";
$oid_name = 'EGW4SensorInfoTranslatedFormatByDatumNumberReadingValue';
$oid_num = '.1.3.6.1.4.1.41542.2.2.2.3.'.$index;
$value = $entry[$oid_name];
switch (strtolower($entry['EGW4SensorInfoTranslatedFormatByDatumNumberReadingUnits'])) {
case 'deg. c':
discover_sensor_ng($device, 'temperature', $mib, $oid_name, $oid_num, $index, NULL, $descr, 1, $value);
break;
case 'ph':
discover_sensor_ng($device, 'humidity', $mib, $oid_name, $oid_num, $index, NULL, $descr, 1, $value);
break;
case 'detected':
discover_status_ng($device, $mib, $oid_name, $oid_num, $index, 'EGW4SensorDetected', $descr, $value, [ 'entPhysicalClass' => 'sensor' ]);
break;
default:
print_warning("Unknown sensor Unit: ".$entry['EGW4SensorInfoTranslatedFormatByDatumNumberReadingUnits']);
print_debug_vars($egw4[$egw4deviceid]);
print_debug_vars($entry);
}
}
}
// EOF

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -38,7 +38,7 @@ $scale_current = 0.01;
// ENLOGIC-PDU2-MIB::pduUnitConfigAlarmStateChangeDelay.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0
// ENLOGIC-PDU2-MIB::pduUnitConfigEnabledThresholds.1 = BITS: 00
$oids = snmpwalk_cache_oid($device, 'pduUnitStatusEntry', array(), $mib);
$oids = snmpwalk_cache_oid($device, 'pduUnitStatusEntry', [], $mib);
$oids = snmpwalk_cache_oid($device, 'pduUnitConfigLowerCriticalThreshold', $oids, $mib);
$oids = snmpwalk_cache_oid($device, 'pduUnitConfigLowerWarningThreshold', $oids, $mib);
$oids = snmpwalk_cache_oid($device, 'pduUnitConfigUpperCriticalThreshold', $oids, $mib);
@ -46,8 +46,7 @@ $oids = snmpwalk_cache_oid($device, 'pduUnitConfigUpperWarningThreshold', $oids
$oids = snmpwalk_cache_oid($device, 'pduUnitConfigEnabledThresholds', $oids, $mib);
print_debug_vars($oids);
foreach ($oids as $index => $entry)
{
foreach ($oids as $index => $entry) {
$name = "Unit $index";
// pduUnitStatusLoadState
@ -68,22 +67,18 @@ foreach ($oids as $index => $entry)
// upperWarning (2),
// upperCritical (3)
// }
$options = array();
$options = [];
$limits_flags = base_convert(str_replace(' ', '', $entry['pduUnitConfigEnabledThresholds']), 16, 10);
if (is_flag_set(bindec(10000000), $limits_flags)) // 0b 1000 0000
{
if (is_flag_set(bindec(10000000), $limits_flags)) { // 0b 1000 0000
$options['limit_low'] = $entry['pduUnitConfigLowerCriticalThreshold'] * $scale;
}
if (is_flag_set(bindec(1000000), $limits_flags)) // 0b 0100 0000
{
if (is_flag_set(bindec(1000000), $limits_flags)) { // 0b 0100 0000
$options['limit_low_warn'] = $entry['pduUnitConfigLowerWarningThreshold'] * $scale;
}
if (is_flag_set(bindec(100000), $limits_flags)) // 0b 0010 0000
{
if (is_flag_set(bindec(100000), $limits_flags)) { // 0b 0010 0000
$options['limit_high_warn'] = $entry['pduUnitConfigUpperWarningThreshold'] * $scale;
}
if (is_flag_set(bindec(10000), $limits_flags)) // 0b 0001 0000
{
if (is_flag_set(bindec(10000), $limits_flags)) { // 0b 0001 0000
$options['limit_high'] = $entry['pduUnitConfigUpperCriticalThreshold'] * $scale;
}
@ -110,8 +105,7 @@ foreach ($oids as $index => $entry)
$oid_num = ".1.3.6.1.4.1.38446.1.2.4.1.9.$index";
$value = $entry[$oid_name];
if ($value > 0)
{
if ($value > 0) {
discover_counter($device, 'energy', $mib, $oid_name, $oid_num, $index, $descr, 1, $value);
}
}
@ -136,7 +130,7 @@ $units = snmpwalk_cache_oid($device, 'pduUnitPropertiesCircuitBreakerCount',
$units = snmpwalk_cache_oid($device, 'pduUnitPropertiesConnExternalSensorCount', $units, $mib); // The current number of external sensors connected to the PDU
print_debug_vars($units);
$oids = snmpwalk_cache_twopart_oid($device, 'pduInputPhaseStatusEntry', array(), $mib);
$oids = snmpwalk_cache_twopart_oid($device, 'pduInputPhaseStatusEntry', [], $mib);
$oids = snmpwalk_cache_twopart_oid($device, 'pduInputPhaseConfigCurrentLowerCriticalThreshold', $oids, $mib);
$oids = snmpwalk_cache_twopart_oid($device, 'pduInputPhaseConfigCurrentLowerWarningThreshold', $oids, $mib);
@ -151,10 +145,8 @@ $oids = snmpwalk_cache_twopart_oid($device, 'pduInputPhaseConfigVoltageUpperWarn
$oids = snmpwalk_cache_twopart_oid($device, 'pduInputPhaseConfigVoltageEnabledThresholds', $oids, $mib);
print_debug_vars($oids);
foreach ($oids as $unit => $entry1)
{
foreach ($entry1 as $phase => $entry)
{
foreach ($oids as $unit => $entry1) {
foreach ($entry1 as $phase => $entry) {
if ($entry['pduInputPhaseStatusCount'] < 1) { continue; } // Skip not exist phases
$name = "Unit $unit, Phase $phase Input";
@ -187,22 +179,18 @@ foreach ($oids as $unit => $entry1)
// upperWarning (2),
// upperCritical (3)
// }
$options = array();
$options = [];
$limits_flags = base_convert(str_replace(' ', '', $entry['pduInputPhaseConfigCurrentEnabledThresholds']), 16, 10);
if (is_flag_set(bindec(10000000), $limits_flags)) // 0b 1000 0000
{
if (is_flag_set(bindec(10000000), $limits_flags)) { // 0b 1000 0000
$options['limit_low'] = $entry['pduInputPhaseConfigCurrentLowerCriticalThreshold'] * $scale_current;
}
if (is_flag_set(bindec(1000000), $limits_flags)) // 0b 0100 0000
{
if (is_flag_set(bindec(1000000), $limits_flags)) { // 0b 0100 0000
$options['limit_low_warn'] = $entry['pduInputPhaseConfigCurrentLowerWarningThreshold'] * $scale_current;
}
if (is_flag_set(bindec(100000), $limits_flags)) // 0b 0010 0000
{
if (is_flag_set(bindec(100000), $limits_flags)) { // 0b 0010 0000
$options['limit_high_warn'] = $entry['pduInputPhaseConfigCurrentUpperWarningThreshold'] * $scale_current;
}
if (is_flag_set(bindec(10000), $limits_flags)) // 0b 0001 0000
{
if (is_flag_set(bindec(10000), $limits_flags)) { // 0b 0001 0000
$options['limit_high'] = $entry['pduInputPhaseConfigCurrentUpperCriticalThreshold'] * $scale_current;
}
@ -223,22 +211,18 @@ foreach ($oids as $unit => $entry1)
// upperWarning (2),
// upperCritical (3)
// }
$options = array();
$options = [];
$limits_flags = base_convert(str_replace(' ', '', $entry['pduInputPhaseConfigVoltageEnabledThresholds']), 16, 10);
if (is_flag_set(bindec(10000000), $limits_flags)) // 0b 1000 0000
{
if (is_flag_set(bindec(10000000), $limits_flags)) { // 0b 1000 0000
$options['limit_low'] = $entry['pduInputPhaseConfigVoltageLowerCriticalThreshold'] * $scale;
}
if (is_flag_set(bindec(1000000), $limits_flags)) // 0b 0100 0000
{
if (is_flag_set(bindec(1000000), $limits_flags)) { // 0b 0100 0000
$options['limit_low_warn'] = $entry['pduInputPhaseConfigVoltageLowerWarningThreshold'] * $scale;
}
if (is_flag_set(bindec(100000), $limits_flags)) // 0b 0010 0000
{
if (is_flag_set(bindec(100000), $limits_flags)) { // 0b 0010 0000
$options['limit_high_warn'] = $entry['pduInputPhaseConfigVoltageUpperWarningThreshold'] * $scale;
}
if (is_flag_set(bindec(10000), $limits_flags)) // 0b 0001 0000
{
if (is_flag_set(bindec(10000), $limits_flags)) { // 0b 0001 0000
$options['limit_high'] = $entry['pduInputPhaseConfigVoltageUpperCriticalThreshold'] * $scale;
}
@ -279,7 +263,7 @@ foreach ($oids as $unit => $entry1)
}
}
$oids = snmpwalk_cache_twopart_oid($device, 'pduCircuitBreakerStatusEntry', array(), $mib);
$oids = snmpwalk_cache_twopart_oid($device, 'pduCircuitBreakerStatusEntry', [], $mib);
$oids = snmpwalk_cache_twopart_oid($device, 'pduCircuitBreakerConfigLowerCriticalThreshold', $oids, $mib);
$oids = snmpwalk_cache_twopart_oid($device, 'pduCircuitBreakerConfigLowerWarningThreshold', $oids, $mib);
@ -288,10 +272,8 @@ $oids = snmpwalk_cache_twopart_oid($device, 'pduCircuitBreakerConfigUpperWarning
$oids = snmpwalk_cache_twopart_oid($device, 'pduCircuitBreakerConfigEnabledThresholds', $oids, $mib);
print_debug_vars($oids);
foreach ($oids as $unit => $entry1)
{
foreach ($entry1 as $i => $entry)
{
foreach ($oids as $unit => $entry1) {
foreach ($entry1 as $i => $entry) {
if ($entry['pduCircuitBreakerStatusCount'] < 1) { continue; } // Skip not exist Circuit Breaker
$name = "Unit $unit, Circuit Breaker $i";
@ -315,22 +297,18 @@ foreach ($oids as $unit => $entry1)
// upperWarning (2),
// upperCritical (3)
// }
$options = array();
$options = [];
$limits_flags = base_convert(str_replace(' ', '', $entry['pduCircuitBreakerConfigEnabledThresholds']), 16, 10);
if (is_flag_set(bindec(10000000), $limits_flags)) // 0b 1000 0000
{
if (is_flag_set(bindec(10000000), $limits_flags)) { // 0b 1000 0000
$options['limit_low'] = $entry['pduCircuitBreakerConfigLowerCriticalThreshold'] * $scale_current;
}
if (is_flag_set(bindec(1000000), $limits_flags)) // 0b 0100 0000
{
if (is_flag_set(bindec(1000000), $limits_flags)) { // 0b 0100 0000
$options['limit_low_warn'] = $entry['pduCircuitBreakerConfigLowerWarningThreshold'] * $scale_current;
}
if (is_flag_set(bindec(100000), $limits_flags)) // 0b 0010 0000
{
if (is_flag_set(bindec(100000), $limits_flags)) { // 0b 0010 0000
$options['limit_high_warn'] = $entry['pduCircuitBreakerConfigUpperWarningThreshold'] * $scale_current;
}
if (is_flag_set(bindec(10000), $limits_flags)) // 0b 0001 0000
{
if (is_flag_set(bindec(10000), $limits_flags)) { // 0b 0001 0000
$options['limit_high'] = $entry['pduCircuitBreakerConfigUpperCriticalThreshold'] * $scale_current;
}
@ -347,14 +325,13 @@ foreach ($oids as $unit => $entry1)
// NOTE, next part not tested, but should be working (mike)
$sensors_count = 0;
foreach ($units as $entry)
{
foreach ($units as $entry) {
$sensors_count += $entry['pduUnitPropertiesConnExternalSensorCount'];
}
if ($sensors_count == 0) { return; } // Skip next sensors discovery (not exist)
$oids = snmpwalk_cache_twopart_oid($device, 'pduExternalSensorStatusEntry', array(), $mib);
$oids = snmpwalk_cache_twopart_oid($device, 'pduExternalSensorStatusEntry', [], $mib);
$oids = snmpwalk_cache_twopart_oid($device, 'pduExternalSensorNamePlateType', $oids, $mib);
$oids = snmpwalk_cache_twopart_oid($device, 'pduExternalSensorNamePlateUnits', $oids, $mib);
@ -366,10 +343,8 @@ $oids = snmpwalk_cache_twopart_oid($device, 'pduExternalSensorConfigUpperWarning
$oids = snmpwalk_cache_twopart_oid($device, 'pduExternalSensorConfigEnabledThresholds', $oids, $mib);
print_debug_vars($oids);
foreach ($oids as $unit => $entry1)
{
foreach ($entry1 as $i => $entry)
{
foreach ($oids as $unit => $entry1) {
foreach ($entry1 as $i => $entry) {
if ($entry['pduExternalSensorStatusState'] === 'notPresent') { continue; } // Skip not exist Sensors
$name = "Unit $unit, Sensor ".$entry['pduExternalSensorStatusName'];
@ -394,22 +369,18 @@ foreach ($oids as $unit => $entry1)
// upperWarning (2),
// upperCritical (3)
// }
$options = array();
$options = [];
$limits_flags = base_convert(str_replace(' ', '', $entry['pduExternalSensorConfigEnabledThresholds']), 16, 10);
if (is_flag_set(bindec(10000000), $limits_flags)) // 0b 1000 0000
{
if (is_flag_set(bindec(10000000), $limits_flags)) { // 0b 1000 0000
$options['limit_low'] = $entry['pduExternalSensorConfigLowerCriticalThreshold'] * $scale;
}
if (is_flag_set(bindec(1000000), $limits_flags)) // 0b 0100 0000
{
if (is_flag_set(bindec(1000000), $limits_flags)) { // 0b 0100 0000
$options['limit_low_warn'] = $entry['pduExternalSensorConfigLowerWarningThreshold'] * $scale;
}
if (is_flag_set(bindec(100000), $limits_flags)) // 0b 0010 0000
{
if (is_flag_set(bindec(100000), $limits_flags)) { // 0b 0010 0000
$options['limit_high_warn'] = $entry['pduExternalSensorConfigUpperWarningThreshold'] * $scale;
}
if (is_flag_set(bindec(10000), $limits_flags)) // 0b 0001 0000
{
if (is_flag_set(bindec(10000), $limits_flags)) { // 0b 0001 0000
$options['limit_high'] = $entry['pduExternalSensorConfigUpperCriticalThreshold'] * $scale;
}
@ -427,8 +398,7 @@ foreach ($oids as $unit => $entry1)
// modbusAdapter (17),
// hidAdapter (18)
// }
switch ($entry['pduExternalSensorNamePlateType'])
{
switch ($entry['pduExternalSensorNamePlateType']) {
case 'temperature':
case 'humidity':
$sensor_class = $entry['pduExternalSensorNamePlateType'];
@ -439,13 +409,11 @@ foreach ($oids as $unit => $entry1)
default:
continue 2;
}
if ($entry['pduExternalSensorNamePlateUnits'] === 'degreeF')
{
if ($entry['pduExternalSensorNamePlateUnits'] === 'degreeF') {
$options['sensor_unit'] = 'F';
}
if (isset($entry['pduExternalSensorStatusHighPrecisionValue'])) // && $entry['pduExternalSensorStatusHighPrecisionValue'] > 0)
{
if (isset($entry['pduExternalSensorStatusHighPrecisionValue'])) { // && $entry['pduExternalSensorStatusHighPrecisionValue'] > 0)
$scale = 0.1;
$oid_name = 'pduExternalSensorStatusHighPrecisionValue';
$oid_num = ".1.3.6.1.4.1.38446.1.6.4.1.8.$index";

View File

@ -1,5 +1,4 @@
<?php
/**
* Observium
*
@ -7,70 +6,199 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2015 Adam Armstrong
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
echo('Caching OIDs: ');
$ups_array = array();
$InputTableCount = snmp_get($device, 'upsESystemInputNumPhases.0', '-OQv', $mib);
echo('upsESystemInputTable ('.$InputTableCount.' entries)');
$ups_array = snmpwalk_cache_oid($device, 'upsESystemInputTable', $ups_array, $mib);
$OutputTableCount = snmp_get($device, 'upsESystemOutputNumPhase.0', '-OQv', $mib);
echo('upsESystemOutputTable ('.$OutputTableCount.' entries)');
$ups_array = snmpwalk_cache_oid($device, 'upsESystemOutputTable', $ups_array, $mib);
$BypassTableCount = snmp_get($device, 'upsESystemBypassNumPhase.0', '-OQv', $mib);
echo('upsESystemBypassTable ('.$BypassTableCount.' entries)');
$ups_array = snmpwalk_cache_oid($device, 'upsESystemBypassTable', $ups_array, $mib);
$scale = 0.1;
$nominal = snmp_get($device, 'upsESystemConfigOutputVoltage.0', '-OQv', $mib) * $scale;
$voltage_limits = array('limit_high' => ($nominal * 1.03), 'limit_high_warn' => ($nominal * 1.01), 'limit_low' => ($nominal * 0.97), 'limit_low_warn' => ($nominal * 0.99));
# Input Sensors
for ($index = 1; $index <= $InputTableCount; $index++)
{
$data = $ups_array[$index];
$descr = 'Input';
$oid = '.1.3.6.1.4.1.935.10.1.1.2.16.1.3.'.$index; # EPPC-MIB:upsESystemInputVoltage.$index
$value = $data['upsESystemInputVoltage'];
discover_sensor('voltage', $device, $oid, "upsESystemInputVoltage.$index", 'eppc-mib', $descr, 0.1, $value, $voltage_limits);
// EPPC-MIB::upsESystemConfigInputVoltage.0 = INTEGER: 2300
// EPPC-MIB::upsESystemConfigInputFrequence.0 = INTEGER: 500
// EPPC-MIB::upsESystemInputSourceNum.0 = INTEGER: 1
// EPPC-MIB::upsESystemInputLineBads.0 = Counter32: 0
// EPPC-MIB::upsESystemInputNumPhases.0 = INTEGER: 1
// EPPC-MIB::upsESystemInputFrequency.1 = INTEGER: 500
// EPPC-MIB::upsESystemInputVoltage.1 = INTEGER: 2301
// EPPC-MIB::upsESystemInputCurrent.1 = INTEGER: -1
// EPPC-MIB::upsESystemInputWatts.1 = INTEGER: -1
$input_phases = snmp_get_oid($device, 'upsESystemInputNumPhases.0', $mib);
if ($input_phases > 0) {
echo('upsESystemInputTable ('.$input_phases.' phases)');
$descr = "Input";
$oid = ".1.3.6.1.4.1.935.10.1.1.2.16.1.2.".$index; # EPPC-MIB:upsESystemInputFrequency.$index
$value = $data['upsESystemInputFrequency'];
$limits = array('limit_high' => 55, 'limit_high_warn' => 51, 'limit_low' => 45, 'limit_low_warn' => 49);
discover_sensor('frequency', $device, $oid, "upsESystemInputFrequency.$index", 'eppc-mib', $descr, 0.1, $value, $limits);
$scale = 0.1;
$ups_array = snmpwalk_cache_oid($device, 'upsESystemInputTable', [], $mib);
$input_voltage = snmp_get_oid($device, 'upsESystemConfigInputVoltage.0', $mib) * $scale;
if ($input_voltage > 0) {
$voltage_limits = [
'limit_high' => $input_voltage * 1.03, 'limit_high_warn' => $input_voltage * 1.01,
'limit_low' => $input_voltage * 0.97, 'limit_low_warn' => $input_voltage * 0.99
];
} else {
$voltage_limits = [];
}
$input_frequency = snmp_get_oid($device, 'upsESystemConfigInputFrequence.0', $mib) * $scale;
if ($input_frequency > 0) {
$frequency_limits = [
'limit_high' => $input_frequency * 1.10, 'limit_high_warn' => $input_frequency * 1.02,
'limit_low' => $input_frequency * 0.90, 'limit_low_warn' => $input_frequency * 0.98
];
} else {
$frequency_limits = [];
}
foreach ($ups_array as $phase => $entry) {
$descr = 'Input';
if ($input_phases > 1) {
$descr .= ' (Phase '.$phase.')';
}
$oid_name = 'upsESystemInputVoltage';
$oid_num = '.1.3.6.1.4.1.935.10.1.1.2.16.1.3.'.$phase;
$value = $entry[$oid_name];
$options = $voltage_limits;
$options['rename_rrd'] = "eppc-mib-upsESystemInputVoltage.%index%";
//discover_sensor('voltage', $device, $oid, "upsESystemInputVoltage.$index", 'eppc-mib', $descr, 0.1, $value, $voltage_limits);
discover_sensor_ng($device, 'voltage', $mib, $oid_name, $oid_num, $phase, NULL, $descr, $scale, $value, $options);
$oid_name = 'upsESystemInputFrequency';
$oid_num = '.1.3.6.1.4.1.935.10.1.1.2.16.1.2.'.$phase;
$value = $entry[$oid_name];
$options = $frequency_limits;
$options['rename_rrd'] = "eppc-mib-upsESystemInputFrequency.%index%";
//discover_sensor('frequency', $device, $oid, "upsESystemInputFrequency.$index", 'eppc-mib', $descr, 0.1, $value, $limits);
discover_sensor_ng($device, 'frequency', $mib, $oid_name, $oid_num, $phase, NULL, $descr, $scale, $value, $options);
if ($entry['upsESystemInputCurrent'] > 0) {
$oid_name = 'upsESystemInputCurrent';
$oid_num = '.1.3.6.1.4.1.935.10.1.1.2.16.1.4.'.$phase;
$value = $entry[$oid_name];
discover_sensor_ng($device, 'current', $mib, $oid_name, $oid_num, $phase, NULL, $descr, $scale, $value);
}
if ($entry['upsESystemInputWatts'] > 0) {
$oid_name = 'upsESystemInputWatts';
$oid_num = '.1.3.6.1.4.1.935.10.1.1.2.16.1.5.'.$phase;
$value = $entry[$oid_name];
discover_sensor_ng($device, 'power', $mib, $oid_name, $oid_num, $phase, NULL, $descr, 1, $value);
}
}
}
# Output Sensors
for ($index = 1; $index <= $InputTableCount; $index++)
{
$data = $ups_array[$index];
// EPPC-MIB::upsESystemConfigOutputVoltage.0 = INTEGER: -1
// EPPC-MIB::upsESystemConfigOutputFrequency.0 = INTEGER: -1
// EPPC-MIB::upsESystemConfigOutputVA.0 = INTEGER: -1
// EPPC-MIB::upsESystemConfigOutputPower.0 = INTEGER: -1
// EPPC-MIB::upsESystemConfigOutputLoadHighSetPoint.0 = INTEGER: 90
// EPPC-MIB::upsESystemOutputNumPhase.0 = INTEGER: 1
// EPPC-MIB::upsESystemOutputFrequency.1 = INTEGER: 500
// EPPC-MIB::upsESystemOutputVoltage.1 = INTEGER: 2299
// EPPC-MIB::upsESystemOutputCurrent.1 = INTEGER: 64
// EPPC-MIB::upsESystemOutputWatts.1 = INTEGER: 1300
// EPPC-MIB::upsESystemOutputVA.1 = INTEGER: 1400
// EPPC-MIB::upsESystemOutputLoad.1 = INTEGER: 24
$descr = "Output";
$oid = ".1.3.6.1.4.1.935.10.1.1.2.18.1.3.$index"; # EPPC-MIB:upsESystemOutputVoltage.$index
$value = $data['upsESystemOutputVoltage'];
discover_sensor('voltage', $device, $oid, "upsESystemOutputVoltage.$index", 'eppc-mib', $descr, 0.1, $value, $voltage_limits);
$output_phases = snmp_get_oid($device, 'upsESystemOutputNumPhase.0', $mib);
if ($output_phases > 0) {
echo('upsESystemOutputTable (' . $output_phases . ' phases)');
$descr = "Output";
$oid = ".1.3.6.1.4.1.935.10.1.1.2.18.1.2.$index"; # EPPC-MIB:upsESystemOutputFrequency.$index
$value = $data['upsESystemOutputFrequency'];
$limits = array('limit_high' => 55, 'limit_high_warn' => 51, 'limit_low' => 45, 'limit_low_warn' => 49); // FIXME orly? 50Hz only?
discover_sensor('frequency', $device, $oid, "upsESystemOutputFrequency.$index", 'eppc-mib', $descr, 0.1, $value, $limits);
$scale = 0.1;
$ups_array = snmpwalk_cache_oid($device, 'upsESystemOutputTable', [], $mib);
$descr = "Output";
$oid = ".1.3.6.1.4.1.935.10.1.1.2.18.1.7.$index"; # EPPC-MIB:upsESystemOutputLoad.$index
$value = $data['upsESystemOutputLoad'];
$limits = array('limit_high' => 100, 'limit_high_warn' => 75, 'limit_low' => 0);
discover_sensor('load', $device, $oid, "upsESystemOutputLoad.$index", 'eppc-mib', $descr, 1, $value, $limits);
$output_voltage = snmp_get_oid($device, 'upsESystemConfigOutputVoltage.0', $mib) * $scale;
if ($output_voltage > 0) {
$voltage_limits = [
'limit_high' => $output_voltage * 1.03, 'limit_high_warn' => $output_voltage * 1.01,
'limit_low' => $output_voltage * 0.97, 'limit_low_warn' => $output_voltage * 0.99
];
} else {
// Keep input voltage limits
//$voltage_limits = [];
}
$output_frequency = snmp_get_oid($device, 'upsESystemConfigOutputFrequency.0', $mib) * $scale;
if ($output_frequency > 0) {
$frequency_limits = [
'limit_high' => $output_frequency * 1.10, 'limit_high_warn' => $output_frequency * 1.02,
'limit_low' => $output_frequency * 0.90, 'limit_low_warn' => $output_frequency * 0.98
];
} else {
// Keep input frequency limits
//$frequency_limits = [];
}
foreach ($ups_array as $phase => $entry) {
$descr = 'Output';
if ($input_phases > 1) {
$descr .= ' (Phase ' . $phase . ')';
}
$oid_name = 'upsESystemOutputVoltage';
$oid_num = ".1.3.6.1.4.1.935.10.1.1.2.18.1.3.$index";
$value = $entry[$oid_name];
$options = $voltage_limits;
$options['rename_rrd'] = "eppc-mib-upsESystemOutputVoltage.%index%";
//discover_sensor('voltage', $device, $oid, "upsESystemOutputVoltage.$index", 'eppc-mib', $descr, 0.1, $value, $voltage_limits);
discover_sensor_ng($device, 'voltage', $mib, $oid_name, $oid_num, $phase, NULL, $descr, $scale, $value, $options);
$oid_name = 'upsESystemOutputFrequency';
$oid_num = ".1.3.6.1.4.1.935.10.1.1.2.18.1.2.$index";
$value = $entry[$oid_name];
$options = $frequency_limits;
$options['rename_rrd'] = "eppc-mib-upsESystemOutputFrequency.%index%";
//discover_sensor('frequency', $device, $oid, "upsESystemOutputFrequency.$index", 'eppc-mib', $descr, 0.1, $value, $limits);
discover_sensor_ng($device, 'frequency', $mib, $oid_name, $oid_num, $phase, NULL, $descr, $scale, $value, $options);
$oid_name = 'upsESystemOutputLoad';
$oid_num = ".1.3.6.1.4.1.935.10.1.1.2.18.1.7.$index";
$value = $entry[$oid_name];
$options = [ 'limit_high' => 90, 'limit_high_warn' => 75 ];
$options['rename_rrd'] = "eppc-mib-upsESystemOutputLoad.%index%";
//discover_sensor('load', $device, $oid, "upsESystemOutputLoad.$index", 'eppc-mib', $descr, 1, $value, $limits);
discover_sensor_ng($device, 'load', $mib, $oid_name, $oid_num, $phase, NULL, $descr, 1, $value, $options);
if ($entry['upsESystemOutputCurrent'] > 0) {
$oid_name = 'upsESystemOutputCurrent';
$oid_num = '.1.3.6.1.4.1.935.10.1.1.2.18.1.4.'.$phase;
$value = $entry[$oid_name];
discover_sensor_ng($device, 'current', $mib, $oid_name, $oid_num, $phase, NULL, $descr, $scale, $value);
}
if ($entry['upsESystemOutputWatts'] > 0) {
$oid_name = 'upsESystemOutputWatts';
$oid_num = '.1.3.6.1.4.1.935.10.1.1.2.18.1.5.'.$phase;
$value = $entry[$oid_name];
discover_sensor_ng($device, 'power', $mib, $oid_name, $oid_num, $phase, NULL, $descr, 1, $value);
}
if ($entry['upsESystemOutputVA'] > 0) {
$oid_name = 'upsESystemOutputVA';
$oid_num = '.1.3.6.1.4.1.935.10.1.1.2.18.1.6.'.$phase;
$value = $entry[$oid_name];
discover_sensor_ng($device, 'apower', $mib, $oid_name, $oid_num, $phase, NULL, $descr, 1, $value);
}
}
}
// FIXME Sensors below are a definite candidate for definition-based discovery
# bypass sensors
// EPPC-MIB::upsESystemBypassNumPhase.0 = INTEGER: -1
$bypass_phases = snmp_get_oid($device, 'upsESystemBypassNumPhase.0', $mib);
if ($bypass_phases > 0) {
echo('upsESystemBypassTable (' . $bypass_phases . ' phases)');
$ups_array = snmpwalk_cache_oid($device, 'upsESystemBypassTable', [], $mib);
}
/* FIXME Sensors below are a definite candidate for definition-based discovery
$descr = 'Charge Remaining';
$oid = '.1.3.6.1.4.1.935.10.1.1.3.4.0'; # EPPC-MIB:upsEBatteryEstimatedChargeRemaining
@ -96,7 +224,7 @@ $high = snmp_get($device, 'upsEEnvironmentTemperatureHighSetPoint.0', '-OQv',
$low = snmp_get($device, 'upsEEnvironmentTemperatureLowSetPoint.0', '-OQv', $mib);
$limits = array('limit_high' => $high * $scale, 'limit_high_warn' => ($high * $scale) * .75, 'limit_low' => $low * $scale);
discover_sensor('temperature', $device, $oid, 'upsESystemTemperature', 'eppc-mib', $descr, $scale, $value, $limits); // FIXME should be upsESystemTemperature.0
*/
unset($limits, $ups_array);
// EOF

View File

@ -6,18 +6,17 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// Currently not possible convert to definitions because type detection is hard, based on descriptions
// SAME code in ATEN-IPMI-MIB
$oids = snmpwalk_multipart_oid($device, "fgHwSensorTable", array(), "FORTINET-FORTIGATE-MIB");
$oids = snmpwalk_multipart_oid($device, "fgHwSensorTable", [], "FORTINET-FORTIGATE-MIB");
print_debug_vars($oids);
foreach ($oids as $index => $entry)
{
foreach ($oids as $index => $entry) {
$descr = $entry['fgHwSensorEntName'];
$oid_name = 'fgHwSensorEntValue';
@ -25,6 +24,8 @@ foreach ($oids as $index => $entry)
$scale = 1;
$value = $entry[$oid_name];
if (empty($descr) && $value == 0) { continue; }
// Detect class based on descr anv value (this is derp, table not have other data for detect class
if (str_iends($descr, ' Temp')) {
if ($value == 0) { continue; }
@ -58,7 +59,10 @@ foreach ($oids as $index => $entry)
$class = 'temperature';
}
discover_sensor_ng($device, $class, $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value);
discover_status_ng($device, $mib, `fgHwSensorEntAlarmStatus`, '.1.3.6.1.4.1.12356.101.4.3.2.1.4.'.$index, $index,
'fgHwSensorEntAlarmStatus', $descr, $entry['fgHwSensorEntAlarmStatus']);
discover_sensor_ng($device, $class, $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value);
}
// EOF

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -105,6 +105,7 @@ $entity_array = [];
*/
$power_class = 'power';
$power_scale = 0.000001;
$power_scale_multi = 0.01;
foreach (snmpwalk_cache_oid($device, 'hwEntityOpticalTemperature', [], 'HUAWEI-ENTITY-EXTENT-MIB') as $index => $entry) {
// Ignore optical sensors with temperature of zero or negative
if ($entry['hwEntityOpticalTemperature'] > 1) {
@ -223,25 +224,40 @@ foreach ($entity_array as $index => $entry) {
}
if ($multilane) {
// Fix incorrect Power scale.. again
// See: https://jira.observium.org/browse/OBS-4148
/*
hwEntityOpticalRxPower.16850463 = -121
hwEntityOpticalRxHighThreshold.16850463 = 400
hwEntityOpticalRxHighWarnThreshold.16850463 = No Such Object available on this agent at this OID
hwEntityOpticalRxLowThreshold.16850463 = -1801
hwEntityOpticalRxLowWarnThreshold.16850463 = No Such Object available on this agent at this OID
hwEntityOpticalLaneRxPower.16850463 = -1.21,-1.51,-1.83,-2.18
*/
list($lane1_rxpower) = explode(',', $entry['hwEntityOpticalLaneRxPower']);
if (($entry['hwEntityOpticalRxPower'] != -1) && float_cmp($entry['hwEntityOpticalRxPower'] * 0.01, $lane1_rxpower, 0.01) === 0) {
$power_scale_multi = 1;
}
$rxoptions['sensor_unit'] = 'split1';
$lane_descr = $entry['ifDescr'] . ' Lane 1 Rx Power' . $trans;
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneRxPower', $lane_oid, $index, NULL, $lane_descr, 0.01, $entry['hwEntityOpticalLaneRxPower'], $rxoptions);
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneRxPower', $lane_oid, $index, NULL, $lane_descr, $power_scale_multi, $entry['hwEntityOpticalLaneRxPower'], $rxoptions);
$rxoptions['sensor_unit'] = 'split2';
$lane_descr = $entry['ifDescr'] . ' Lane 2 Rx Power' . $trans;
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneRxPower', $lane_oid, $index, NULL, $lane_descr, 0.01, $entry['hwEntityOpticalLaneRxPower'], $rxoptions);
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneRxPower', $lane_oid, $index, NULL, $lane_descr, $power_scale_multi, $entry['hwEntityOpticalLaneRxPower'], $rxoptions);
$rxoptions['sensor_unit'] = 'split3';
$lane_descr = $entry['ifDescr'] . ' Lane 3 Rx Power' . $trans;
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneRxPower', $lane_oid, $index, NULL, $lane_descr, 0.01, $entry['hwEntityOpticalLaneRxPower'], $rxoptions);
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneRxPower', $lane_oid, $index, NULL, $lane_descr, $power_scale_multi, $entry['hwEntityOpticalLaneRxPower'], $rxoptions);
$rxoptions['sensor_unit'] = 'split4';
$lane_descr = $entry['ifDescr'] . ' Lane 4 Rx Power' . $trans;
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneRxPower', $lane_oid, $index, NULL, $lane_descr, 0.01, $entry['hwEntityOpticalLaneRxPower'], $rxoptions);
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneRxPower', $lane_oid, $index, NULL, $lane_descr, $power_scale_multi, $entry['hwEntityOpticalLaneRxPower'], $rxoptions);
} else {
$rxoptions['rename_rrd'] = "HUAWEI-ENTITY-EXTENT-MIB-hwEntityOpticalRxPower-$index";
$lane_descr = $entry['ifDescr'] . ' Rx Power' . $trans;
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneRxPower', $lane_oid, $index, NULL, $lane_descr, 0.01, $entry['hwEntityOpticalLaneRxPower'], $rxoptions);
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneRxPower', $lane_oid, $index, NULL, $lane_descr, $power_scale_multi, $entry['hwEntityOpticalLaneRxPower'], $rxoptions);
}
} elseif ($entry['hwEntityOpticalRxPower'] != -1) {
// Huawei does not follow their own MIB for some devices and instead reports Rx/Tx Power as dBm converted to mW then multiplied by 1000
@ -275,21 +291,36 @@ foreach ($entity_array as $index => $entry) {
}
if ($multilane) {
// Fix incorrect Power scale.. again
// See: https://jira.observium.org/browse/OBS-4148
/*
hwEntityOpticalTxPower.16850463 = -25
hwEntityOpticalTxHighThreshold.16850463 = 400
hwEntityOpticalTxHighWarnThreshold.16850463 = No Such Object available on this agent at this OID
hwEntityOpticalTxLowThreshold.16850463 = -1060
hwEntityOpticalTxLowWarnThreshold.16850463 = No Such Object available on this agent at this OID
hwEntityOpticalLaneTxPower.16850463 = -0.25,-0.26,-0.26,-0.23
*/
list($lane1_txpower) = explode(',', $entry['hwEntityOpticalLaneTxPower']);
if (($entry['hwEntityOpticalTxPower'] != -1) && float_cmp($entry['hwEntityOpticalTxPower'] * 0.01, $lane1_txpower, 0.01) === 0) {
$power_scale_multi = 1;
}
$txoptions['sensor_unit'] = 'split1';
$lane_descr = $entry['ifDescr'] . ' Lane 1 Tx Power' . $trans;
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneTxPower', $lane_oid, $index, NULL, $lane_descr, 0.01, $entry['hwEntityOpticalLaneTxPower'], $txoptions);
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneTxPower', $lane_oid, $index, NULL, $lane_descr, $power_scale_multi, $entry['hwEntityOpticalLaneTxPower'], $txoptions);
$txoptions['sensor_unit'] = 'split2';
$lane_descr = $entry['ifDescr'] . ' Lane 2 Tx Power' . $trans;
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneTxPower', $lane_oid, $index, NULL, $lane_descr, 0.01, $entry['hwEntityOpticalLaneTxPower'], $txoptions);
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneTxPower', $lane_oid, $index, NULL, $lane_descr, $power_scale_multi, $entry['hwEntityOpticalLaneTxPower'], $txoptions);
$txoptions['sensor_unit'] = 'split3';
$lane_descr = $entry['ifDescr'] . ' Lane 3 Tx Power' . $trans;
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneTxPower', $lane_oid, $index, NULL, $lane_descr, 0.01, $entry['hwEntityOpticalLaneTxPower'], $txoptions);
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneTxPower', $lane_oid, $index, NULL, $lane_descr, $power_scale_multi, $entry['hwEntityOpticalLaneTxPower'], $txoptions);
$txoptions['sensor_unit'] = 'split4';
$lane_descr = $entry['ifDescr'] . ' Lane 4 Tx Power' . $trans;
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneTxPower', $lane_oid, $index, NULL, $lane_descr, 0.01, $entry['hwEntityOpticalLaneTxPower'], $txoptions);
discover_sensor_ng($device, 'dbm', $mib, 'hwEntityOpticalLaneTxPower', $lane_oid, $index, NULL, $lane_descr, $power_scale_multi, $entry['hwEntityOpticalLaneTxPower'], $txoptions);
} else {
$txoptions['rename_rrd'] = "HUAWEI-ENTITY-EXTENT-MIB-hwEntityOpticalTxPower-$index";
$lane_descr = $entry['ifDescr'] . ' Tx Power' . $trans;

View File

@ -1,5 +1,4 @@
<?php
/**
* Observium
*
@ -7,7 +6,7 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -19,7 +18,7 @@
//POWER-ETHERNET-MIB::pethMainPseConsumptionPower.10 = Gauge32: 0 Watts
//POWER-ETHERNET-MIB::pethMainPseConsumptionPower.11 = Gauge32: 1 Watts
$oids = snmpwalk_cache_oid($device, 'pethMainPseTable', array(), 'POWER-ETHERNET-MIB');
$oids = snmpwalk_cache_oid($device, 'pethMainPseTable', [], 'POWER-ETHERNET-MIB');
//NETONIX-SWITCH-MIB::poeStatus.10 = STRING: Off
//NETONIX-SWITCH-MIB::poeStatus.11 = STRING: 48V
@ -30,14 +29,12 @@ print_debug_vars($oids);
////// Per-port Statistics
foreach ($oids as $index => $entry)
{
$options = array('entPhysicalIndex' => $index);
foreach ($oids as $index => $entry) {
$options = [ 'entPhysicalIndex' => $index ];
$port = get_port_by_ifIndex($device['device_id'], $index);
// print_vars($port);
if (is_array($port))
{
if (is_array($port)) {
$entry['ifDescr'] = $port['port_label'];
$options['measured_class'] = 'port';
$options['measured_entity'] = $port['port_id'];
@ -55,8 +52,7 @@ foreach ($oids as $index => $entry)
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, $options);
if ($entry['pethMainPseOperStatus'] != 'off')
{
if ($entry['pethMainPseOperStatus'] != 'off') {
$descr = $entry['ifDescr'] . ' PoE Power';
$oid_name = 'pethMainPseConsumptionPower';

View File

@ -1407,7 +1407,7 @@ foreach ($cache['apc'] as $index => $entry)
$descr = $entry['uioSensorStatusSensorName'];
$status = $entry['uioSensorStatusCommStatus'];
if ($status != 'commsOK') { continue; } // Skip unconnected sensors entirely
if ($status !== 'commsOK') { continue; } // Skip unconnected sensors entirely
// Humidity
$value = $entry['uioSensorStatusHumidity'];
@ -1417,7 +1417,7 @@ foreach ($cache['apc'] as $index => $entry)
if ($value != '' && $value > 0) // Humidity = 0 or -1 -> Sensor not available
{
// Skip if already discovered through iem
if (!in_array($descr, $iem_sensors['humidity']))
if (!in_array($descr, (array)$iem_sensors['humidity']))
{
//discover_sensor('humidity', $device, $oid, "uioSensorStatusHumidity.$index", 'apc', $descr, 1, $value);
$options = [ 'rename_rrd' => 'apc-uioSensorStatusHumidity.%index%' ];
@ -1435,7 +1435,7 @@ foreach ($cache['apc'] as $index => $entry)
if ($value != '' && $value != -1) // Temperature = -1 -> Sensor not available
{
// Skip if already discovered through iem
if (!in_array($descr, $iem_sensors['temperature']))
if (!in_array($descr, (array)$iem_sensors['temperature']))
{
//discover_sensor('temperature', $device, $oid, "uioSensorStatusTemperatureDegC.$index", 'apc', $descr, 1, $value);
$options = [ 'rename_rrd' => 'apc-uioSensorStatusTemperatureDegC.%index%' ];

View File

@ -0,0 +1,215 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// Inlets
// PWTv1-MIB::pduPwrMonitoringInletNum.0 = INTEGER: 1
// PWTv1-MIB::inletIndex.1 = INTEGER: 0
// PWTv1-MIB::inletPowerAll.1 = INTEGER: 11114 0.1W
// PWTv1-MIB::inletResetFrom.1 = STRING: "07/02/2022 15:40:15"
// PWTv1-MIB::inletEnergy.1 = INTEGER: 10526559 KWh
// PWTv1-MIB::inletStatus.1 = INTEGER: normal(1)
// PWTv1-MIB::inletCurrPhase1.1 = INTEGER: 526 0.01A
// PWTv1-MIB::inletCurrPhase2.1 = INTEGER: 0 0.01A
// PWTv1-MIB::inletCurrPhase3.1 = INTEGER: 0 0.01A
// PWTv1-MIB::inletVoltPhase1.1 = INTEGER: 2291 0.1V
// PWTv1-MIB::inletVoltPhase2.1 = INTEGER: 0 0.1V
// PWTv1-MIB::inletVoltPhase3.1 = INTEGER: 0 0.1V
// PWTv1-MIB::inletPowerPhase1.1 = INTEGER: 11114 0.1W
// PWTv1-MIB::inletPowerPhase2.1 = INTEGER: 0 0.1W
// PWTv1-MIB::inletPowerPhase3.1 = INTEGER: 0 0.1W
$inlet_count = snmp_get_oid($device, 'pduPwrMonitoringInletNum.0', 'PWTv1-MIB');
$oids = snmpwalk_cache_oid($device, 'pduPwrMonitoringInletStatusTable', [], 'PWTv1-MIB');
$oids = snmpwalk_cache_oid($device, 'pduPwrMonitoringInletCfgTable', $oids, 'PWTv1-MIB');
foreach ($oids as $index => $entry) {
// PDU reports all inlets as "normal" status, but really only as in count
if ($index > $inlet_count) { break; }
$name = $inlet_count > 1 ? " #$index" : '';
$descr = "Inlet Total".$name;
$oid_num = ".1.3.6.1.4.1.42610.1.4.4.1.6.1.2.1.2.$index";
$oid_name = 'inletPowerAll';
$value = $entry[$oid_name];
$scale = 0.1;
$options = [
'limit_high' => $entry['inletCfgLoadCritical'] * 1000 * $scale,
'limit_high_warn' => $entry['inletCfgLoadWarning'] * 1000 * $scale
];
discover_sensor_ng($device, 'power', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options);
$descr = "Inlet Total".$name;
$oid_num = ".1.3.6.1.4.1.42610.1.4.4.1.6.1.2.1.4.$index";
$oid_name = 'inletEnergy';
$value = $entry[$oid_name];
$scale = 1000;
$options = [];
discover_counter($device, 'energy', $mib, $oid_name, $oid_num, $index, $descr, $scale, $value, $options);
$descr = "Inlet".$name;
$oid_num = ".1.3.6.1.4.1.42610.1.4.4.1.6.1.2.1.5.$index";
$oid_name = 'inletStatus';
$value = $entry[$oid_name];
$options = [];
discover_status_ng($device, $mib, $oid_name, $oid_num, $index, 'inletStatus', $descr, $value, $options);
$phase_count = ($entry['inletVoltPhase2'] > 0) || ($entry['inletVoltPhase3'] > 0) ? 3 : 1;
for ($phase = 1; $phase <= $phase_count; $phase++) {
$phase_name = $phase_count > 1 ? " (Phase $phase)" : '';
$descr = "Inlet".$name.$phase_name;
$oid_name = 'inletCurrPhase'.$phase;
$oid_num = snmp_translate($oid_name, $mib).".$index";
$value = $entry[$oid_name];
$scale = 0.1;
$options = [
'limit_high' => $entry['inletCfgTotalCurrCritPhase'.$phase] * $scale,
'limit_high_warn' => $entry['inletCfgTotalCurrWarnPhase'.$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 = 'inletVoltPhase'.$phase;
$oid_num = snmp_translate($oid_name, $mib).".$index";
$value = $entry[$oid_name];
$scale = 0.1;
$options = [
'limit_high' => $entry['inletCfgVoltCritPhase'.$phase] * $scale,
'limit_high_warn' => $entry['inletCfgVoltWarnPhase'.$phase] * $scale
];
discover_sensor_ng($device, 'voltage', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options);
$descr = "Inlet".$name.$phase_name;
$oid_name = 'inletFreqPhase'.$phase;
$oid_num = snmp_translate($oid_name, $mib).".$index";
$value = $entry[$oid_name];
$scale = 0.01;
$options = [];
discover_sensor_ng($device, 'frequency', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options);
if ($phase_count > 1) {
// Three Phase
$descr = "Inlet".$name.$phase_name;
$oid_name = 'inletPowerPhase'.$phase;
$oid_num = snmp_translate($oid_name, $mib).".$index";
$value = $entry[$oid_name];
$scale = 0.1;
$options = [];
discover_sensor_ng($device, 'power', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options);
$descr = "Inlet".$name.$phase_name;
$oid_name = 'inletStatusPhase'.$phase;
$oid_num = snmp_translate($oid_name, $mib).".$index";
$value = $entry[$oid_name];
$options = [];
discover_status_ng($device, $mib, $oid_name, $oid_num, $index, 'inletStatus', $descr, $value, $options);
}
}
}
// Outlets
// PWTv1-MIB::pduPwrMonitoringOutletNumPduA.0 = INTEGER: 0
// PWTv1-MIB::pduPwrMonitoringOutletNumPduB.0 = INTEGER: 0
// PWTv1-MIB::pduPwrMonitoringOutletNumPduC.0 = INTEGER: 0
// PWTv1-MIB::pduPwrMonitoringOutletNumPduD.0 = INTEGER: 0
// PWTv1-MIB::pduPwrMonitoringOutletNumPduE.0 = INTEGER: 0
// PWTv1-MIB::pduPwrMonitoringOutletNumPduF.0 = INTEGER: 0
// PWTv1-MIB::pduPwrMonitoringOutletNumPduG.0 = INTEGER: 0
// PWTv1-MIB::pduPwrMonitoringOutletNumPduH.0 = INTEGER: 0
// PWTv1-MIB::outletPduAIndex.11 = INTEGER: 10
// PWTv1-MIB::outletPduAState.11 = INTEGER: off(1)
// PWTv1-MIB::outletPduACurrent.11 = INTEGER: 0 0.01A
// PWTv1-MIB::outletPduAPwrFactor.11 = INTEGER: 0 0.1%
// PWTv1-MIB::outletPduAPower.11 = INTEGER: 0 0.1W
// PWTv1-MIB::outletPduAEnergy.11 = INTEGER: 0 KWh
// PWTv1-MIB::outletPduAResetFrom.11 = STRING: "07/02/2022 15:40:15"
// PWTv1-MIB::outletPduAStatus.11 = INTEGER: normal(1)
// PWTv1-MIB::outletPduAAppPower.11 = INTEGER: 0 0.1W
// PWTv1-MIB::outletPduAVoltage.11 = INTEGER: 0 0.1V
// PWTv1-MIB::outletCfgPduAIndex.11 = INTEGER: 10
// PWTv1-MIB::outletCfgPduAName.11 = STRING: "outlet 11"
// PWTv1-MIB::outletCfgPduADelayOnStatus.11 = INTEGER: nodelay(1)
// PWTv1-MIB::outletCfgPduADelayOnTime.11 = INTEGER: 11 seconds
// PWTv1-MIB::outletCfgPduADelayOffStatus.11 = INTEGER: nodelay(1)
// PWTv1-MIB::outletCfgPduADelayOffTime.11 = INTEGER: 11 seconds
// PWTv1-MIB::outletCfgPduAReboot.11 = INTEGER: 5 seconds
// PWTv1-MIB::outletCfgPduAOverCurrCritical.11 = INTEGER: 160 0.1A
// PWTv1-MIB::outletCfgPduAOverCurrWarning.11 = INTEGER: 130 0.1A
// PWTv1-MIB::outletCfgPduAOverPwrCritical.11 = INTEGER: 2500 1W
// PWTv1-MIB::outletCfgPduAOverPwrWarning.11 = INTEGER: 2000 1W
// PWTv1-MIB::outletCtlPduAIndex.11 = INTEGER: 10
// PWTv1-MIB::outletCtlPduAControl.11 = INTEGER: nothing(1)
foreach ([ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' ] as $char) {
if ($outlet_count = snmp_get_oid($device, "pduPwrMonitoringOutletNumPdu{$char}.0", 'PWTv1-MIB')) {
$oids = snmpwalk_cache_oid($device, 'pduPwrMonitoringOutletStatusTablePdu'.$char, [], 'PWTv1-MIB');
$oids = snmpwalk_cache_oid($device, 'pduPwrMonitoringOutletCfgTablePdu'.$char, $oids, 'PWTv1-MIB');
$name = "Pdu $char";
foreach ($oids as $index => $entry) {
// PDU reports all outlets as "normal" status, but really only as in count
if ($index > $outlet_count) { break; }
$descr = "Outlet $index State ($name)";
$oid_name = "outletPdu{$char}State";
$oid_num = snmp_translate($oid_name, $mib).".$index";
$value = $entry[$oid_name];
$options = [];
discover_status_ng($device, $mib, $oid_name, $oid_num, $index, 'outletPduState', $descr, $value, $options);
$descr = "Outlet $index ($name)";
$oid_name = "outletPdu{$char}Current";
$oid_num = snmp_translate($oid_name, $mib).".$index";
$value = $entry[$oid_name];
$scale = 0.01;
$options = [
'limit_high' => $entry["outletCfgPdu{$char}OverCurrCritical"] * 0.1,
'limit_high_warn' => $entry["outletCfgPdu{$char}OverCurrWarning"] * 0.1
];
discover_sensor_ng($device, 'current', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options);
$descr = "Outlet $index ($name)";
$oid_name = "outletPdu{$char}Power";
$oid_num = snmp_translate($oid_name, $mib).".$index";
$value = $entry[$oid_name];
$scale = 0.1;
$options = [
'limit_high' => $entry["outletCfgPdu{$char}OverPwrCritical"],
'limit_high_warn' => $entry["outletCfgPdu{$char}OverPwrWarning"]
];
discover_sensor_ng($device, 'power', $mib, $oid_name, $oid_num, $index, NULL, $descr, $scale, $value, $options);
$descr = "Outlet $index ($name)";
$oid_name = "outletPdu{$char}Energy";
$oid_num = snmp_translate($oid_name, $mib).".$index";
$value = $entry[$oid_name];
$scale = 1000;
$options = [];
if ($value > 0) {
discover_counter($device, 'energy', $mib, $oid_name, $oid_num, $index, $descr, $scale, $value, $options);
}
$descr = "Outlet $index ($name)";
$oid_name = "outletPdu{$char}Status";
$oid_num = snmp_translate($oid_name, $mib).".$index";
$value = $entry[$oid_name];
$options = [];
discover_status_ng($device, $mib, $oid_name, $oid_num, $index, 'inletStatus', $descr, $value, $options);
}
}
}
unset($inlet_count, $phase_count, $oids, $outlet_count);
// EOF

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -91,7 +91,7 @@ foreach ($physicalConnectorEntry as $ifIndex => $entry)
//print_debug_vars($options);
$name = $options['port_label'];
$name_ext = " (${entry['portMfgName']} ${entry['portVendorPartNo']} ${entry['physicalConnectorString']})";
$name_ext = " ({$entry['portMfgName']} {$entry['portVendorPartNo']} {$entry['physicalConnectorString']})";
// Temperature
$descr = $name . ' Temperature' . $name_ext;

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -43,10 +43,10 @@ $temp_unit = snmp_get_oid($device, 'cmcIIISetTempUnit.0', $mib);
//RITTAL-CMC-III-MIB::cmcIIIVarName.1.26 = STRING: Input 2.Delay
//RITTAL-CMC-III-MIB::cmcIIIVarName.1.27 = STRING: Input 2.Status
//RITTAL-CMC-III-MIB::cmcIIIVarName.1.28 = STRING: Input 2.Category
$oids = snmpwalk_cache_oid($device, "cmcIIIVarTable", array(), $mib);
$oids = snmpwalk_cache_oid($device, "cmcIIIVarTable", [], $mib);
//print_debug_vars($oids);
$device_oids = snmpwalk_cache_oid($device, "cmcIIIDevTable", array(), $mib);
$device_oids = snmpwalk_cache_oid($device, "cmcIIIDevTable", [], $mib);
print_debug_vars($device_oids);
$device_names = [];
@ -68,7 +68,7 @@ foreach ($device_oids as $index => $entry) {
}
// Rearrage this dumb array as more logic
$device_sensors = array();
$device_sensors = [];
foreach ($oids as $index => $entry) {
$device_index = explode('.', $index)[0];
@ -96,8 +96,8 @@ foreach($device_sensors as $device_index => $sensors) {
}
if (strlen($sensor['description']['cmcIIIVarValueStr'])) {
$tmp = str_replace(array( '_', 'Sys ' ),
array( ' ', 'System ' ), $sensor['description']['cmcIIIVarValueStr']);
$tmp = str_replace([ '_', 'Sys ' ],
[ ' ', 'System ' ], $sensor['description']['cmcIIIVarValueStr']);
if (!str_contains_array($name, $tmp)) {
$descr .= ' - ' . $sensor['description']['cmcIIIVarValueStr'];
}
@ -115,7 +115,6 @@ foreach($device_sensors as $device_index => $sensors) {
$oid_num = '.1.3.6.1.4.1.2606.7.4.2.2.1.11.' . $index;
if ($datatype === 'enum') {
//discover_status($device, $oid_num, "$oid_name.$index", 'cmcIIIMsgStatus', $descr, $value, array( 'entPhysicalClass' => 'other' ));
discover_status_ng($device, $mib, $oid_name, $oid_num, $index, 'cmcIIIMsgStatus', $descr, $value, [ 'entPhysicalClass' => 'other' ]);
}
@ -149,7 +148,7 @@ foreach($device_sensors as $device_index => $sensors) {
$value = $entry['cmcIIIVarValueInt'];
$oid_num = '.1.3.6.1.4.1.2606.7.4.2.2.1.11.' . $index;
$options = array();
$options = [];
/*
if ($type == 'outputPWM')
{
@ -174,7 +173,7 @@ foreach($device_sensors as $device_index => $sensors) {
} elseif (str_ends($unit, 'V')) {
$type = "voltage";
} elseif ($unit === "%") {
if (str_icontains_array($name, [ 'RPM', ' Fan', 'Valve' ]) || str_iends($entry['cmcIIIVarName'], 'Rpm')) {
if (str_icontains_array($descr, [ 'RPM', ' Fan', 'Valve', 'Airflow' ]) || str_iends($entry['cmcIIIVarName'], 'Rpm')) {
$type = "load";
} elseif (str_icontains_array($name, 'Humidity')) {
$type = "humidity";

View File

@ -0,0 +1,84 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
$scale = 1; // Start at 1 for 2 digits setting.
//$scale = 0.01;
$oids = snmpwalk_cache_oid($device, "digital", [], "ROOMALERT12S-MIB");
$index = 0;
$i = 1;
//for ($i = 1; $i <= 2; $i++) {
if (isset($oids[$index]["digital-sen$i-1"])) {
$name = "External Digital Sensor";
// Sensor is present.
if (!isset($oids[$index]["digital-sen$i-3"])) {
// Temp sensor
$descr = "$name: Temperature";
$oid = ".1.3.6.1.4.1.20916.1.12.1.2.$i.1.$index";
$value = $oids[$index]["digital-sen$i-1"];
if ($value > 100) { $scale = 0.01; }
discover_sensor_ng($device, 'temperature', $mib, "digital-sen$i-1", $oid, $index, NULL, $descr, $scale, $value);
} elseif (isset($oids[$index]["digital-sen$i-5"])) {
// Temp/Humidity sensor
$descr = "$name: Temperature";
$oid = ".1.3.6.1.4.1.20916.1.12.1.2.$i.1.$index";
$value = $oids[$index]["digital-sen$i-1"];
if ($value > 100) { $scale = 0.01; }
discover_sensor_ng($device, 'temperature', $mib, "digital-sen$i-1", $oid, $index, NULL, $descr, $scale, $value);
$descr = "$name: Heat index";
$oid = ".1.3.6.1.4.1.20916.1.12.1.2.$i.5.$index";
$value = $oids[$index]["digital-sen$i-5"];
discover_sensor_ng($device, 'temperature', $mib, "digital-sen$i-5", $oid, $index, NULL, $descr, $scale, $value);
$descr = "$name: Humidity";
$oid = ".1.3.6.1.4.1.20916.1.12.1.2.$i.3.$index";
$value = $oids[$index]["digital-sen$i-3"];
discover_sensor_ng($device, 'humidity', $mib, "digital-sen$i-3", $oid, $index, NULL, $descr, $scale, $value);
$descr = "$name: Dew Point";
$oid = ".1.3.6.1.4.1.20916.1.12.1.2.$i.6.$index";
$value = $oids[$index]["digital-sen$i-6"];
discover_sensor_ng($device, 'dewpoint', $mib, "digital-sen$i-6", $oid, $index, NULL, $descr, $scale, $value);
} else {
// Power sensor
$descr = "Channel $i: Current";
$oid = ".1.3.6.1.4.1.20916.1.12.1.2.$i.1.$index";
$value = $oids[$index]["digital-sen$i-1"];
discover_sensor('current', $device, $oid, "digital-sen$i-1.$index", 'roomalert', $descr, $scale, $value);
$descr = "Channel $i: Power";
$oid = ".1.3.6.1.4.1.20916.1.12.1.2.$i.2.$index";
$value = $oids[$index]["digital-sen$i-2"];
discover_sensor('power', $device, $oid, "digital-sen$i-2.$index", 'roomalert', $descr, $scale, $value);
$descr = "Channel $i: Voltage";
$oid = ".1.3.6.1.4.1.20916.1.12.1.2.$i.3.$index";
$value = $oids[$index]["digital-sen$i-3"];
discover_sensor('voltage', $device, $oid, "digital-sen$i-3.$index", 'roomalert', $descr, $scale, $value);
$descr = "Channel $i: Reference voltage";
$oid = ".1.3.6.1.4.1.20916.1.12.1.2.$i.4.$index";
$value = $oids[$index]["digital-sen$i-4"];
discover_sensor('voltage', $device, $oid, "digital-sen$i-4.$index", 'roomalert', $descr, $scale, $value);
}
}
//}
// EOF

View File

@ -77,13 +77,14 @@ for ($i = 1; $i <= 4; $i++) {
discover_status($device, $oid, 'relay'.$i.'State.0', 'teracom-relay-state', $descr, $value, array('entPhysicalClass' => 'other'));
}
// Status FIXME definition-based
/* Status FIXME definition-based
$value = snmp_get_oid($device, 'hardwareErr.0', $mib);
if (!safe_empty($value)) {
$descr = 'Status';
$oid = '.1.3.6.1.4.1.38783.1.3.8.0';
discover_status($device, $oid, 'hardwareErr.0', 'teracom-alarm-state', $descr, $value, array('entPhysicalClass' => 'other'));
}
*/
unset($data, $oid, $descr, $limits, $value);

View File

@ -0,0 +1,144 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// Teracom MIBs are stupid
// TERACOM-TCW241-MIB::temperatureUnit.0 = INTEGER: celcius(0)
$temp_unit = snmp_get_oid($device, 'temperatureUnit.0', $mib);
$flags = OBS_QUOTES_TRIM | OBS_SNMP_DISPLAY_HINT; // disable use display-hint, for correct scales
$invalid = [ '0', '-2147483648' ];
// 1-Wire sensors
for ($i = 1; $i <= 8; $i++) {
// TERACOM-TCW241-MIB::s1description.0 = STRING: S1:TSH2xx
// TERACOM-TCW241-MIB::s11MAXInt.0 = INTEGER: 85.000
// TERACOM-TCW241-MIB::s11MINInt.0 = INTEGER: -40.000
// TERACOM-TCW241-MIB::s11HYSTInt.0 = INTEGER: 8.500
// TERACOM-TCW241-MIB::s12MAXInt.0 = INTEGER: 100.000
// TERACOM-TCW241-MIB::s12MINInt.0 = INTEGER: .000
// TERACOM-TCW241-MIB::s12HYSTInt.0 = INTEGER: 10.000
// TERACOM-TCW241-MIB::s11Int.0 = INTEGER: 17.875
// TERACOM-TCW241-MIB::s12Int.0 = INTEGER: 27.500
// TERACOM-TCW241-MIB::s1ID.0 = STRING: 01FBBC5A1800FF40
$oids = [
"s{$i}description.0", "s{$i}ID.0",
"s{$i}1Int.0", "s{$i}1MAXInt.0", "s{$i}1MINInt.0",
"s{$i}2Int.0", "s{$i}2MAXInt.0", "s{$i}2MINInt.0",
];
$data = snmp_get_multi_oid($device, $oids, [], $mib, NULL, $flags);
if ($data[0]['s'.$i.'ID'] === '0000000000000000') { continue; }
if (!in_array($data[0]["s{$i}1Int"], $invalid)) {
$descr = '#1 ' . $data[0]["s{$i}description"] . ' (' . $data[0]["s{$i}ID"] . ')';
$oid_num = ".1.3.6.1.4.1.38783.3.3.1.$i.1.0";
$oid_name = "s{$i}1Int";
$value = $data[0][$oid_name];
$scale = 0.001;
$options = [
'limit_low' => $data[0]["s{$i}1MINInt"] * $scale,
'limit_high' => $data[0]["s{$i}1MAXInt"] * $scale
];
if ($temp_unit === 'fahrenheit') {
$options['sensor_unit'] = 'F';
}
discover_sensor_ng($device, 'temperature', $mib, $oid_name, $oid_num, 0, NULL, $descr, $scale, $value, $options);
}
if (!in_array($data[0]["s{$i}2Int"], $invalid)) {
$descr = '#2 ' . $data[0]["s{$i}description"] . ' (' . $data[0]["s{$i}ID"] . ')';
$oid_num = ".1.3.6.1.4.1.38783.3.3.1.$i.2.0";
$oid_name = "s{$i}2Int";
$value = $data[0][$oid_name];
$scale = 0.001;
$options = [
'limit_low' => $data[0]["s{$i}2MINInt"] * $scale,
'limit_high' => $data[0]["s{$i}2MAXInt"] * $scale
];
if ($temp_unit === 'fahrenheit') {
$options['sensor_unit'] = 'F';
}
discover_sensor_ng($device, 'temperature', $mib, $oid_name, $oid_num, 0, NULL, $descr, $scale, $value, $options);
}
}
// Analog inputs
for ($i = 1; $i <= 4; $i++) {
$oids = [
"voltage{$i}description.0",
"voltage{$i}Int.0", "voltage{$i}max.0", "voltage{$i}min.0",
];
$data = snmp_get_multi_oid($device, $oids, [], $mib, NULL, $flags);
$descr = $data[0]["voltage{$i}description"];
switch(substr($descr, 0, 2)) {
case 'I ':
$type = 'current';
$descr = substr($descr, 2);
break;
case 'F ':
$type = 'frequency';
$descr = substr($descr, 2);
break;
case 'H ':
$type = 'humidity';
$descr = substr($descr, 2);
break;
default:
$type = 'voltage';
}
if (!in_array($data[0]["voltage{$i}Int"], $invalid)) {
$oid_num = ".1.3.6.1.4.1.38783.3.3.2.$i.0";
$oid_name = "voltage{$i}Int";
$value = $data[0][$oid_name];
$scale = 0.001;
$options = [
'limit_low' => $data[0]["voltage{$i}min"] * $scale,
'limit_high' => $data[0]["voltage{$i}max"] * $scale
];
discover_sensor_ng($device, $type, $mib, $oid_name, $oid_num, 0, NULL, $descr, $scale, $value, $options);
}
}
// Digital inputs
for ($i = 1; $i <= 4; $i++) {
$oids = [
"digitalInput{$i}description.0", "digitalInput{$i}State.0",
];
$data = snmp_get_multi_oid($device, $oids, [], $mib);
$descr = $data[0]["digitalInput{$i}description"];
$oid_num = ".1.3.6.1.4.1.38783.3.3.3.$i.0";
$oid_name = "digitalInput{$i}State";
$value = $data[0][$oid_name];
discover_status_ng($device, $mib, $oid_name, $oid_num, 0, 'teracom-digitalin-state', $descr, $value, [ 'entPhysicalClass' => 'other' ]);
}
// Relay outputs
for ($i = 1; $i <= 4; $i++) {
$oids = [
"relay{$i}description.0", "relay{$i}State.0",
];
$data = snmp_get_multi_oid($device, $oids, [], $mib);
$descr = $data[0]["relay{$i}description"];
$oid_num = ".1.3.6.1.4.1.38783.3.3.4.$i.1.0";
$oid_name = "relay{$i}State";
$value = $data[0][$oid_name];
discover_status_ng($device, $mib, $oid_name, $oid_num, 0, 'teracom-relay-state', $descr, $value, [ 'entPhysicalClass' => 'other' ]);
}
// EOF

View File

@ -273,7 +273,8 @@ if (safe_count($ups_array)) {
$oid_name = 'upsInputVoltage';
if (isset($entry[$oid_name]) &&
!discovery_check_if_type_exist([ 'voltage->TRIPPLITE-PRODUCTS-tlpUpsInputPhaseVoltage',
'voltage->HUAWEI-UPS-MIB-hwUpsInputVoltageA' ], 'sensor')) {
'voltage->HUAWEI-UPS-MIB-hwUpsInputVoltageA',
'voltage->CPS-MIB-upsAdvanceInputLineVoltage' ], 'sensor')) {
$oid = ".1.3.6.1.2.1.33.1.3.3.1.3.$index";
//discover_sensor('voltage', $device, $oid, "upsInputEntry.".$phase, 'ups-mib', $descr, 1, $entry[$oid_name]);
$options = [ 'rename_rrd' => 'ups-mib-upsInputEntry.'.$phase ];
@ -368,7 +369,8 @@ if (safe_count($ups_array)) {
$oid_name = 'upsOutputVoltage';
if (isset($entry[$oid_name]) && $entry[$oid_name] > 0 &&
!discovery_check_if_type_exist([ 'voltage->TRIPPLITE-PRODUCTS-tlpUpsOutputLineVoltage',
'voltage->HUAWEI-UPS-MIB-hwUpsOutputVoltageA' ], 'sensor')) {
'voltage->HUAWEI-UPS-MIB-hwUpsOutputVoltageA',
'voltage->CPS-MIB-upsAdvanceOutputVoltage' ], 'sensor')) {
$oid = ".1.3.6.1.2.1.33.1.4.4.1.2.$index";
//discover_sensor('voltage', $device, $oid, "upsOutputEntry.".$phase, 'ups-mib', $descr, 1, $entry['upsOutputVoltage']);
$options = [ 'rename_rrd' => 'ups-mib-upsOutputEntry.'.$phase ];
@ -382,7 +384,8 @@ if (safe_count($ups_array)) {
## Output current
$oid_name = 'upsOutputCurrent';
if (isset($entry[$oid_name]) && $ups_total[$oid_name] > 0 &&
!discovery_check_if_type_exist([ 'current->HUAWEI-UPS-MIB-hwUpsOutputCurrentA' ], 'sensor')) {
!discovery_check_if_type_exist([ 'current->HUAWEI-UPS-MIB-hwUpsOutputCurrentA',
'current->CPS-MIB-upsAdvanceOutputCurrent' ], 'sensor')) {
$oid = ".1.3.6.1.2.1.33.1.4.4.1.3.$index";
//discover_sensor('current', $device, $oid, "upsOutputEntry.".$phase, 'ups-mib', $descr, $scale_current, $entry['upsOutputCurrent']);
$options = [ 'rename_rrd' => 'ups-mib-upsOutputEntry.'.$phase ];
@ -392,7 +395,8 @@ if (safe_count($ups_array)) {
## Output power
$oid_name = 'upsOutputPower';
if (isset($entry[$oid_name]) && $ups_total[$oid_name] > 0 &&
!discovery_check_if_type_exist('power->HUAWEI-UPS-MIB-hwUpsOutputActivePowerA', 'sensor')) {
!discovery_check_if_type_exist([ 'power->HUAWEI-UPS-MIB-hwUpsOutputActivePowerA',
'power->CPS-MIB-upsAdvanceOutputPower' ], 'sensor')) {
$oid = ".1.3.6.1.2.1.33.1.4.4.1.4.$index";
//discover_sensor('power', $device, $oid, "upsOutputEntry.".$phase, 'ups-mib', $descr, 1, $entry['upsOutputPower']);
$options = [ 'rename_rrd' => 'ups-mib-upsOutputEntry.'.$phase ];
@ -403,7 +407,7 @@ if (safe_count($ups_array)) {
if (isset($entry[$oid_name]) &&
!discovery_check_if_type_exist('load->HUAWEI-UPS-MIB-hwUpsOutputLoadA', 'sensor')) {
$oid = ".1.3.6.1.2.1.33.1.4.4.1.5.$index";
//rename_rrd($device, "sensor-capacity-ups-mib-upsOutputPercentLoad.${phase}", "sensor-load-ups-mib-upsOutputPercentLoad.${phase}");
//rename_rrd($device, "sensor-capacity-ups-mib-upsOutputPercentLoad.{$phase}", "sensor-load-ups-mib-upsOutputPercentLoad.{$phase}");
//discover_sensor('load', $device, $oid, "upsOutputPercentLoad.$phase", 'ups-mib', $descr, 1, $entry['upsOutputPercentLoad']);
$options = [ 'rename_rrd' => 'ups-mib-upsOutputPercentLoad.'.$phase ];
discover_sensor_ng($device, 'load', $mib, $oid_name, $oid, $index, NULL, $descr, 1, $entry[$oid_name], $options);

View File

@ -6,11 +6,11 @@
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
$xups_array = array();
$xups_array = [];
$xups_array = snmpwalk_cache_oid($device, "xupsInput", $xups_array, "XUPS-MIB");
$xups_array = snmpwalk_cache_oid($device, "xupsOutput", $xups_array, "XUPS-MIB");
$xups_array = snmpwalk_cache_oid($device, "xupsBypass", $xups_array, "XUPS-MIB");
@ -27,14 +27,11 @@ $xups_array = snmpwalk_cache_oid($device, "xupsConfig", $xups_array, "XUPS-MIB")
$xups_base = $xups_array[0];
unset($xups_array[0]);
foreach ($xups_array as $index => $entry)
{
foreach ($xups_array as $index => $entry) {
// Input
if (isset($entry['xupsInputPhase']))
{
if (isset($entry['xupsInputPhase'])) {
$descr = "Input";
if ($xups_base['xupsInputNumPhases'] > 1)
{
if ($xups_base['xupsInputNumPhases'] > 1) {
$descr .= " Phase $index";
}
@ -43,12 +40,10 @@ foreach ($xups_array as $index => $entry)
$value = $entry['xupsInputVoltage'];
if ($value != 0 &&
!isset($valid['sensor']['voltage']['mge-ups'][100+$index]))
{
!isset($valid['sensor']['voltage']['mge-ups'][100+$index])) {
// Limits
$limits = [];
if ($xups_base['xupsConfigInputVoltage'])
{
if ($xups_base['xupsConfigInputVoltage']) {
$limits['limit_low'] = $xups_base['xupsConfigInputVoltage'] - 15;
$limits['limit_high'] = $xups_base['xupsConfigInputVoltage'] + 15;
}
@ -60,16 +55,14 @@ foreach ($xups_array as $index => $entry)
$value = $entry['xupsInputCurrent'];
if ($value != 0 && $value < 10000 && // xupsInputCurrent.1 = 136137420 ? really? You're nuts.
!isset($valid['sensor']['current']['mge-ups'][100+$index]))
{
!isset($valid['sensor']['current']['mge-ups'][100+$index])) {
discover_sensor('current', $device, $oid, "xupsInputEntry.".$index, 'xups', $descr, 1, $value);
}
## Input power
$oid = ".1.3.6.1.4.1.534.1.3.4.1.4.$index"; # XUPS-MIB::xupsInputWatts.$index
$value = $entry['xupsInputWatts'];
if ($value != 0)
{
if ($value != 0) {
discover_sensor('power', $device, $oid, "xupsInputEntry.".$index, 'xups', $descr, 1, $value);
}
}
@ -96,11 +89,9 @@ foreach ($xups_array as $index => $entry)
// XUPS-MIB::xupsOutputTotalVA.0 = INTEGER: 98 VA
// XUPS-MIB::xupsOutputAveragePowerFactor.0 = INTEGER: 33
// XUPS-MIB::xupsOutput.10.0 = INTEGER: 3
if (isset($entry['xupsOutputPhase']))
{
if (isset($entry['xupsOutputPhase'])) {
$descr = "Output";
if ($xups_base['xupsOutputNumPhases'] > 1)
{
if ($xups_base['xupsOutputNumPhases'] > 1) {
$descr .= " Phase $index";
}
@ -108,12 +99,10 @@ foreach ($xups_array as $index => $entry)
$oid = ".1.3.6.1.4.1.534.1.4.4.1.2.$index"; # XUPS-MIB::xupsOutputVoltage.$index
$value = $entry['xupsOutputVoltage'];
if ($value != 0 &&
!isset($valid['sensor']['voltage']['mge-ups'][$index]))
{
!isset($valid['sensor']['voltage']['mge-ups'][$index])) {
// Limits
$limits = [];
if ($xups_base['xupsConfigLowOutputVoltageLimit'] && $xups_base['xupsConfigHighOutputVoltageLimit'])
{
if ($xups_base['xupsConfigLowOutputVoltageLimit'] && $xups_base['xupsConfigHighOutputVoltageLimit']) {
$limits['limit_low'] = $xups_base['xupsConfigLowOutputVoltageLimit'];
$limits['limit_high'] = $xups_base['xupsConfigHighOutputVoltageLimit'];
}
@ -121,19 +110,15 @@ foreach ($xups_array as $index => $entry)
}
## Output current
if (!isset($valid['sensor']['current']['mge-ups'][$index]))
{
if (!isset($valid['sensor']['current']['mge-ups'][$index])) {
$options = [ 'rename_rrd' => 'xups-xupsOutputEntry.'.$index ];
if (isset($entry['xupsOutputCurrentHighPrecision']) && $entry['xupsOutputCurrentHighPrecision'] != 0)
{
if (isset($entry['xupsOutputCurrentHighPrecision']) && $entry['xupsOutputCurrentHighPrecision'] != 0) {
// Prefer High precision
$oid = ".1.3.6.1.4.1.534.1.4.4.1.7.$index";
$value = $entry['xupsOutputCurrentHighPrecision'];
$options['limit_auto'] = FALSE; // Not sure
discover_sensor_ng($device, 'current', 'XUPS-MIB', 'xupsOutputCurrentHighPrecision', $oid, $index, NULL, $descr, 0.1, $value, $options);
}
elseif ($entry['xupsOutputCurrent'] != 0)
{
} elseif ($entry['xupsOutputCurrent'] != 0) {
$oid = ".1.3.6.1.4.1.534.1.4.4.1.3.$index"; # XUPS-MIB::xupsOutputCurrent.$index
$value = $entry['xupsOutputCurrent'];
discover_sensor_ng($device, 'current', 'XUPS-MIB', 'xupsOutputCurrent', $oid, $index, NULL, $descr, 1, $value, $options);
@ -144,11 +129,9 @@ foreach ($xups_array as $index => $entry)
## Output power
$oid = ".1.3.6.1.4.1.534.1.4.4.1.4.$index"; # XUPS-MIB::xupsOutputWatts.$index
$value = $entry['xupsOutputWatts'];
if ($value != 0)
{
if ($value != 0) {
$limits = [];
if ($xups_base['xupsConfigOutputWatts'])
{
if ($xups_base['xupsConfigOutputWatts']) {
$limits['limit_high_warn'] = $xups_base['xupsConfigOutputWatts'] * 0.8;
$limits['limit_high'] = $xups_base['xupsConfigOutputWatts'] * 0.95;
}
@ -158,8 +141,7 @@ foreach ($xups_array as $index => $entry)
## Output Active power
$oid = ".1.3.6.1.4.1.534.1.4.4.1.9.$index"; # XUPS-MIB::xupsOutputVA.$index
$value = $entry['xupsOutputVA'];
if ($value != 0)
{
if ($value != 0) {
discover_sensor_ng($device, 'apower', 'XUPS-MIB', 'xupsOutputVA', $oid, $index, NULL, $descr, 1, $value);
}
}
@ -176,23 +158,19 @@ foreach ($xups_array as $index => $entry)
// XUPS-MIB::xupsBypassAverageVoltage.0 = INTEGER: 229 RMS Volts
// XUPS-MIB::xupsBypassAverageCurrent.0 = INTEGER: 0 RMS tenth of Amps
if (isset($entry['xupsBypassPhase']))
{
if (isset($entry['xupsBypassPhase'])) {
$descr = "Bypass";
if ($xups_base['xupsBypassNumPhases'] > 1)
{
if ($xups_base['xupsBypassNumPhases'] > 1) {
$descr .= " Phase $index";
}
## Bypass voltage
$oid = ".1.3.6.1.4.1.534.1.5.3.1.2.$index"; # XUPS-MIB::xupsBypassVoltage.$index
$value = $entry['xupsBypassVoltage'];
if ($value != 0)
{
if ($value != 0) {
discover_sensor('voltage', $device, $oid, "xupsBypassEntry." . $index, 'xups', $descr, 1, $value);
if (isset($entry['xupsBypassCurrentHighPrecision'])) // && $entry['xupsBypassCurrentHighPrecision'] != 0)
{
if (isset($entry['xupsBypassCurrentHighPrecision'])) { // && $entry['xupsBypassCurrentHighPrecision'] != 0)
$oid = ".1.3.6.1.4.1.534.1.5.3.1.5.$index";
$value = $entry['xupsBypassCurrentHighPrecision'];
discover_sensor_ng($device, 'current', 'XUPS-MIB', 'xupsBypassCurrentHighPrecision', $oid, $index, NULL, $descr, 0.1, $value);
@ -208,8 +186,7 @@ $oid = ".1.3.6.1.4.1.534.1.3.1.0"; # XUPS-MIB::xupsInputFrequency.0
$scale = 0.1;
$value = $entry['xupsInputFrequency'];
if ($value != 0 &&
!isset($valid['sensor']['frequency']['mge-ups'][101]))
{
!isset($valid['sensor']['frequency']['mge-ups'][101])) {
discover_sensor('frequency', $device, $oid, "xupsInputFrequency.0", 'xups', "Input", $scale, $value);
}
@ -217,8 +194,7 @@ if ($value != 0 &&
$oid = ".1.3.6.1.4.1.534.1.4.1.0"; # XUPS-MIB::xupsOutputLoad.0
$descr = "Output Load";
$value = $entry['xupsOutputLoad'];
if (!isset($valid['sensor']['load']['mge-ups']['mgoutputLoadPerPhase.1']))
{
if (!isset($valid['sensor']['load']['mge-ups']['mgoutputLoadPerPhase.1'])) {
$limits = [ 'limit_high_warn' => 80, 'limit_high' => 95 ];
discover_sensor('load', $device, $oid, "xupsOutputLoad.0", 'xups', $descr, 1, $value, $limits);
}
@ -227,11 +203,9 @@ if (!isset($valid['sensor']['load']['mge-ups']['mgoutputLoadPerPhase.1']))
$oid = ".1.3.6.1.4.1.534.1.4.2.0"; # XUPS-MIB::xupsOutputFrequency.0
$value = $entry['xupsOutputFrequency'];
if ($value != 0 &&
!isset($valid['sensor']['frequency']['mge-ups'][1]))
{
!isset($valid['sensor']['frequency']['mge-ups'][1])) {
$limits = [];
if ($xups_base['xupsConfigOutputFreq'])
{
if ($xups_base['xupsConfigOutputFreq']) {
$limits['limit_low'] = $xups_base['xupsConfigOutputFreq'] * 0.099; // 50 -> 49,5
$limits['limit_low_warn'] = $xups_base['xupsConfigOutputFreq'] * 0.0996; // 50 -> 49.8
$limits['limit_high_warn'] = $xups_base['xupsConfigOutputFreq'] * 0.1004; // 50 -> 50.2
@ -244,16 +218,14 @@ if ($value != 0 &&
$oid = ".1.3.6.1.4.1.534.1.4.9.5.0"; # XUPS-MIB::xupsOutputAveragePowerFactor.0
$descr = "Output Power Factor";
$value = $entry['xupsOutputAveragePowerFactor'];
if ($value != 0)
{
if ($value != 0) {
discover_sensor_ng($device, 'powerfactor', 'XUPS-MIB', 'xupsOutputAveragePowerFactor', $oid, 0, NULL, $descr, 1, $value);
}
## Bypass Frequency
$oid = ".1.3.6.1.4.1.534.1.5.1.0"; # XUPS-MIB::xupsBypassFrequency.0
$value = $entry['xupsBypassFrequency'];
if ($value != 0)
{
if ($value != 0) {
discover_sensor('frequency', $device, $oid, "xupsBypassFrequency.0", 'xups', "Bypass", $scale, $value);
}
@ -264,7 +236,7 @@ $oid_num = '.1.3.6.1.4.1.534.1.3.5.0';
$type = 'xupsInputSource';
$value = $entry[$oid_name];
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, array('entPhysicalClass' => 'other'));
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, [ 'entPhysicalClass' => 'other' ]);
// xupsOutputSource
$descr = 'Output Source';
@ -273,7 +245,7 @@ $oid_num = '.1.3.6.1.4.1.534.1.4.5.0';
$type = 'xupsOutputSource';
$value = $entry[$oid_name];
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, array('entPhysicalClass' => 'other'));
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, [ 'entPhysicalClass' => 'other' ]);
// XUPS-MIB::xupsBatTimeRemaining.0 = INTEGER: 31500 seconds
// XUPS-MIB::xupsBatVoltage.0 = INTEGER: 104 Volts DC
@ -290,17 +262,15 @@ discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value,
// XUPS-MIB::xupsEnvAmbientUpperLimit.0 = INTEGER: 40 degrees Centigrade
// XUPS-MIB::xupsEnvNumContacts.0 = INTEGER: 0
$xups_array = array();
$xups_array = [];
$xups_array = snmpwalk_cache_oid($device, "xupsBattery", $xups_array, "XUPS-MIB");
$xups_array = snmpwalk_cache_oid($device, "xupsEnvironment", $xups_array, "XUPS-MIB");
$entry = $xups_array[0];
if ($entry['xupsBatteryNotPresent'] !== 'yes')
{
if ($entry['xupsBatteryNotPresent'] !== 'yes') {
if (isset($entry['xupsBatTimeRemaining']) &&
!isset($valid['sensor']['runtime']['mge']['upsmgBatteryRemainingTime.0']))
{
!isset($valid['sensor']['runtime']['mge']['upsmgBatteryRemainingTime.0'])) {
$oid = ".1.3.6.1.4.1.534.1.2.1.0"; # XUPS-MIB::xupsBatTimeRemaining.0
$scale = 1/60;
$value = $entry['xupsBatTimeRemaining'];
@ -309,8 +279,7 @@ if ($entry['xupsBatteryNotPresent'] !== 'yes')
}
if (isset($entry['xupsBatCapacity']) &&
!isset($valid['sensor']['capacity']['mge']['upsmgBatteryLevel.0']))
{
!isset($valid['sensor']['capacity']['mge']['upsmgBatteryLevel.0'])) {
$oid = ".1.3.6.1.4.1.534.1.2.4.0"; # XUPS-MIB::xupsBatCapacity.0
$value = $entry['xupsBatCapacity'];
@ -318,8 +287,7 @@ if ($entry['xupsBatteryNotPresent'] !== 'yes')
}
if (isset($entry['xupsBatVoltage']) && $entry['xupsBatVoltage'] != 0 &&
!isset($valid['sensor']['voltage']['mge']['upsmgBatteryVoltage.0']))
{
!isset($valid['sensor']['voltage']['mge']['upsmgBatteryVoltage.0'])) {
$oid = ".1.3.6.1.4.1.534.1.2.2.0"; # XUPS-MIB::xupsBatVoltage.0
$value = $entry['xupsBatVoltage'];
@ -327,8 +295,7 @@ if ($entry['xupsBatteryNotPresent'] !== 'yes')
}
if (isset($entry['xupsBatCurrent']) &&
!isset($valid['sensor']['current']['mge']['upsmgBatteryCurrent.0']))
{
!isset($valid['sensor']['current']['mge']['upsmgBatteryCurrent.0'])) {
$oid = ".1.3.6.1.4.1.534.1.2.3.0"; # XUPS-MIB::xupsBatCurrent.0
$value = $entry['xupsBatCurrent'];
@ -342,7 +309,7 @@ if ($entry['xupsBatteryNotPresent'] !== 'yes')
$type = 'xupsBatteryAbmStatus';
$value = $entry[$oid_name];
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, array('entPhysicalClass' => 'battery'));
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, [ 'entPhysicalClass' => 'battery' ]);
// xupsBatteryFailure
$descr = 'Battery Failure';
@ -351,17 +318,17 @@ if ($entry['xupsBatteryNotPresent'] !== 'yes')
$type = 'xupsBatteryFailure';
$value = $entry[$oid_name];
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, array('entPhysicalClass' => 'battery'));
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, [ 'entPhysicalClass' => 'battery' ]);
// xupsBatteryAged
$age = $entry['xupsBatteryLastReplacedDate'];
$descr = "Battery over aged ($age)";
$oid_name = 'xupsBatteryAged';
$oid_num = '.1.3.6.1.4.1.534.1.2.9.0';
$type = 'xupsBatteryFailure';
$type = 'xupsBatteryWarning';
$value = $entry[$oid_name];
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, array('entPhysicalClass' => 'battery'));
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, [ 'entPhysicalClass' => 'battery' ]);
// xupsBatteryLowCapacity
$descr = 'Battery Low Capacity';
@ -370,7 +337,7 @@ if ($entry['xupsBatteryNotPresent'] !== 'yes')
$type = 'xupsBatteryFailure';
$value = $entry[$oid_name];
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, array('entPhysicalClass' => 'battery'));
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, [ 'entPhysicalClass' => 'battery' ]);
}
// xupsBatteryNotPresent
@ -380,18 +347,16 @@ $oid_num = '.1.3.6.1.4.1.534.1.2.8.0';
$type = 'xupsBatteryNotPresent';
$value = $entry[$oid_name];
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, array('entPhysicalClass' => 'battery'));
discover_status($device, $oid_num, $oid_name.'.'.$index, $type, $descr, $value, [ 'entPhysicalClass' => 'battery' ]);
if (isset($entry['xupsEnvAmbientTemp']))
{
if (isset($entry['xupsEnvAmbientTemp'])) {
$oid = ".1.3.6.1.4.1.534.1.6.1.0"; # XUPS-MIB:xupsEnvAmbientTemp.0
$value = $entry['xupsEnvAmbientTemp'];
$limits = array('limit_low' => $xups_array[0]['upsEnvAmbientLowerLimit'],
'limit_high' => $xups_array[0]['upsEnvAmbientUpperLimit']);
$limits = [ 'limit_low' => $xups_array[0]['upsEnvAmbientLowerLimit'],
'limit_high' => $xups_array[0]['upsEnvAmbientUpperLimit'] ];
if ($value != 0)
{
if ($value != 0) {
discover_sensor('temperature', $device, $oid, "xupsEnvAmbientTemp.0", 'xups', "Ambient", 1, $value, $limits);
}
}