diff --git a/doc/Developing/Sensor-State-Support.md b/doc/Developing/Sensor-State-Support.md index 03a3588eee..cd18dd9727 100644 --- a/doc/Developing/Sensor-State-Support.md +++ b/doc/Developing/Sensor-State-Support.md @@ -121,14 +121,14 @@ $oids = snmpwalk_group($device, 'ciscoEnvMonSupplyStatusTable', 'CISCO-ENVMON-MI if (!empty($oids)) { //Create State Index $state_name = 'ciscoEnvMonSupplyState'; - $states = array( - array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'normal'), - array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'warning'), - array('value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'critical'), - array('value' => 4, 'generic' => 3, 'graph' => 0, 'descr' => 'shutdown'), - array('value' => 5, 'generic' => 3, 'graph' => 0, 'descr' => 'notPresent'), - array('value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'notFunctioning'), - ); + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'normal'], + ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'warning'], + ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'critical'], + ['value' => 4, 'generic' => 3, 'graph' => 0, 'descr' => 'shutdown'], + ['value' => 5, 'generic' => 3, 'graph' => 0, 'descr' => 'notPresent'], + ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'notFunctioning'], + ]; create_state_index($state_name, $states); $num_oid = '.1.3.6.1.4.1.9.9.13.1.5.1.3.'; diff --git a/includes/discovery/sensors/ber/junos.inc.php b/includes/discovery/sensors/ber/junos.inc.php index c779df89e6..556a6ac18a 100644 --- a/includes/discovery/sensors/ber/junos.inc.php +++ b/includes/discovery/sensors/ber/junos.inc.php @@ -18,7 +18,7 @@ foreach ($pre_cache['junos_ifotn_oids'] as $index => $entry) { if (is_numeric($entry['jnxoptIfOTNPMCurrentFECBERMantissa'])) { $index = substr_replace($index, '', -2); $oid = '.1.3.6.1.4.1.2636.3.73.1.3.3.8.1.5.'.$index.'.1'; - $interface = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])); + $interface = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]); $descr = $interface . ' preFEC BER'; $limit_low = null; diff --git a/includes/discovery/sensors/charge/apc.inc.php b/includes/discovery/sensors/charge/apc.inc.php index 9a379633fc..7517ebb338 100644 --- a/includes/discovery/sensors/charge/apc.inc.php +++ b/includes/discovery/sensors/charge/apc.inc.php @@ -19,7 +19,7 @@ if (!empty($oids)) { $warnlimit = 10; $descr = 'Battery Charge'; - discover_sensor($valid['sensor'], 'charge', $device, $current_oid, $index, $sensorType, $descr, $precision, '1', $lowlimit, $warnlimit, null, $limit, $current_val); + discover_sensor($valid['sensor'], 'charge', $device, $current_oid, $index, $sensorType, $descr, $precision, 1, $lowlimit, $warnlimit, null, $limit, $current_val); } else { // Try to just get capacity $oids = snmp_get($device, '.1.3.6.1.4.1.318.1.1.1.2.2.1.0', '-OsqnU'); @@ -40,6 +40,6 @@ if (!empty($oids)) { $warnlimit = 10; $descr = 'Battery Charge'; - discover_sensor($valid['sensor'], 'charge', $device, $current_oid, $index, $sensorType, $descr, $precision, '1', $lowlimit, $warnlimit, null, $limit, $current_val); + discover_sensor($valid['sensor'], 'charge', $device, $current_oid, $index, $sensorType, $descr, $precision, 1, $lowlimit, $warnlimit, null, $limit, $current_val); } }//end if diff --git a/includes/discovery/sensors/charge/dsm.inc.php b/includes/discovery/sensors/charge/dsm.inc.php index b8a37164e6..5b25457d44 100644 --- a/includes/discovery/sensors/charge/dsm.inc.php +++ b/includes/discovery/sensors/charge/dsm.inc.php @@ -25,5 +25,5 @@ $ups_device_model = str_replace('"', '', snmp_get($device, $ups_device_model $ups_charge_oid = '.1.3.6.1.4.1.6574.4.3.1.1.0'; $ups_charge = snmp_get($device, $ups_charge_oid, '-Oqv'); if (is_numeric($ups_charge)) { - discover_sensor($valid['sensor'], 'charge', $device, $ups_charge_oid, 'UPSChargeValue', $ups_device_manufacturer.' '.$ups_device_model, 'UPS Charge Value', '1', '1', 0, 10, null, 100, $ups_charge); + discover_sensor($valid['sensor'], 'charge', $device, $ups_charge_oid, 'UPSChargeValue', $ups_device_manufacturer.' '.$ups_device_model, 'UPS Charge Value', 1, 1, 0, 10, null, 100, $ups_charge); } diff --git a/includes/discovery/sensors/charge/linux.inc.php b/includes/discovery/sensors/charge/linux.inc.php index c1a4899f8f..f3ccb554fd 100644 --- a/includes/discovery/sensors/charge/linux.inc.php +++ b/includes/discovery/sensors/charge/linux.inc.php @@ -11,7 +11,7 @@ if (preg_match("/(Linux).+(ntc)/", $device['sysDescr'])) { $index = '116.8'; $value = snmp_get($device, $oid.$index, '-Oqv'); if (is_numeric($value)) { - discover_sensor($valid['sensor'], 'charge', $device, $oid.$index, $index, $sensor_type, $descr, '1', '1', $lowlimit, $lowwarnlimit, $warnlimit, $limit, $value); + discover_sensor($valid['sensor'], 'charge', $device, $oid.$index, $index, $sensor_type, $descr, 1, 1, $lowlimit, $lowwarnlimit, $warnlimit, $limit, $value); } } diff --git a/includes/discovery/sensors/cisco-entity-sensor.inc.php b/includes/discovery/sensors/cisco-entity-sensor.inc.php index 8a5fa50f7a..965d01246d 100644 --- a/includes/discovery/sensors/cisco-entity-sensor.inc.php +++ b/includes/discovery/sensors/cisco-entity-sensor.inc.php @@ -3,12 +3,12 @@ if ($device['os_group'] == 'cisco') { echo ' CISCO-ENTITY-SENSOR: '; - $oids = array(); + $oids = []; echo 'Caching OIDs:'; if (empty($entity_array)) { - $tmp_oids = array('entPhysicalDescr', 'entPhysicalName', 'entPhysicalClass', 'entPhysicalContainedIn', 'entPhysicalParentRelPos'); - $entity_array = array(); + $tmp_oids = ['entPhysicalDescr', 'entPhysicalName', 'entPhysicalClass', 'entPhysicalContainedIn', 'entPhysicalParentRelPos']; + $entity_array = []; foreach ($tmp_oids as $tmp_oid) { echo " $tmp_oid"; $entity_array = snmpwalk_cache_multi_oid($device, $tmp_oid, $entity_array, 'ENTITY-MIB:CISCO-ENTITY-SENSOR-MIB'); @@ -28,7 +28,7 @@ if ($device['os_group'] == 'cisco') { echo ' entSensorPrecision'; $oids = snmpwalk_cache_multi_oid($device, 'entSensorPrecision', $oids, 'CISCO-ENTITY-SENSOR-MIB'); - $t_oids = array(); + $t_oids = []; echo ' entSensorThresholdSeverity'; $t_oids = snmpwalk_cache_twopart_oid($device, 'entSensorThresholdSeverity', $t_oids, 'CISCO-ENTITY-SENSOR-MIB'); echo ' entSensorThresholdRelation'; diff --git a/includes/discovery/sensors/current/adva_fsp150.inc.php b/includes/discovery/sensors/current/adva_fsp150.inc.php index 37271dd264..ce3e098829 100644 --- a/includes/discovery/sensors/current/adva_fsp150.inc.php +++ b/includes/discovery/sensors/current/adva_fsp150.inc.php @@ -21,12 +21,12 @@ // ****************************************** // Define Sensors and Limits - $sensors_adva = array - ( - array( - 'sensor_name' => 'psuOutputCurrent', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.4.1.8') - ); + $sensors_adva = [ + [ + 'sensor_name' => 'psuOutputCurrent', + 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.4.1.8' + ] + ]; $multiplier = 1; $divisor = 1000; diff --git a/includes/discovery/sensors/current/comware.inc.php b/includes/discovery/sensors/current/comware.inc.php index dde2fb6d59..d71590bc67 100644 --- a/includes/discovery/sensors/current/comware.inc.php +++ b/includes/discovery/sensors/current/comware.inc.php @@ -18,10 +18,10 @@ $divisor_alarm = 1000000; foreach ($pre_cache['comware_oids'] as $index => $entry) { if (is_numeric($entry['hh3cTransceiverBiasCurrent']) && $entry['hh3cTransceiverBiasCurrent'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { $oid = '.1.3.6.1.4.1.25506.2.70.1.1.1.17.' . $index; - $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array( + $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", [ $index, $device['device_id'] - )); + ]); $limit_low = $entry['hh3cTransceiverBiasLoAlarm'] / $divisor_alarm; $warn_limit_low = $entry['hh3cTransceiverBiasLoWarn'] / $divisor_alarm; $limit = $entry['hh3cTransceiverBiasHiAlarm'] / $divisor_alarm; diff --git a/includes/discovery/sensors/current/digipower.inc.php b/includes/discovery/sensors/current/digipower.inc.php index 5faccfbabe..12cee5daef 100644 --- a/includes/discovery/sensors/current/digipower.inc.php +++ b/includes/discovery/sensors/current/digipower.inc.php @@ -11,5 +11,5 @@ if ($oids) { $type = 'digipower'; $descr = 'Input'; $current=$current/10; - discover_sensor($valid['sensor'], 'current', $device, $oid, '0', $type, $descr, $divisor, '1', null, null, null, null, $current); + discover_sensor($valid['sensor'], 'current', $device, $oid, 0, $type, $descr, $divisor, 1, null, null, null, null, $current); } diff --git a/includes/discovery/sensors/current/eatonpdu.inc.php b/includes/discovery/sensors/current/eatonpdu.inc.php index c46e728738..ff238f21cc 100644 --- a/includes/discovery/sensors/current/eatonpdu.inc.php +++ b/includes/discovery/sensors/current/eatonpdu.inc.php @@ -10,8 +10,8 @@ * the source code distribution for details. */ -$data = snmpwalk_cache_multi_oid($device, 'outletCurrent', array(), 'EATON-EPDU-MIB'); -$descr = snmpwalk_cache_multi_oid($device, 'outletName', array(), 'EATON-EPDU-MIB'); +$data = snmpwalk_cache_multi_oid($device, 'outletCurrent', [], 'EATON-EPDU-MIB'); +$descr = snmpwalk_cache_multi_oid($device, 'outletName', [], 'EATON-EPDU-MIB'); if (is_array($data)) { $cur_oid = '.1.3.6.1.4.1.534.6.6.7.6.4.1.3.'; foreach ($data as $index => $entry) { diff --git a/includes/discovery/sensors/current/eatonups.inc.php b/includes/discovery/sensors/current/eatonups.inc.php index 4de344a0d9..f2f829f8ea 100644 --- a/includes/discovery/sensors/current/eatonups.inc.php +++ b/includes/discovery/sensors/current/eatonups.inc.php @@ -2,7 +2,7 @@ echo 'XUPS-MIB '; -$oids = snmpwalk_cache_oid($device, 'xupsBatCurrent', array(), 'XUPS-MIB'); +$oids = snmpwalk_cache_oid($device, 'xupsBatCurrent', [], 'XUPS-MIB'); foreach ($oids as $current_id => $data) { $current_oid = ".1.3.6.1.4.1.534.1.2.3.$current_id"; @@ -15,7 +15,7 @@ foreach ($oids as $current_id => $data) { discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); } -$oids = snmpwalk_cache_oid($device, 'xupsOutputCurrent', array(), 'XUPS-MIB'); +$oids = snmpwalk_cache_oid($device, 'xupsOutputCurrent', [], 'XUPS-MIB'); foreach ($oids as $current_id => $data) { $current_oid = ".1.3.6.1.4.1.534.1.4.4.1.3.$current_id"; @@ -31,7 +31,7 @@ foreach ($oids as $current_id => $data) { discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); } -$oids = snmpwalk_cache_oid($device, 'xupsInputCurrent', array(), 'XUPS-MIB'); +$oids = snmpwalk_cache_oid($device, 'xupsInputCurrent', [], 'XUPS-MIB'); foreach ($oids as $current_id => $data) { $current_oid = ".1.3.6.1.4.1.534.1.3.4.1.3.$current_id"; diff --git a/includes/discovery/sensors/current/ict-pdu.inc.php b/includes/discovery/sensors/current/ict-pdu.inc.php index a8a9d05d95..e181287ca0 100644 --- a/includes/discovery/sensors/current/ict-pdu.inc.php +++ b/includes/discovery/sensors/current/ict-pdu.inc.php @@ -24,7 +24,7 @@ */ // Output Current -$oids = snmpwalk_cache_oid($device, 'outputEntry', array(), 'ICT-DISTRIBUTION-PANEL-MIB'); +$oids = snmpwalk_cache_oid($device, 'outputEntry', [], 'ICT-DISTRIBUTION-PANEL-MIB'); foreach ($oids as $index => $entry) { $output_number = (int)$entry['outputNumber'] + 1; diff --git a/includes/discovery/sensors/current/ipoman.inc.php b/includes/discovery/sensors/current/ipoman.inc.php index 53d60c4f97..6353e8fdc0 100644 --- a/includes/discovery/sensors/current/ipoman.inc.php +++ b/includes/discovery/sensors/current/ipoman.inc.php @@ -2,8 +2,8 @@ echo ' IPOMANII-MIB '; -$oids_in = array(); -$oids_out = array(); +$oids_in = []; +$oids_out = []; d_echo('inletConfigCurrentHigh '); $oids_in = snmpwalk_cache_multi_oid($device, 'inletConfigCurrentHigh', $oids_in, 'IPOMANII-MIB'); diff --git a/includes/discovery/sensors/current/junos.inc.php b/includes/discovery/sensors/current/junos.inc.php index f5edc21139..b361cd48e2 100644 --- a/includes/discovery/sensors/current/junos.inc.php +++ b/includes/discovery/sensors/current/junos.inc.php @@ -17,7 +17,7 @@ $divisor = 1000000; foreach ($pre_cache['junos_oids'] as $index => $entry) { if (is_numeric($entry['jnxDomCurrentTxLaserBiasCurrent']) && $entry['jnxDomCurrentTxLaserBiasCurrent'] != 0 && $entry['jnxDomCurrentTxLaserBiasCurrentLowAlarmThreshold'] != 0) { $oid = '.1.3.6.1.4.1.2636.3.60.1.1.1.1.6.' . $index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Tx Current'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Tx Current'; $limit_low = $entry['jnxDomCurrentTxLaserBiasCurrentLowAlarmThreshold'] / $divisor; $warn_limit_low = $entry['jnxDomCurrentTxLaserBiasCurrentLowWarningThreshold'] / $divisor; $limit = $entry['jnxDomCurrentTxLaserBiasCurrentHighAlarmThreshold'] / $divisor; diff --git a/includes/discovery/sensors/current/pbn.inc.php b/includes/discovery/sensors/current/pbn.inc.php index 8d3715f843..528ee37f06 100644 --- a/includes/discovery/sensors/current/pbn.inc.php +++ b/includes/discovery/sensors/current/pbn.inc.php @@ -16,7 +16,7 @@ $divisor = 1000000; foreach ($pre_cache['pbn_oids'] as $index => $entry) { if (is_numeric($entry['curr']) && ($entry['curr'] !== '-65535')) { $oid = '.1.3.6.1.4.1.11606.10.9.63.1.7.1.6.'.$index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Current'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Current'; $limit_low = 8000/$divisor; $warn_limit_low = 8500/$divisor; $limit = 15000/$divisor; diff --git a/includes/discovery/sensors/current/procurve.inc.php b/includes/discovery/sensors/current/procurve.inc.php index 72fef63733..4be210fa1a 100644 --- a/includes/discovery/sensors/current/procurve.inc.php +++ b/includes/discovery/sensors/current/procurve.inc.php @@ -5,10 +5,7 @@ $divisor_alarm = 1000000; foreach ($pre_cache['procurve_hpicfXcvrInfoTable'] as $index => $entry) { if (is_numeric($entry['hpicfXcvrBias']) && $entry['hpicfXcvrBias'] != 0) { $oid = '.1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.13.' . $index; - $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array( - $index, - $device['device_id'] - )); + $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", [$index, $device['device_id']]); $limit_low = $entry['hpicfXcvrBiasLoAlarm'] / $divisor_alarm; $warn_limit_low = $entry['hpicfXcvrBiasLoWarn'] / $divisor_alarm; $limit = $entry['hpicfXcvrBiasHiAlarm'] / $divisor_alarm; diff --git a/includes/discovery/sensors/current/sinetica.inc.php b/includes/discovery/sensors/current/sinetica.inc.php index ed94e8a6b0..0b63f0acb1 100644 --- a/includes/discovery/sensors/current/sinetica.inc.php +++ b/includes/discovery/sensors/current/sinetica.inc.php @@ -36,7 +36,7 @@ if (!empty($battery_current) || $battery_current == 0) { discover_sensor($valid['sensor'], 'current', $device, $battery_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); } -$oids = snmpwalk_cache_oid_num($device, '.1.3.6.1.4.1.13891.101.4.4.1.3', array()); +$oids = snmpwalk_cache_oid_num($device, '.1.3.6.1.4.1.13891.101.4.4.1.3', []); foreach ($oids as $oid => $data) { $current_id = substr($oid, strrpos($oid, '.') + 1); @@ -54,7 +54,7 @@ foreach ($oids as $oid => $data) { discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); } -$oids = snmpwalk_cache_oid_num($device, '.1.3.6.1.4.1.13891.101.3.3.1.4', array()); +$oids = snmpwalk_cache_oid_num($device, '.1.3.6.1.4.1.13891.101.3.3.1.4', []); foreach ($oids as $oid => $data) { $current_id = substr($oid, strrpos($oid, '.') + 1); diff --git a/includes/discovery/sensors/current/tpdin.inc.php b/includes/discovery/sensors/current/tpdin.inc.php index 4d479a6110..377a94d4ba 100644 --- a/includes/discovery/sensors/current/tpdin.inc.php +++ b/includes/discovery/sensors/current/tpdin.inc.php @@ -23,32 +23,32 @@ * @author Neil Lathwood */ -$tpdin_oids = array( - array( +$tpdin_oids = [ + [ 'oid' => '.1.3.6.1.4.1.45621.2.2.9.0', 'index' => 'current1', 'descr' => 'Current 1', 'current' => $pre_cache['tpdin_monitor'][0]['current1'], - ), - array( + ], + [ 'oid' => '.1.3.6.1.4.1.45621.2.2.10.0', 'index' => 'current2', 'descr' => 'Current 2', 'current' => $pre_cache['tpdin_monitor'][0]['current2'], - ), - array( + ], + [ 'oid' => '.1.3.6.1.4.1.45621.2.2.11.0', 'index' => 'current3', 'descr' => 'Current 3', 'current' => $pre_cache['tpdin_monitor'][0]['current3'], - ), - array( + ], + [ 'oid' => '.1.3.6.1.4.1.45621.2.2.12.0', 'index' => 'current4', 'descr' => 'Current 4', 'current' => $pre_cache['tpdin_monitor'][0]['current4'], - ), -); + ], +]; foreach ($tpdin_oids as $data) { if ($data['current'] > 0) { diff --git a/includes/discovery/sensors/dbm/comware.inc.php b/includes/discovery/sensors/dbm/comware.inc.php index 768ea6fdd7..0cffcd7114 100644 --- a/includes/discovery/sensors/dbm/comware.inc.php +++ b/includes/discovery/sensors/dbm/comware.inc.php @@ -17,10 +17,7 @@ $divisor = 100; foreach ($pre_cache['comware_oids'] as $index => $entry) { if (is_numeric($entry['hh3cTransceiverCurRXPower']) && $entry['hh3cTransceiverCurRXPower'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { $oid = '.1.3.6.1.4.1.25506.2.70.1.1.1.12.' . $index; - $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array( - $index, - $device['device_id'] - )); + $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", [$index, $device['device_id']]); $limit_low = round(uw_to_dbm($entry['hh3cTransceiverRcvPwrLoAlarm'] / 10), 2); $warn_limit_low = round(uw_to_dbm($entry['hh3cTransceiverRcvPwrLoWarn'] / 10), 2); $limit = round(uw_to_dbm($entry['hh3cTransceiverRcvPwrHiAlarm'] / 10), 2); @@ -36,10 +33,7 @@ foreach ($pre_cache['comware_oids'] as $index => $entry) { if (is_numeric($entry['hh3cTransceiverCurTXPower']) && $entry['hh3cTransceiverCurTXPower'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { $oid = '.1.3.6.1.4.1.25506.2.70.1.1.1.9.' . $index; - $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array( - $index, - $device['device_id'] - )); + $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", [$index, $device['device_id']]); $limit_low = round(uw_to_dbm($entry['hh3cTransceiverPwrOutLoAlarm'] / 10), 2); $warn_limit_low = round(uw_to_dbm($entry['hh3cTransceiverPwrOutLoWarn'] / 10), 2); $limit = round(uw_to_dbm($entry['hh3cTransceiverPwrOutHiAlarm'] / 10), 2); diff --git a/includes/discovery/sensors/dbm/datacom.inc.php b/includes/discovery/sensors/dbm/datacom.inc.php index da2ae945e5..62527d27c5 100644 --- a/includes/discovery/sensors/dbm/datacom.inc.php +++ b/includes/discovery/sensors/dbm/datacom.inc.php @@ -7,7 +7,7 @@ $divisor = 100; foreach ($pre_cache['datacom_oids'] as $index => $entry) { if (is_numeric(str_replace('dBm', '', $entry['ddTransceiversRxPower']))) { $oid = '.1.3.6.1.4.1.3709.3.5.201.1.28.1.1.4.' . $index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Rx Power'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Rx Power'; /* Basic default values */ $limit_low = -30; $warn_limit_low = -12.3; @@ -21,7 +21,7 @@ foreach ($pre_cache['datacom_oids'] as $index => $entry) { if (is_numeric(str_replace('dBm', '', $entry['ddTransceiversTxPower']))) { $oid = '.1.3.6.1.4.1.3709.3.5.201.1.28.1.1.5.' . $index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Tx Power'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Tx Power'; /* Basic default values */ $limit_low = -30; $warn_limit_low = -12.3; diff --git a/includes/discovery/sensors/dbm/ironware.inc.php b/includes/discovery/sensors/dbm/ironware.inc.php index 78aaa997ad..1a151436ea 100644 --- a/includes/discovery/sensors/dbm/ironware.inc.php +++ b/includes/discovery/sensors/dbm/ironware.inc.php @@ -22,7 +22,7 @@ foreach ($pre_cache['ironware_optic_oids'] as $index => $entry) { if (strpos($entry['snIfOpticalMonitoringRxPower'], 'N\/A') !== true) { return_num($entry); $oid = '.1.3.6.1.4.1.1991.1.1.3.3.6.1.3.' . $index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Rx Power'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Rx Power'; discover_sensor( $valid['sensor'], 'dbm', @@ -47,7 +47,7 @@ foreach ($pre_cache['ironware_optic_oids'] as $index => $entry) { if (strpos($entry['snIfOpticalMonitoringTxPower'], 'N\/A') !== true) { return_num($entry); $oid = '.1.3.6.1.4.1.1991.1.1.3.3.6.1.2.' . $index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Tx Power'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Tx Power'; discover_sensor( $valid['sensor'], 'dbm', diff --git a/includes/discovery/sensors/dbm/junos.inc.php b/includes/discovery/sensors/dbm/junos.inc.php index 4fd220a8ba..55fd42fc03 100644 --- a/includes/discovery/sensors/dbm/junos.inc.php +++ b/includes/discovery/sensors/dbm/junos.inc.php @@ -17,7 +17,7 @@ $divisor = 100; foreach ($pre_cache['junos_oids'] as $index => $entry) { if (is_numeric($entry['jnxDomCurrentRxLaserPower']) && $entry['jnxDomCurrentRxLaserPower'] != 0 && $entry['jnxDomCurrentTxLaserOutputPower'] != 0) { $oid = '.1.3.6.1.4.1.2636.3.60.1.1.1.1.5.'.$index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Rx Power'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Rx Power'; $limit_low = $entry['jnxDomCurrentRxLaserPowerLowAlarmThreshold']/$divisor; $warn_limit_low = $entry['jnxDomCurrentRxLaserPowerLowWarningThreshold']/$divisor; $limit = $entry['jnxDomCurrentRxLaserPowerHighAlarmThreshold']/$divisor; @@ -30,7 +30,7 @@ foreach ($pre_cache['junos_oids'] as $index => $entry) { if (is_numeric($entry['jnxDomCurrentTxLaserOutputPower']) && $entry['jnxDomCurrentTxLaserOutputPower'] && $entry['jnxDomCurrentRxLaserPower']) { $oid = '.1.3.6.1.4.1.2636.3.60.1.1.1.1.7.'.$index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Tx Power'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Tx Power'; $limit_low = $entry['jnxDomCurrentTxLaserOutputPowerLowAlarmThreshold']/$divisor; $warn_limit_low = $entry['jnxDomCurrentTxLaserOutputPowerLowWarningThreshold']/$divisor; $limit = $entry['jnxDomCurrentTxLaserOutputPowerHighAlarmThreshold']/$divisor; @@ -45,7 +45,7 @@ foreach ($pre_cache['junos_oids'] as $index => $entry) { $lane = $pre_cache['junos_multilane_oids'][$index.'.'.$x]; if (is_numeric($lane['jnxDomCurrentLaneRxLaserPower']) && $lane['jnxDomCurrentLaneRxLaserPower'] != 0 && $lane['jnxDomCurrentLaneTxLaserOutputPower'] != 0) { $oid = '.1.3.6.1.4.1.2636.3.60.1.2.1.1.6.'.$index.'.'.$x; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' lane ' . $x . ' Rx Power'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' lane ' . $x . ' Rx Power'; $limit_low = $entry['jnxDomCurrentRxLaserPowerLowAlarmThreshold']/$divisor; $warn_limit_low = $entry['jnxDomCurrentRxLaserPowerLowWarningThreshold']/$divisor; $limit = $entry['jnxDomCurrentRxLaserPowerHighAlarmThreshold']/$divisor; @@ -57,7 +57,7 @@ foreach ($pre_cache['junos_oids'] as $index => $entry) { } if (is_numeric($lane['jnxDomCurrentLaneTxLaserOutputPower']) && $lane['jnxDomCurrentLaneTxLaserOutputPower'] && $lane['jnxDomCurrentLaneRxLaserPower']) { $oid = '.1.3.6.1.4.1.2636.3.60.1.2.1.1.8.'.$index.'.'.$x; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' lane ' . $x . ' Tx Power'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' lane ' . $x . ' Tx Power'; $limit_low = $entry['jnxDomCurrentTxLaserOutputPowerLowAlarmThreshold']/$divisor; $warn_limit_low = $entry['jnxDomCurrentTxLaserOutputPowerLowWarningThreshold']/$divisor; $limit = $entry['jnxDomCurrentTxLaserOutputPowerHighAlarmThreshold']/$divisor; diff --git a/includes/discovery/sensors/dbm/mrv-od.inc.php b/includes/discovery/sensors/dbm/mrv-od.inc.php index f7149f4141..9cf651257d 100644 --- a/includes/discovery/sensors/dbm/mrv-od.inc.php +++ b/includes/discovery/sensors/dbm/mrv-od.inc.php @@ -20,7 +20,7 @@ $divisor = 1000; foreach ($pre_cache['mrv-od_port-table'] as $index => $entry) { if ($entry['nbsCmmcPortRxPower']) { $oid = '.1.3.6.1.4.1.629.200.8.1.1.32.' . $index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifName`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Rx Power'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifName`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Rx Power'; $currentrx = $entry['nbsCmmcPortRxPower']; discover_sensor( $valid['sensor'], @@ -43,7 +43,7 @@ foreach ($pre_cache['mrv-od_port-table'] as $index => $entry) { if ($entry['nbsCmmcPortTxPower']) { $oid = '.1.3.6.1.4.1.629.200.8.1.1.31.' . $index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifName`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Tx Power'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifName`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Tx Power'; $currenttx = $entry['nbsCmmcPortTxPower']; discover_sensor( $valid['sensor'], diff --git a/includes/discovery/sensors/dbm/pbn.inc.php b/includes/discovery/sensors/dbm/pbn.inc.php index be6be75414..3817999005 100644 --- a/includes/discovery/sensors/dbm/pbn.inc.php +++ b/includes/discovery/sensors/dbm/pbn.inc.php @@ -16,7 +16,7 @@ $divisor = 1; foreach ($pre_cache['pbn_oids'] as $index => $entry) { if (is_numeric($entry['rxPower']) && ($entry['rxPower'] !== '-65535')) { $oid = '.1.3.6.1.4.1.11606.10.9.63.1.7.1.3.'.$index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Rx Power'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Rx Power'; $limit_low = -30/$divisor; $warn_limit_low = -25/$divisor; $limit = -2/$divisor; @@ -29,7 +29,7 @@ foreach ($pre_cache['pbn_oids'] as $index => $entry) { if (is_numeric($entry['txPower']) && ($entry['txPower'] !== '-65535')) { $oid = '.1.3.6.1.4.1.11606.10.9.63.1.7.1.2.'.$index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Tx Power'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Tx Power'; $limit_low = -30/$divisor; $warn_limit_low = -25/$divisor; $limit = -2/$divisor; diff --git a/includes/discovery/sensors/dbm/procurve.inc.php b/includes/discovery/sensors/dbm/procurve.inc.php index 164dfbbdb6..386f048e8c 100644 --- a/includes/discovery/sensors/dbm/procurve.inc.php +++ b/includes/discovery/sensors/dbm/procurve.inc.php @@ -6,10 +6,7 @@ $divisor = 1000; foreach ($pre_cache['procurve_hpicfXcvrInfoTable'] as $index => $entry) { if (is_numeric($entry['hpicfXcvrRxPower']) && $entry['hpicfXcvrRxPower'] != -99999999 && isset($entry['hpicfXcvrDiagnosticsUpdate'])) { $oid = '.1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.15.' . $index; - $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array( - $index, - $device['device_id'] - )); + $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", [$index, $device['device_id']]); $limit_low = round(uw_to_dbm($entry['hpicfXcvrRcvPwrLoAlarm'] / 10), 2); $warn_limit_low = round(uw_to_dbm($entry['hpicfXcvrRcvPwrLoWarn'] / 10), 2); $limit = round(uw_to_dbm($entry['hpicfXcvrRcvPwrHiAlarm'] / 10), 2); @@ -25,10 +22,7 @@ foreach ($pre_cache['procurve_hpicfXcvrInfoTable'] as $index => $entry) { if (is_numeric($entry['hpicfXcvrTxPower']) && $entry['hpicfXcvrTxPower'] != -99999999 && isset($entry['hpicfXcvrDiagnosticsUpdate'])) { $oid = '.1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.14.' . $index; - $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array( - $index, - $device['device_id'] - )); + $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", [$index, $device['device_id']]); $limit_low = round(uw_to_dbm($entry['hpicfXcvrPwrOutLoAlarm'] / 10), 2); $warn_limit_low = round(uw_to_dbm($entry['hpicfXcvrPwrOutLoWarn'] / 10), 2); $limit = round(uw_to_dbm($entry['hpicfXcvrPwrOutHiAlarm'] / 10), 2); diff --git a/includes/discovery/sensors/entity-sensor.inc.php b/includes/discovery/sensors/entity-sensor.inc.php index 791bdda4d0..731d0530e2 100644 --- a/includes/discovery/sensors/entity-sensor.inc.php +++ b/includes/discovery/sensors/entity-sensor.inc.php @@ -2,7 +2,7 @@ echo ' ENTITY-SENSOR: '; echo 'Caching OIDs:'; if (empty($entity_array)) { - $entity_array = array(); + $entity_array = []; echo ' entPhysicalDescr'; $entity_array = snmpwalk_cache_multi_oid($device, 'entPhysicalDescr', $entity_array, 'ENTITY-MIB'); if (!empty($entity_array)) { @@ -28,7 +28,7 @@ if (!empty($entity_array)) { } if (!empty($entity_oids)) { - $entitysensor = array( + $entitysensor = [ 'voltsDC' => 'voltage', 'voltsAC' => 'voltage', 'amperes' => 'current', @@ -38,7 +38,7 @@ if (!empty($entity_oids)) { 'rpm' => 'fanspeed', 'celsius' => 'temperature', 'dBm' => 'dbm', - ); + ]; foreach ($entity_oids as $index => $entry) { $low_limit = null; @@ -47,7 +47,7 @@ if (!empty($entity_oids)) { $high_limit = null; // Fix for Cisco ASR920, 15.5(2)S - if ($entry['entPhySensorType'] == 'other' && str_contains($entity_array[$index]['entPhysicalName'], array('Rx Power Sensor', 'Tx Power Sensor'))) { + if ($entry['entPhySensorType'] == 'other' && str_contains($entity_array[$index]['entPhysicalName'], ['Rx Power Sensor', 'Tx Power Sensor'])) { $entitysensor['other'] = 'dbm'; } if ($entitysensor[$entry['entPhySensorType']] && is_numeric($entry['entPhySensorValue']) && is_numeric($index)) { @@ -138,7 +138,7 @@ if (!empty($entity_oids)) { if ($entry['entPhySensorOperStatus'] === 'unavailable') { $valid_sensor = false; } - if ($valid_sensor && dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE device_id = ? AND `sensor_class` = ? AND `sensor_type` = 'cisco-entity-sensor' AND `sensor_index` = ?", array($device['device_id'], $type, $index)) == '0') { + if ($valid_sensor && dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE device_id = ? AND `sensor_class` = ? AND `sensor_type` = 'cisco-entity-sensor' AND `sensor_index` = ?", [$device['device_id'], $type, $index]) == '0') { // Check to make sure we've not already seen this sensor via cisco's entity sensor mib if ($type == "power" && $device['os'] == "arista_eos" && preg_match("/DOM (R|T)x Power/i", $descr)) { $type = "dbm"; diff --git a/includes/discovery/sensors/fanspeed/dell.inc.php b/includes/discovery/sensors/fanspeed/dell.inc.php index ee6c53715c..e6fdd1b957 100644 --- a/includes/discovery/sensors/fanspeed/dell.inc.php +++ b/includes/discovery/sensors/fanspeed/dell.inc.php @@ -10,7 +10,7 @@ * the source code distribution for details. */ -$temp = snmpwalk_cache_multi_oid($device, 'coolingDeviceTable', array(), 'MIB-Dell-10892'); +$temp = snmpwalk_cache_multi_oid($device, 'coolingDeviceTable', [], 'MIB-Dell-10892'); $cur_oid = '.1.3.6.1.4.1.674.10892.1.700.12.1.6.'; if (is_array($temp)) { diff --git a/includes/discovery/sensors/fanspeed/ibm-amm.inc.php b/includes/discovery/sensors/fanspeed/ibm-amm.inc.php index 5f0537c411..01030891b6 100644 --- a/includes/discovery/sensors/fanspeed/ibm-amm.inc.php +++ b/includes/discovery/sensors/fanspeed/ibm-amm.inc.php @@ -11,12 +11,12 @@ */ $descr_prefix = 'Blower '; -$oids = array( +$oids = [ '.1.3.6.1.4.1.2.3.51.2.2.3.20.0', // BLADE-MIB:blower1speedRPM '.1.3.6.1.4.1.2.3.51.2.2.3.21.0', // BLADE-MIB:blower2speedRPM '.1.3.6.1.4.1.2.3.51.2.2.3.22.0', // BLADE-MIB:blower3speedRPM '.1.3.6.1.4.1.2.3.51.2.2.3.23.0', // BLADE-MIB:blower4speedRPM -); +]; echo 'BLADE-MIB '; foreach ($oids as $index => $oid) { diff --git a/includes/discovery/sensors/fanspeed/netonix.inc.php b/includes/discovery/sensors/fanspeed/netonix.inc.php index 8488e66e20..9ab436c64f 100644 --- a/includes/discovery/sensors/fanspeed/netonix.inc.php +++ b/includes/discovery/sensors/fanspeed/netonix.inc.php @@ -25,7 +25,7 @@ echo 'Netonix: '; // NETONIX-SWITCH-MIB::fanTable .1.3.6.1.4.1.46242.2 -$oids = snmpwalk_cache_multi_oid($device, 'fanTable', array(), 'NETONIX-SWITCH-MIB', 'netonix'); +$oids = snmpwalk_cache_multi_oid($device, 'fanTable', [], 'NETONIX-SWITCH-MIB', 'netonix'); if (is_array($oids)) { foreach ($oids as $index => $entry) { if (is_numeric($entry['fanSpeed']) && is_numeric($index)) { diff --git a/includes/discovery/sensors/fanspeed/onefs.inc.php b/includes/discovery/sensors/fanspeed/onefs.inc.php index d9221fd355..92f34470f5 100644 --- a/includes/discovery/sensors/fanspeed/onefs.inc.php +++ b/includes/discovery/sensors/fanspeed/onefs.inc.php @@ -24,7 +24,7 @@ */ echo 'OneFS: '; -$oids = snmpwalk_cache_multi_oid($device, 'fanTable', array(), 'ISILON-MIB'); +$oids = snmpwalk_cache_multi_oid($device, 'fanTable', [], 'ISILON-MIB'); foreach ($oids as $index => $entry) { if (is_numeric($entry['fanSpeed']) && is_numeric($index)) { diff --git a/includes/discovery/sensors/fanspeed/qnap.inc.php b/includes/discovery/sensors/fanspeed/qnap.inc.php index a76ac8b5ed..c0b3def1c1 100644 --- a/includes/discovery/sensors/fanspeed/qnap.inc.php +++ b/includes/discovery/sensors/fanspeed/qnap.inc.php @@ -15,8 +15,8 @@ echo 'QNAP: '; $fan_descr_oid = '.1.3.6.1.4.1.24681.1.2.15.1.2'; $fan_speed_oid = '.1.3.6.1.4.1.24681.1.2.15.1.3'; -$fans_descr = snmpwalk_cache_numerical_oid($device, $fan_descr_oid, array(), null, null, '-OQUsn'); -$fans_speed = snmpwalk_cache_numerical_oid($device, $fan_speed_oid, array(), null, null, '-OQUsn'); +$fans_descr = snmpwalk_cache_numerical_oid($device, $fan_descr_oid, [], null, null, '-OQUsn'); +$fans_speed = snmpwalk_cache_numerical_oid($device, $fan_speed_oid, [], null, null, '-OQUsn'); if (is_array($fans_speed) && !empty($fans_speed)) { foreach ($fans_speed as $index => $entry) { diff --git a/includes/discovery/sensors/fanspeed/quanta.inc.php b/includes/discovery/sensors/fanspeed/quanta.inc.php index c4ff56405f..68490a4454 100644 --- a/includes/discovery/sensors/fanspeed/quanta.inc.php +++ b/includes/discovery/sensors/fanspeed/quanta.inc.php @@ -14,7 +14,7 @@ d_echo('Quanta Fan Speeds'); $sensor_type = 'quanta_fan'; //FASTPATH-BOXSERVICES-PRIVATE-MIB::boxServicesFanSpeed $sensors_id_oid = 'boxServicesFanSpeed'; -$sensors_values = snmpwalk_cache_multi_oid($device, $sensors_id_oid, array(), 'NETGEAR-BOXSERVICES-PRIVATE-MIB'); +$sensors_values = snmpwalk_cache_multi_oid($device, $sensors_id_oid, [], 'NETGEAR-BOXSERVICES-PRIVATE-MIB'); $numeric_oid_base = '.1.3.6.1.4.1.4413.1.1.43.1.6.1.4'; foreach ($sensors_values as $index => $entry) { diff --git a/includes/discovery/sensors/fanspeed/xos.inc.php b/includes/discovery/sensors/fanspeed/xos.inc.php index ff2c69815a..dc3c632297 100644 --- a/includes/discovery/sensors/fanspeed/xos.inc.php +++ b/includes/discovery/sensors/fanspeed/xos.inc.php @@ -4,7 +4,7 @@ echo(" EXTREME-BASE-MIB "); // Fan Speed $oid = ".1.3.6.1.4.1.1916.1.1.1.9.1.4"; -$oids = snmpwalk_cache_multi_oid($device, $oid, array(), "EXTREME-BASE-MIB"); +$oids = snmpwalk_cache_multi_oid($device, $oid, [], "EXTREME-BASE-MIB"); foreach ($oids as $index => $entry) { // fix index to a proper int diff --git a/includes/discovery/sensors/frequency/eaton-ats.inc.php b/includes/discovery/sensors/frequency/eaton-ats.inc.php index d094fe91cc..04a6f6a91e 100644 --- a/includes/discovery/sensors/frequency/eaton-ats.inc.php +++ b/includes/discovery/sensors/frequency/eaton-ats.inc.php @@ -16,7 +16,7 @@ echo 'EATON-ATS '; -$oids = snmpwalk_cache_oid($device, 'ats2InputFrequency', array(), 'EATON-ATS2-MIB'); +$oids = snmpwalk_cache_oid($device, 'ats2InputFrequency', [], 'EATON-ATS2-MIB'); foreach ($oids as $volt_id => $data) { $source_oid="EATON-ATS2-MIB::ats2InputIndex.".$volt_id; $num_id = snmp_get($device, $source_oid, '-Oqve'); diff --git a/includes/discovery/sensors/frequency/eatonups.inc.php b/includes/discovery/sensors/frequency/eatonups.inc.php index 4547820f57..8f85feb7f3 100644 --- a/includes/discovery/sensors/frequency/eatonups.inc.php +++ b/includes/discovery/sensors/frequency/eatonups.inc.php @@ -3,7 +3,7 @@ echo 'XUPS-MIB '; // XUPS-MIB::xupsInputFrequency.0 = INTEGER: 500 -$oids = snmpwalk_cache_oid($device, 'xupsInputFrequency', array(), 'XUPS-MIB'); +$oids = snmpwalk_cache_oid($device, 'xupsInputFrequency', [], 'XUPS-MIB'); foreach ($oids as $freq_id => $data) { $freq_oid = ".1.3.6.1.4.1.534.1.3.1.$freq_id"; @@ -20,7 +20,7 @@ foreach ($oids as $freq_id => $data) { } // XUPS-MIB::xupsOutputFrequency.0 = INTEGER: 500 -$oids = snmpwalk_cache_oid($device, 'xupsOutputFrequency', array(), 'XUPS-MIB'); +$oids = snmpwalk_cache_oid($device, 'xupsOutputFrequency', [], 'XUPS-MIB'); foreach ($oids as $freq_id => $data) { $freq_oid = ".1.3.6.1.4.1.534.1.4.2.$freq_id"; @@ -36,7 +36,7 @@ foreach ($oids as $freq_id => $data) { } // XUPS-MIB::xupsBypassFrequency.0 = INTEGER: 500 -$oids = snmpwalk_cache_oid($device, 'xupsBypassFrequency', array(), 'XUPS-MIB'); +$oids = snmpwalk_cache_oid($device, 'xupsBypassFrequency', [], 'XUPS-MIB'); foreach ($oids as $freq_id => $data) { $freq_oid = ".1.3.6.1.4.1.534.1.5.1.$freq_id"; diff --git a/includes/discovery/sensors/frequency/ipoman.inc.php b/includes/discovery/sensors/frequency/ipoman.inc.php index 4f113f5b15..6fdd9a9fc4 100644 --- a/includes/discovery/sensors/frequency/ipoman.inc.php +++ b/includes/discovery/sensors/frequency/ipoman.inc.php @@ -2,7 +2,7 @@ echo 'IPOMANII-MIB: '; -$oids = array(); +$oids = []; d_echo('inletConfigFrequencyHigh '); $oids = snmpwalk_cache_multi_oid($device, 'inletConfigFrequencyHigh', $oids, 'IPOMANII-MIB'); diff --git a/includes/discovery/sensors/frequency/sinetica.inc.php b/includes/discovery/sensors/frequency/sinetica.inc.php index 0aa911e50c..b8eb7aaa69 100644 --- a/includes/discovery/sensors/frequency/sinetica.inc.php +++ b/includes/discovery/sensors/frequency/sinetica.inc.php @@ -49,7 +49,7 @@ if (!empty($bypass_current) || $bypass_current == 0) { discover_sensor($valid['sensor'], 'frequency', $device, $bypass_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); } -$oids = snmpwalk_cache_oid_num($device, '.1.3.6.1.4.1.13891.101.3.3.1.2', array()); +$oids = snmpwalk_cache_oid_num($device, '.1.3.6.1.4.1.13891.101.3.3.1.2', []); foreach ($oids as $oid => $data) { $current_id = substr($oid, strrpos($oid, '.') + 1); diff --git a/includes/discovery/sensors/gw-eydfa.inc.php b/includes/discovery/sensors/gw-eydfa.inc.php index fbf3722ebf..88ed23d568 100644 --- a/includes/discovery/sensors/gw-eydfa.inc.php +++ b/includes/discovery/sensors/gw-eydfa.inc.php @@ -174,14 +174,14 @@ unset($num_oid, $value, $divisor, $descr, $low_limit, $low_warn, $high_warn, $se echo 'GW EYDFA PSU State '; -$oids = array('.1.3.6.1.4.1.17409.1.1.2.1.4.11.1.3.6.1.4.1.17409.1.11.100.0.2', '.1.3.6.1.4.1.17409.1.1.2.1.4.11.1.3.6.1.4.1.17409.1.11.101.0.2'); +$oids = ['.1.3.6.1.4.1.17409.1.1.2.1.4.11.1.3.6.1.4.1.17409.1.11.100.0.2', '.1.3.6.1.4.1.17409.1.1.2.1.4.11.1.3.6.1.4.1.17409.1.11.101.0.2']; $state_name = 'PowerSupplyState'; -$states = array( - array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'normal'), - array('value' => 7, 'generic' => 1, 'graph' => 0, 'descr' => 'warning'), - array('value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'critical'), -); +$states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'normal'], + ['value' => 7, 'generic' => 1, 'graph' => 0, 'descr' => 'warning'], + ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'critical'], +]; create_state_index($state_name, $states); $n = 1; foreach ($oids as $oid) { diff --git a/includes/discovery/sensors/humidity/apc.inc.php b/includes/discovery/sensors/humidity/apc.inc.php index fe8cdeee4f..2291357829 100644 --- a/includes/discovery/sensors/humidity/apc.inc.php +++ b/includes/discovery/sensors/humidity/apc.inc.php @@ -2,7 +2,7 @@ // Environmental monitoring on UPSes etc // FIXME emConfigProbesTable may also be used? But not filled out on my device... -$apc_env_data = snmpwalk_cache_oid($device, 'iemConfigProbesTable', array(), 'PowerNet-MIB'); +$apc_env_data = snmpwalk_cache_oid($device, 'iemConfigProbesTable', [], 'PowerNet-MIB'); $apc_env_data = snmpwalk_cache_oid($device, 'iemStatusProbesTable', $apc_env_data, 'PowerNet-MIB'); foreach (array_keys($apc_env_data) as $index) { @@ -21,7 +21,7 @@ foreach (array_keys($apc_env_data) as $index) { } } -$apc_env_data = snmpwalk_cache_oid($device, 'emsProbeStatus', array(), 'PowerNet-MIB'); +$apc_env_data = snmpwalk_cache_oid($device, 'emsProbeStatus', [], 'PowerNet-MIB'); foreach (array_keys($apc_env_data) as $index) { if ($apc_env_data[$index]['emsProbeStatusProbeCommStatus'] != 'commsNeverDiscovered') { diff --git a/includes/discovery/sensors/humidity/liebert.inc.php b/includes/discovery/sensors/humidity/liebert.inc.php index 6df8a78da3..1ded005d78 100644 --- a/includes/discovery/sensors/humidity/liebert.inc.php +++ b/includes/discovery/sensors/humidity/liebert.inc.php @@ -23,7 +23,7 @@ * @author Neil Lathwood */ -$lib_data = snmpwalk_cache_oid($device, 'lgpEnvHumidityEntryRel', array(), 'LIEBERT-GP-ENVIRONMENTAL-MIB'); +$lib_data = snmpwalk_cache_oid($device, 'lgpEnvHumidityEntryRel', [], 'LIEBERT-GP-ENVIRONMENTAL-MIB'); foreach ($lib_data as $index => $data) { if (is_numeric($data['lgpEnvHumidityMeasurementRelTenths'])) { diff --git a/includes/discovery/sensors/humidity/mgeups.inc.php b/includes/discovery/sensors/humidity/mgeups.inc.php index bc0a9c8d88..26f17e2656 100644 --- a/includes/discovery/sensors/humidity/mgeups.inc.php +++ b/includes/discovery/sensors/humidity/mgeups.inc.php @@ -4,7 +4,7 @@ echo 'MGE UPS External '; // Environmental monitoring on UPSes etc // FIXME upsmgConfigEnvironmentTable and upsmgEnvironmentSensorTable are used but there are others ... -$mge_env_data = snmpwalk_cache_oid($device, 'upsmgConfigEnvironmentTable', array(), 'MG-SNMP-UPS-MIB'); +$mge_env_data = snmpwalk_cache_oid($device, 'upsmgConfigEnvironmentTable', [], 'MG-SNMP-UPS-MIB'); $mge_env_data = snmpwalk_cache_oid($device, 'upsmgEnvironmentSensorTable', $mge_env_data, 'MG-SNMP-UPS-MIB'); /** diff --git a/includes/discovery/sensors/humidity/pcoweb.inc.php b/includes/discovery/sensors/humidity/pcoweb.inc.php index 34feb5e53d..d6a9a2167f 100644 --- a/includes/discovery/sensors/humidity/pcoweb.inc.php +++ b/includes/discovery/sensors/humidity/pcoweb.inc.php @@ -2,38 +2,38 @@ echo 'pCOWeb: '; -$humidities = array( - array( +$humidities = [ + [ 'mib' => 'CAREL-ug40cdz-MIB::roomRH.0', 'descr' => 'Room Relative Humidity', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.6.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::dehumPband.0', 'descr' => 'Dehumidification Prop. Band', 'oid' => '.1.3.6.1.4.1.9839.2.1.3.12.0', 'precision' => '1', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::humidPband.0', 'descr' => 'Humidification Prop. Band', 'oid' => '.1.3.6.1.4.1.9839.2.1.3.13.0', 'precision' => '1', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::dehumSetp.0', 'descr' => 'Dehumidification Set Point', 'oid' => '.1.3.6.1.4.1.9839.2.1.3.16.0', 'precision' => '1', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::humidSetp.0', 'descr' => 'Humidification Set Point', 'oid' => '.1.3.6.1.4.1.9839.2.1.3.17.0', 'precision' => '1', - ), -); + ], +]; foreach ($humidities as $humidity) { $current = (snmp_get($device, $humidity['mib'], '-OqvU') / $humidity['precision']); diff --git a/includes/discovery/sensors/humidity/sentry3.inc.php b/includes/discovery/sensors/humidity/sentry3.inc.php index d85879a615..0c54cf032a 100644 --- a/includes/discovery/sensors/humidity/sentry3.inc.php +++ b/includes/discovery/sensors/humidity/sentry3.inc.php @@ -1,6 +1,6 @@ */ -$serverscheck_oids = array( +$serverscheck_oids = [ 'sensor1Value.0' => '.1.3.6.1.4.1.17095.3.2.0', 'sensor2Value.0' => '.1.3.6.1.4.1.17095.3.6.0', 'sensor3Value.0' => '.1.3.6.1.4.1.17095.3.10.0', 'sensor4Value.0' => '.1.3.6.1.4.1.17095.3.14.0', 'sensor5Value.0' => '.1.3.6.1.4.1.17095.3.18.0', -); +]; $temp_x = 1; foreach ($pre_cache['serverscheck_control'] as $oid_name => $oid_value) { diff --git a/includes/discovery/sensors/load/apc.inc.php b/includes/discovery/sensors/load/apc.inc.php index a19eb742e4..5bb5fb6634 100644 --- a/includes/discovery/sensors/load/apc.inc.php +++ b/includes/discovery/sensors/load/apc.inc.php @@ -4,7 +4,7 @@ echo 'APC Load '; $phasecount = $phasecount = $pre_cache['apcups_phase_count']; if ($phasecount > 1) { - $oids = snmpwalk_cache_oid($device, 'upsPhaseOutputPercentLoad', array(), 'PowerNet-MIB'); + $oids = snmpwalk_cache_oid($device, 'upsPhaseOutputPercentLoad', [], 'PowerNet-MIB'); d_echo($oids); foreach ($oids as $index => $data) { $type = 'apcUPS'; @@ -18,17 +18,17 @@ if ($phasecount > 1) { } unset($oids); } else { - $oid_array = array( - array( - 'HighPrecOid' => 'upsHighPrecOutputLoad', - 'AdvOid' => 'upsAdvOutputLoad', - 'type' => 'apc', - 'index' => 0, - 'descr' => 'Load', - 'divisor' => 10, - 'mib' => '+PowerNet-MIB', - ), - ); + $oid_array = [ + [ + 'HighPrecOid' => 'upsHighPrecOutputLoad', + 'AdvOid' => 'upsAdvOutputLoad', + 'type' => 'apc', + 'index' => 0, + 'descr' => 'Load', + 'divisor' => 10, + 'mib' => '+PowerNet-MIB', + ], + ]; foreach ($oid_array as $item) { $oids = snmp_get($device, $item['HighPrecOid'].'.'.$item['index'], '-OsqnU', $item['mib']); if (empty($oids)) { diff --git a/includes/discovery/sensors/load/sinetica.inc.php b/includes/discovery/sensors/load/sinetica.inc.php index cc381445a7..a82203b856 100644 --- a/includes/discovery/sensors/load/sinetica.inc.php +++ b/includes/discovery/sensors/load/sinetica.inc.php @@ -23,7 +23,7 @@ * @author Tony Murray */ -$oids = snmpwalk_cache_oid_num($device, '.1.3.6.1.4.1.13891.101.4.4.1.5', array()); +$oids = snmpwalk_cache_oid_num($device, '.1.3.6.1.4.1.13891.101.4.4.1.5', []); foreach ($oids as $oid => $data) { $current_id = substr($oid, strrpos($oid, '.') + 1); diff --git a/includes/discovery/sensors/netscaler.inc.php b/includes/discovery/sensors/netscaler.inc.php index 064ab38160..f9bc61e7f9 100644 --- a/includes/discovery/sensors/netscaler.inc.php +++ b/includes/discovery/sensors/netscaler.inc.php @@ -5,7 +5,7 @@ echo ' NetScaler '; echo ' Caching OIDs:'; if (!is_array($ns_sensor_array)) { - $ns_sensor_array = array(); + $ns_sensor_array = []; echo ' sysHealthCounterValue '; $ns_sensor_array = snmpwalk_cache_multi_oid($device, 'sysHealthCounterValue', $ns_sensor_array, 'NS-ROOT-MIB'); } diff --git a/includes/discovery/sensors/openbsd.inc.php b/includes/discovery/sensors/openbsd.inc.php index d479fd49d4..5b6669d5ec 100644 --- a/includes/discovery/sensors/openbsd.inc.php +++ b/includes/discovery/sensors/openbsd.inc.php @@ -4,7 +4,7 @@ echo ' OPENBSD-SENSORS-MIB: '; echo 'Caching OIDs:'; -$oids = array(); +$oids = []; echo ' sensorDevice'; $oids = snmpwalk_cache_multi_oid($device, 'sensorDevice', $oids, 'OPENBSD-SENSORS-MIB'); echo ' sensorDescr'; diff --git a/includes/discovery/sensors/power/ciscosb.inc.php b/includes/discovery/sensors/power/ciscosb.inc.php index 79033ab968..2e8db1401e 100644 --- a/includes/discovery/sensors/power/ciscosb.inc.php +++ b/includes/discovery/sensors/power/ciscosb.inc.php @@ -11,7 +11,7 @@ */ echo 'CiscoSB: '; -$temp = snmpwalk_cache_multi_oid($device, 'rlPethPsePortEntry', array(), 'CISCOSB-POE-MIB'); +$temp = snmpwalk_cache_multi_oid($device, 'rlPethPsePortEntry', [], 'CISCOSB-POE-MIB'); if (is_array($temp)) { $cur_oid = '.1.3.6.1.4.1.9.6.1.101.108.1.1.5.'; $divisor = '1000'; diff --git a/includes/discovery/sensors/power/dell.inc.php b/includes/discovery/sensors/power/dell.inc.php index 6ee094a584..f2e8e45657 100644 --- a/includes/discovery/sensors/power/dell.inc.php +++ b/includes/discovery/sensors/power/dell.inc.php @@ -23,7 +23,7 @@ * @author Neil Lathwood */ -$temp = snmpwalk_cache_multi_oid($device, 'amperageProbeTableEntry', array(), 'MIB-Dell-10892'); +$temp = snmpwalk_cache_multi_oid($device, 'amperageProbeTableEntry', [], 'MIB-Dell-10892'); $cur_oid = '.1.3.6.1.4.1.674.10892.1.600.30.1.6.1.'; foreach ((array)$temp as $index => $entry) { diff --git a/includes/discovery/sensors/power/microsemipdsine.inc.php b/includes/discovery/sensors/power/microsemipdsine.inc.php index 8746f8f1c8..5ff33d9252 100644 --- a/includes/discovery/sensors/power/microsemipdsine.inc.php +++ b/includes/discovery/sensors/power/microsemipdsine.inc.php @@ -24,7 +24,7 @@ */ // Power consumption per port -$oids = snmpwalk_cache_oid_num($device, '1.3.6.1.4.1.7428.1.2.1.1.1.3.1', array()); +$oids = snmpwalk_cache_oid_num($device, '1.3.6.1.4.1.7428.1.2.1.1.1.3.1', []); foreach ($oids as $oid => $data) { $current_id = substr($oid, strrpos($oid, '.') + 1); diff --git a/includes/discovery/sensors/power/sinetica.inc.php b/includes/discovery/sensors/power/sinetica.inc.php index 77632ee9f0..6adb4df72d 100644 --- a/includes/discovery/sensors/power/sinetica.inc.php +++ b/includes/discovery/sensors/power/sinetica.inc.php @@ -23,7 +23,7 @@ * @author Tony Murray */ -$oids = snmpwalk_cache_oid_num($device, '.1.3.6.1.4.1.13891.101.4.4.1.4', array()); +$oids = snmpwalk_cache_oid_num($device, '.1.3.6.1.4.1.13891.101.4.4.1.4', []); foreach ($oids as $oid => $data) { $current_id = substr($oid, strrpos($oid, '.') + 1); diff --git a/includes/discovery/sensors/pre-cache/adva_fsp150.inc.php b/includes/discovery/sensors/pre-cache/adva_fsp150.inc.php index fb75519e7a..0994fb3946 100644 --- a/includes/discovery/sensors/pre-cache/adva_fsp150.inc.php +++ b/includes/discovery/sensors/pre-cache/adva_fsp150.inc.php @@ -17,4 +17,4 @@ **/ // FSP150CC Series -$pre_cache['adva_fsp150'] = snmpwalk_cache_multi_oid($device, 'cmEntityObjects', array(), 'CM-ENTITY-MIB', null, '-OQUbs'); +$pre_cache['adva_fsp150'] = snmpwalk_cache_multi_oid($device, 'cmEntityObjects', [], 'CM-ENTITY-MIB', null, '-OQUbs'); diff --git a/includes/discovery/sensors/pre-cache/aos-emu2.inc.php b/includes/discovery/sensors/pre-cache/aos-emu2.inc.php index 714310331f..7108d5853e 100644 --- a/includes/discovery/sensors/pre-cache/aos-emu2.inc.php +++ b/includes/discovery/sensors/pre-cache/aos-emu2.inc.php @@ -27,4 +27,4 @@ echo 'emsStatusSysTempUnits '; $pre_cache['emu2_temp_scale'] = snmp_get($device, 'emsStatusSysTempUnits.0', '-OQv', 'PowerNet-MIB'); echo 'emsProbeStatusEntry '; -$pre_cache['emu2_temp'] = snmpwalk_cache_oid($device, 'emsProbeStatusEntry', array(), 'PowerNet-MIB'); +$pre_cache['emu2_temp'] = snmpwalk_cache_oid($device, 'emsProbeStatusEntry', [], 'PowerNet-MIB'); diff --git a/includes/discovery/sensors/pre-cache/apc.inc.php b/includes/discovery/sensors/pre-cache/apc.inc.php index 121c39230a..b36d1069b6 100644 --- a/includes/discovery/sensors/pre-cache/apc.inc.php +++ b/includes/discovery/sensors/pre-cache/apc.inc.php @@ -23,13 +23,13 @@ * @author Neil Lathwood */ echo 'coolingUnitStatusAnalogEntry '; -$pre_cache['cooling_unit_analog'] = snmpwalk_cache_oid($device, 'coolingUnitStatusAnalogEntry', array(), 'PowerNet-MIB'); +$pre_cache['cooling_unit_analog'] = snmpwalk_cache_oid($device, 'coolingUnitStatusAnalogEntry', [], 'PowerNet-MIB'); echo 'upsPhaseNumInputPhases '; $pre_cache['apcups_phase_count'] = snmp_get($device, 'upsPhaseNumInputPhases.1', '-OQv', 'PowerNet-MIB'); echo 'memSensorsStatusTable '; -$pre_cache['mem_sensors_status'] = snmpwalk_cache_oid($device, 'memSensorsStatusTable', array(), 'PowerNet-MIB', null, '-OQUse'); +$pre_cache['mem_sensors_status'] = snmpwalk_cache_oid($device, 'memSensorsStatusTable', [], 'PowerNet-MIB', null, '-OQUse'); echo 'memSensorsStatusSysTempUnits '; $pre_cache['memSensorsStatusSysTempUnits'] = snmp_get($device, 'memSensorsStatusSysTempUnits.0', '-OQv', 'PowerNet-MIB'); diff --git a/includes/discovery/sensors/pre-cache/arris-c3.inc.php b/includes/discovery/sensors/pre-cache/arris-c3.inc.php index 0ef6029c0a..11590ce946 100644 --- a/includes/discovery/sensors/pre-cache/arris-c3.inc.php +++ b/includes/discovery/sensors/pre-cache/arris-c3.inc.php @@ -25,10 +25,10 @@ */ echo 'ifName '; -$pre_cache['ar-c3_ifName'] = snmpwalk_cache_oid($device, 'ifName', array(), 'DOCS-IF-MIB'); +$pre_cache['ar-c3_ifName'] = snmpwalk_cache_oid($device, 'ifName', [], 'DOCS-IF-MIB'); echo 'ifAlias '; -$pre_cache['ar-c3_ifAlias'] = snmpwalk_cache_oid($device, 'ifAlias', array(), 'DOCS-IF-MIB'); +$pre_cache['ar-c3_ifAlias'] = snmpwalk_cache_oid($device, 'ifAlias', [], 'DOCS-IF-MIB'); echo 'docsIfSignalQualityTable '; -$pre_cache['ar-c3_docsIfSignalQualityTable'] = snmpwalk_cache_oid($device, 'docsIfSignalQualityTable', array(), 'DOCS-IF-MIB'); +$pre_cache['ar-c3_docsIfSignalQualityTable'] = snmpwalk_cache_oid($device, 'docsIfSignalQualityTable', [], 'DOCS-IF-MIB'); diff --git a/includes/discovery/sensors/pre-cache/arris-c4.inc.php b/includes/discovery/sensors/pre-cache/arris-c4.inc.php index 635d97e14c..0db093e52b 100644 --- a/includes/discovery/sensors/pre-cache/arris-c4.inc.php +++ b/includes/discovery/sensors/pre-cache/arris-c4.inc.php @@ -25,10 +25,10 @@ */ echo 'ifName '; -$pre_cache['ar-c4_ifName'] = snmpwalk_cache_oid($device, 'ifName', array(), 'DOCS-IF-MIB'); +$pre_cache['ar-c4_ifName'] = snmpwalk_cache_oid($device, 'ifName', [], 'DOCS-IF-MIB'); echo 'ifAlias '; -$pre_cache['ar-c4_ifAlias'] = snmpwalk_cache_oid($device, 'ifAlias', array(), 'DOCS-IF-MIB'); +$pre_cache['ar-c4_ifAlias'] = snmpwalk_cache_oid($device, 'ifAlias', [], 'DOCS-IF-MIB'); echo 'docsIfSignalQualityTable '; -$pre_cache['ar-c4_docsIfSignalQualityTable'] = snmpwalk_cache_oid($device, 'docsIfSignalQualityTable', array(), 'DOCS-IF-MIB'); +$pre_cache['ar-c4_docsIfSignalQualityTable'] = snmpwalk_cache_oid($device, 'docsIfSignalQualityTable', [], 'DOCS-IF-MIB'); diff --git a/includes/discovery/sensors/pre-cache/avtech.inc.php b/includes/discovery/sensors/pre-cache/avtech.inc.php index a36aeeb581..9d0ced23ab 100644 --- a/includes/discovery/sensors/pre-cache/avtech.inc.php +++ b/includes/discovery/sensors/pre-cache/avtech.inc.php @@ -25,13 +25,13 @@ // table name => regex (first group is index, second group is id) -$virtual_tables = array( +$virtual_tables = [ 'ra32-analog' => '/\.1\.3\.6\.1\.4\.1\.20916\.1\.8\.1\.1\.5\.((\d+)\.0)/', 'ra32-relay' => '/\.1\.3\.6\.1\.4\.1\.20916\.1\.8\.1\.1\.6\.((\d+)\.0)/', 'ra32-ext-temp' => '/\.1\.3\.6\.1\.4\.1\.20916\.1\.8\.1\.2\.((\d+)\.1\.0)/', 'ra32-switch' => '/\.1\.3\.6\.1\.4\.1\.20916\.1\.8\.1\.3\.((\d+)\.0)/', 'ra32-wish-temp' => '/\.1\.3\.6\.1\.4\.1\.20916\.1\.8\.1\.4\.((\d+)\.4\.1\.2\.0)/', -); +]; $data = snmp_walk($device, '.1.3.6.1.4.1.20916.1', '-OQn'); foreach (explode(PHP_EOL, $data) as $line) { @@ -43,10 +43,7 @@ foreach (explode(PHP_EOL, $data) as $line) { $index = $matches[1]; $id = $matches[2]; - $pre_cache[$vt_name][$index] = array( - 'value' => $value, - 'id' => $id, - ); + $pre_cache[$vt_name][$index] = ['value' => $value, 'id' => $id]; $processed = true; break; // skip rest @@ -54,7 +51,7 @@ foreach (explode(PHP_EOL, $data) as $line) { } if (!$processed) { - $pre_cache[$oid] = array($value); + $pre_cache[$oid] = [$value]; } } diff --git a/includes/discovery/sensors/pre-cache/ciscoepc.inc.php b/includes/discovery/sensors/pre-cache/ciscoepc.inc.php index 101c264555..29ff01a782 100644 --- a/includes/discovery/sensors/pre-cache/ciscoepc.inc.php +++ b/includes/discovery/sensors/pre-cache/ciscoepc.inc.php @@ -24,7 +24,7 @@ */ echo 'docsIfDownstreamChannelTable '; -$pre_cache['ciscoepc_docsIfDownstreamChannelTable'] = snmpwalk_cache_oid($device, 'docsIfDownstreamChannelTable', array(), 'DOCS-IF-MIB'); +$pre_cache['ciscoepc_docsIfDownstreamChannelTable'] = snmpwalk_cache_oid($device, 'docsIfDownstreamChannelTable', [], 'DOCS-IF-MIB'); echo 'docsIfSignalQualityTable '; -$pre_cache['ciscoepc_docsIfSignalQualityTable'] = snmpwalk_cache_oid($device, 'docsIfSignalQualityTable', array(), 'DOCS-IF-MIB'); +$pre_cache['ciscoepc_docsIfSignalQualityTable'] = snmpwalk_cache_oid($device, 'docsIfSignalQualityTable', [], 'DOCS-IF-MIB'); diff --git a/includes/discovery/sensors/pre-cache/comware.inc.php b/includes/discovery/sensors/pre-cache/comware.inc.php index a4882e71a3..3146e73f6a 100644 --- a/includes/discovery/sensors/pre-cache/comware.inc.php +++ b/includes/discovery/sensors/pre-cache/comware.inc.php @@ -11,4 +11,4 @@ */ echo 'hh3cTransceiverInfoTable '; -$pre_cache['comware_oids'] = snmpwalk_cache_multi_oid($device, 'hh3cTransceiverInfoTable', array(), 'HH3C-TRANSCEIVER-INFO-MIB'); +$pre_cache['comware_oids'] = snmpwalk_cache_multi_oid($device, 'hh3cTransceiverInfoTable', [], 'HH3C-TRANSCEIVER-INFO-MIB'); diff --git a/includes/discovery/sensors/pre-cache/datacom.inc.php b/includes/discovery/sensors/pre-cache/datacom.inc.php index 87bdde8b62..93fbd770a5 100644 --- a/includes/discovery/sensors/pre-cache/datacom.inc.php +++ b/includes/discovery/sensors/pre-cache/datacom.inc.php @@ -1,4 +1,4 @@ $contact) { $normalstate = $contact['emsInputContactStatusInputContactNormalState']; if (is_array($contacts['emu2_contacts']) && $normalstate == '1') { $state_name = 'emsInputContactNormalState_NC'; - $states = array( - array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Closed'), - array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Open'), - ); + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Closed'], + ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Open'], + ]; create_state_index($state_name, $states); } elseif (is_array($contacts['emu2_contacts']) && $normalstate == '2') { $state_name = 'emsInputContactNormalState_NO'; - $states = array( - array('value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'Closed'), - array('value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Open'), - ); + $states = [ + ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'Closed'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Open'], + ]; create_state_index($state_name, $states); } - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $currentstate, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $currentstate, 'snmp', $index); create_sensor_to_state_index($device, $state_name, $index); } @@ -65,21 +65,21 @@ foreach ($relays['emu2_relays'] as $id => $relay) { $normalstate = $relay['emsOutputRelayStatusOutputRelayNormalState']; if (is_array($relays['emu2_relays']) && $normalstate == '1') { $state_name = 'emsOutputRelayNormalState_NC'; - $states = array( - array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Closed'), - array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Open'), - ); + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Closed'], + ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Open'], + ]; create_state_index($state_name, $states); } elseif (is_array($relays['emu2_relays']) && $normalstate == '2') { $state_name = 'emsOutputRelayNormalState_NO'; - $states = array( - array('value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'Closed'), - array('value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Open'), - ); + $states = [ + ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'Closed'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Open'], + ]; create_state_index($state_name, $states); } - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $currentstate, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $currentstate, 'snmp', $index); create_sensor_to_state_index($device, $state_name, $index); } @@ -95,20 +95,20 @@ foreach ($outlets['emu2_outlets'] as $id => $outlet) { $normalstate = $outlet['emsOutletStatusOutletNormalState']; if (is_array($outlets['emu2_outlets']) && $normalstate == '1') { $state_name = 'emsOutletNormalState_ON'; - $states = array( - array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'On'), - array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Off'), - ); + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'On'], + ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Off'], + ]; create_state_index($state_name, $states); } elseif (is_array($outlets['emu2_outlets']) && $normalstate == '2') { $state_name = 'emsOutletNormalState_OFF'; - $states = array( - array('value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'On'), - array('value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Off'), - ); + $states = [ + ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'On'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Off'], + ]; create_state_index($state_name, $states); } - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $currentstate, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $currentstate, 'snmp', $index); create_sensor_to_state_index($device, $state_name, $index); } diff --git a/includes/discovery/sensors/state/apc.inc.php b/includes/discovery/sensors/state/apc.inc.php index fe1793e48a..77ae2d849b 100644 --- a/includes/discovery/sensors/state/apc.inc.php +++ b/includes/discovery/sensors/state/apc.inc.php @@ -17,121 +17,73 @@ $index = '0'; if (is_numeric($temp)) { //Create State Index $state_name = 'upsAdvBatteryReplaceIndicator'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'noBatteryNeedsReplacing',0,1,0) , - array($state_index_id,'batteryNeedsReplacing',0,2,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'noBatteryNeedsReplacing'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'batteryNeedsReplacing'], + ]; + create_state_index($state_name, $states); $descr = 'UPS Battery Replacement Status'; //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp, 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); } -$cooling_status = snmpwalk_cache_oid($device, 'coolingUnitStatusDiscreteEntry', array(), 'PowerNet-MIB'); +$cooling_status = snmpwalk_cache_oid($device, 'coolingUnitStatusDiscreteEntry', [], 'PowerNet-MIB'); foreach ($cooling_status as $index => $data) { $cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.4.2.2.1.4.' . $index; $state_name = $data['coolingUnitStatusDiscreteDescription']; - $state_index_id = create_state_index($state_name); - if ($state_index_id !== null) { - $tmp_states = explode(',', $data['coolingUnitStatusDiscreteIntegerReferenceKey']); - $states = array(); - foreach ($tmp_states as $k => $ref) { - preg_match('/([\w]+)\\(([\d]+)\\)/', $ref, $matches); - $nagios_state = get_nagios_state($matches[1]); - $states[] = array($state_index_id, $matches[1], 0, $matches[2], $nagios_state); - } - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } + $tmp_states = explode(',', $data['coolingUnitStatusDiscreteIntegerReferenceKey']); + $states = []; + foreach ($tmp_states as $k => $ref) { + preg_match('/([\w]+)\\(([\d]+)\\)/', $ref, $matches); + $nagios_state = get_nagios_state($matches[1]); + $states[] = ['value' => 0, 'generic' => $nagios_state, 'graph' => 0, $matches[2], 'descr' => $matches[1]]; } - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $cur_oid, 'apc', $state_name, '1', '1', null, null, null, null, $data['coolingUnitStatusDiscreteValueAsInteger']); + create_state_index($state_name, $states); + + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $cur_oid, 'apc', $state_name, 1, 1, null, null, null, null, $data['coolingUnitStatusDiscreteValueAsInteger']); create_sensor_to_state_index($device, $state_name, $index); } unset($cooling_status); -$cooling_unit = snmpwalk_cache_oid($device, 'coolingUnitExtendedDiscreteEntry', array(), 'PowerNet-MIB'); +$cooling_unit = snmpwalk_cache_oid($device, 'coolingUnitExtendedDiscreteEntry', [], 'PowerNet-MIB'); foreach ($cooling_unit as $index => $data) { $cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.6.2.2.1.4.' . $index; $state_name = $data['coolingUnitExtendedDiscreteDescription']; - $state_index_id = create_state_index($state_name); - if ($state_index_id !== null) { - $tmp_states = explode(',', $data['coolingUnitExtendedDiscreteIntegerReferenceKey']); - $states = array(); - foreach ($tmp_states as $k => $ref) { - preg_match('/([\w]+)\\(([\d]+)\\)/', $ref, $matches); - $nagios_state = get_nagios_state($matches[1]); - $states[] = array($state_index_id, $matches[1], 0, $matches[2], $nagios_state); - } - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } + $tmp_states = explode(',', $data['coolingUnitExtendedDiscreteIntegerReferenceKey']); + $states = []; + foreach ($tmp_states as $k => $ref) { + preg_match('/([\w]+)\\(([\d]+)\\)/', $ref, $matches); + $nagios_state = get_nagios_state($matches[1]); + $states[] = ['value' => 0, 'generic' => $nagios_state, 'graph' => 0, $matches[2], 'descr' => $matches[1]]; } - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $cur_oid, 'apc', $state_name, '1', '1', null, null, null, null, $data['coolingUnitExtendedDiscreteValueAsInteger']); + create_state_index($state_name, $states); + + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $cur_oid, 'apc', $state_name, 1, 1, null, null, null, null, $data['coolingUnitExtendedDiscreteValueAsInteger']); create_sensor_to_state_index($device, $state_name, $index); } unset($cooling_unit); -$relays = snmpwalk_cache_oid($device, 'emsOutputRelayControlEntry', array(), 'PowerNet-MIB'); +$relays = snmpwalk_cache_oid($device, 'emsOutputRelayControlEntry', [], 'PowerNet-MIB'); foreach ($relays as $index => $data) { $cur_oid = '.1.3.6.1.4.1.318.1.1.10.3.2.1.1.3.' . $index; $state_name = $data['emsOutputRelayControlOutputRelayName']; - $state_index_id = create_state_index($state_name); + $states = [ + ['value' => 1, 'generic' => 2, 'graph' => 0, 'descr' => 'immediateCloseEMS'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'immediateOpenEMS'], + ]; + create_state_index($state_name, $states); - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'immediateCloseEMS',0,1,2) , - array($state_index_id,'immediateOpenEMS',0,2,0) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } $current = apc_relay_state($data['emsOutputRelayControlOutputRelayCommand']); if (is_numeric($current)) { - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $cur_oid, $state_name, $state_name, '1', '1', null, null, null, null, $current); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $cur_oid, $state_name, $state_name, 1, 1, null, null, null, null, $current); create_sensor_to_state_index($device, $state_name, $cur_oid); } } @@ -141,31 +93,19 @@ unset( $data ); -$switched = snmpwalk_cache_oid($device, 'emsOutletControlEntry', array(), 'PowerNet-MIB'); +$switched = snmpwalk_cache_oid($device, 'emsOutletControlEntry', [], 'PowerNet-MIB'); foreach ($switched as $index => $data) { $cur_oid = '.1.3.6.1.4.1.318.1.1.10.3.3.1.1.3.' . $index; $state_name = $data['emsOutletControlOutletName']; - $state_index_id = create_state_index($state_name); + $states = [ + ['value' => 1, 'generic' => 2, 'graph' => 0, 'descr' => 'immediateOnEMS'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'immediateOffEMS'], + ]; + create_state_index($state_name, $states); - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'immediateOnEMS',0,1,2) , - array($state_index_id,'immediateOffEMS',0,2,0) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } $current = apc_relay_state($data['emsOutletControlOutletCommand']); if (is_numeric($current)) { - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $cur_oid, $state_name, $state_name, '1', '1', null, null, null, null, $current); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $cur_oid, $state_name, $state_name, 1, 1, null, null, null, null, $current); create_sensor_to_state_index($device, $state_name, $cur_oid); } } @@ -179,62 +119,40 @@ foreach ($pre_cache['mem_sensors_status'] as $index => $data) { if ($data['memSensorsCommStatus']) { $cur_oid = '.1.3.6.1.4.1.318.1.1.10.4.2.3.1.7.' . $index; $state_name = 'memSensorsCommStatus'; - $state_index_id = create_state_index($state_name); - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'notInstalled',0,1,1), - array($state_index_id,'commsOK',0,2,0), - array($state_index_id,'commsLost',0,3,2), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'notInstalled'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'commsOK'], + ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'commsLost'], + ]; + create_state_index($state_name, $states); + $current = $data['memSensorsCommStatus']; } $descr = $data['memSensorsStatusSensorName'] . ' - ' . $data['memSensorsStatusSensorLocation']; $divisor = 1; $multiplier = 1; if (is_numeric($current)) { - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $state_name . '.' . $index, $state_name, $state_name, '1', '1', null, null, null, null, $current); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $state_name . '.' . $index, $state_name, $state_name, 1, 1, null, null, null, null, $current); create_sensor_to_state_index($device, $state_name, $state_name . '.' . $index); } if ($data['memSensorsAlarmStatus']) { $cur_oid = '.1.3.6.1.4.1.318.1.1.10.4.2.3.1.8.' . $index; $state_name = 'memSensorsAlarmStatus'; - $state_index_id = create_state_index($state_name); - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'memNormal',0,1,0), - array($state_index_id,'memWarning',0,2,1), - array($state_index_id,'memCritical',0,3,2), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'memNormal'], + ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'memWarning'], + ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'memCritical'], + ]; + create_state_index($state_name, $states); + $current = $data['memSensorsAlarmStatus']; } $descr = $data['memSensorsStatusSensorName'] . ' - ' . $data['memSensorsStatusSensorLocation']; $divisor = 1; $multiplier = 1; if (is_numeric($current)) { - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $state_name . '.' . $index, $state_name, $state_name, '1', '1', null, null, null, null, $current); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $state_name . '.' . $index, $state_name, $state_name, 1, 1, null, null, null, null, $current); create_sensor_to_state_index($device, $state_name, $state_name . '.' . $index); } } diff --git a/includes/discovery/sensors/state/asa.inc.php b/includes/discovery/sensors/state/asa.inc.php index 2ff13de363..d24283dac1 100644 --- a/includes/discovery/sensors/state/asa.inc.php +++ b/includes/discovery/sensors/state/asa.inc.php @@ -10,40 +10,26 @@ * the source code distribution for details. */ -$temp = snmpwalk_cache_multi_oid($device, 'cfwHardwareStatusTable', array(), 'CISCO-FIREWALL-MIB'); +$temp = snmpwalk_cache_multi_oid($device, 'cfwHardwareStatusTable', [], 'CISCO-FIREWALL-MIB'); $cur_oid = '.1.3.6.1.4.1.9.9.147.1.2.1.1.1.3.'; if (is_array($temp)) { //Create State Index if (strstr($temp['netInterface']['cfwHardwareStatusDetail'], 'not Configured') == false) { $state_name = 'cfwHardwareStatus'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'other',0,1,2) , - array($state_index_id,'up',0,2,0) , - array($state_index_id,'down',0,3,2) , - array($state_index_id,'error',0,4,2) , - array($state_index_id,'overTemp',0,5,2) , - array($state_index_id,'busy',0,6,2) , - array($state_index_id,'noMedia',0,7,2) , - array($state_index_id,'backup',0,8,2) , - array($state_index_id,'active',0,9,0) , - array($state_index_id,'standby',0,10,0) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 2, 'graph' => 0, 'descr' => 'other'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'up'], + ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'down'], + ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'error'], + ['value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'overTemp'], + ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'busy'], + ['value' => 7, 'generic' => 2, 'graph' => 0, 'descr' => 'noMedia'], + ['value' => 8, 'generic' => 2, 'graph' => 0, 'descr' => 'backup'], + ['value' => 9, 'generic' => 0, 'graph' => 0, 'descr' => 'active'], + ['value' => 10, 'generic' => 0, 'graph' => 0, 'descr' => 'standby'], + ]; + create_state_index($state_name, $states); foreach ($temp as $index => $entry) { $descr = ucwords(trim(preg_replace('/\s*\([^\s)]*\)/', '', $temp[$index]['cfwHardwareInformation']))); @@ -55,7 +41,7 @@ if (is_array($temp)) { $index = 7; } //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp[$index][' cfwHardwareStatusValue'], 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp[$index][' cfwHardwareStatusValue'], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); diff --git a/includes/discovery/sensors/state/axiscam.inc.php b/includes/discovery/sensors/state/axiscam.inc.php index f8583068ea..467db59c91 100644 --- a/includes/discovery/sensors/state/axiscam.inc.php +++ b/includes/discovery/sensors/state/axiscam.inc.php @@ -3,7 +3,7 @@ echo 'AXIS States'; // Temp Sensor Status -$oids_tmp = snmpwalk_cache_multi_oid($device, 'tempSensorTable', array(), 'AXIS-VIDEO-MIB'); +$oids_tmp = snmpwalk_cache_multi_oid($device, 'tempSensorTable', [], 'AXIS-VIDEO-MIB'); $cur_oid = '.1.3.6.1.4.1.368.4.1.3.1.3.1.'; // Exclude from $oids content .common string @@ -14,30 +14,16 @@ foreach ($oids_tmp as $key_oids_tmp => $val_oids_tmp) { if (is_array($oids)) { //Create State Index $state_name = 'tempSensorStatusState'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'Normal',0,1,0) , - array($state_index_id,'Failed',0,2,2) , - array($state_index_id,'Out Of Boundary',0,3,2) , - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'Failed'], + ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'Out Of Boundary'], + ]; + create_state_index($state_name, $states); foreach ($oids as $index => $entry) { //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, 'Temperature Sensor '.$index, '1', '1', null, null, null, null, $entry['tempSensorStatus'], 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, 'Temperature Sensor '.$index, 1, 1, null, null, null, null, $entry['tempSensorStatus'], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); @@ -45,35 +31,21 @@ if (is_array($oids)) { } // Storage Status -$oids = snmpwalk_cache_multi_oid($device, 'storageTable', array(), 'AXIS-VIDEO-MIB'); +$oids = snmpwalk_cache_multi_oid($device, 'storageTable', [], 'AXIS-VIDEO-MIB'); $cur_oid = '.1.3.6.1.4.1.368.4.1.8.1.3.'; if (is_array($oids)) { //Create State Index $state_name = 'storageDisruptionDetectedState'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'Normal',0,1,0) , - array($state_index_id,'Failed',0,2,2) , - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'Failed'], + ]; + create_state_index($state_name, $states); foreach ($oids as $index => $entry) { //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, 'Storage Status: ' .$entry['storageName'], '1', '1', null, null, null, null, $entry['storageDisruptionDetected'], 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, 'Storage Status: ' .$entry['storageName'], 1, 1, null, null, null, null, $entry['storageDisruptionDetected'], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); diff --git a/includes/discovery/sensors/state/boss.inc.php b/includes/discovery/sensors/state/boss.inc.php index 5dc53f8920..8d88b3f837 100644 --- a/includes/discovery/sensors/state/boss.inc.php +++ b/includes/discovery/sensors/state/boss.inc.php @@ -6,44 +6,30 @@ */ if ($device['os'] === 'boss') { - $oid = snmpwalk_cache_oid($device, 's5ChasComTable', array(), 'S5-CHASSIS-MIB'); + $oid = snmpwalk_cache_oid($device, 's5ChasComTable', [], 'S5-CHASSIS-MIB'); $cur_oid = '.1.3.6.1.4.1.45.1.6.3.3.1.1.10.'; if (is_array($oid)) { //get states $state_name = 's5ChasComOperState'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'other' ,0,1,3) , - array($state_index_id,'notAvail' ,0,2,3) , - array($state_index_id,'removed' ,0,3,3) , - array($state_index_id,'disabled' ,0,4,3) , - array($state_index_id,'normal' ,0,5,0) , - array($state_index_id,'resetInProg',0,6,1) , - array($state_index_id,'testing' ,0,7,1) , - array($state_index_id,'warning' ,0,8,1) , - array($state_index_id,'nonFatalErr',0,9,1) , - array($state_index_id,'fatalErr' ,0,10,2) , - array($state_index_id,'notConfig' ,0,11,3) , - array($state_index_id,'obsoleted' ,0,12,3) - ); - } - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } + $states = [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'other'], + ['value' => 2, 'generic' => 3, 'graph' => 0, 'descr' => 'notAvail'], + ['value' => 3, 'generic' => 3, 'graph' => 0, 'descr' => 'removed'], + ['value' => 4, 'generic' => 3, 'graph' => 0, 'descr' => 'disabled'], + ['value' => 5, 'generic' => 0, 'graph' => 0, 'descr' => 'normal'], + ['value' => 6, 'generic' => 1, 'graph' => 0, 'descr' => 'resetInProg'], + ['value' => 7, 'generic' => 1, 'graph' => 0, 'descr' => 'testing'], + ['value' => 8, 'generic' => 1, 'graph' => 0, 'descr' => 'warning'], + ['value' => 9, 'generic' => 1, 'graph' => 0, 'descr' => 'nonFatalErr'], + ['value' => 10, 'generic' => 2, 'graph' => 0, 'descr' => 'fatalErr'], + ['value' => 11, 'generic' => 3, 'graph' => 0, 'descr' => 'notConfig'], + ['value' => 12, 'generic' => 3, 'graph' => 0, 'descr' => 'obsoleted'], + ]; + create_state_index($state_name, $states); // get fans (6) and temp (5) sensor only from walk - $ers_sensors = array(); + $ers_sensors = []; foreach ($oid as $key => $value) { if ($key['s5ChasComGrpIndx'] == 5 || $key['s5ChasComGrpIndx'] == 6) { $ers_sensors[$key] = $value; @@ -56,7 +42,7 @@ if ($device['os'] === 'boss') { $unit = floor($unit_array[1]/10); $descr = "Unit $unit: $entry[s5ChasComDescr]"; //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, "s5ChasComOperState.$index", $state_name, $descr, '1', '1', null, null, null, null, $entry['s5ChasComOperState']); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, "s5ChasComOperState.$index", $state_name, $descr, 1, 1, null, null, null, null, $entry['s5ChasComOperState']); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, "s5ChasComOperState.$index"); } diff --git a/includes/discovery/sensors/state/cisco.inc.php b/includes/discovery/sensors/state/cisco.inc.php index 68d8df893c..bc0446a557 100644 --- a/includes/discovery/sensors/state/cisco.inc.php +++ b/includes/discovery/sensors/state/cisco.inc.php @@ -10,149 +10,146 @@ * the source code distribution for details. */ -$role_data = snmpwalk_cache_oid($device, 'cswSwitchRole', array(), 'CISCO-STACKWISE-MIB'); +$role_data = snmpwalk_cache_oid($device, 'cswSwitchRole', [], 'CISCO-STACKWISE-MIB'); $redundant_data = snmp_get($device, "cswRingRedundant.0", "-OQv", "CISCO-STACKWISE-MIB"); -$tables = array( - array('ciscoEnvMonVoltageStatusTable','.1.3.6.1.4.1.9.9.13.1.2.1.7.','ciscoEnvMonVoltageState','ciscoEnvMonVoltageStatusDescr', 'CISCO-ENVMON-MIB') , - array('ciscoEnvMonTemperatureStatusTable','.1.3.6.1.4.1.9.9.13.1.3.1.6.','ciscoEnvMonTemperatureState','ciscoEnvMonTemperatureStatusDescr', 'CISCO-ENVMON-MIB') , - array('ciscoEnvMonFanStatusTable','.1.3.6.1.4.1.9.9.13.1.4.1.3.','ciscoEnvMonFanState','ciscoEnvMonFanStatusDescr', 'CISCO-ENVMON-MIB') , - array('ciscoEnvMonSupplyStatusTable','.1.3.6.1.4.1.9.9.13.1.5.1.3.','ciscoEnvMonSupplyState','ciscoEnvMonSupplyStatusDescr', 'CISCO-ENVMON-MIB') , - array('cefcFRUPowerStatusTable','.1.3.6.1.4.1.9.9.117.1.1.2.1.2.','cefcFRUPowerOperStatus','Sensor Name', 'CISCO-ENTITY-FRU-CONTROL-MIB') , - array('cswGlobals','.1.3.6.1.4.1.9.9.500.1.1.3.','cswRingRedundant','Stack Ring - Redundant', 'CISCO-STACKWISE-MIB') , - array('cswSwitchRole','.1.3.6.1.4.1.9.9.500.1.2.1.1.3.','cswSwitchRole','Stack Role - Switch#', 'CISCO-STACKWISE-MIB') , - array('cswSwitchState','.1.3.6.1.4.1.9.9.500.1.2.1.1.6.','cswSwitchState','Stack State - Switch#', 'CISCO-STACKWISE-MIB') , - array('cswStackPortOperStatus','.1.3.6.1.4.1.9.9.500.1.2.2.1.1.','cswStackPortOperStatus','Stack Port Status - ', 'CISCO-STACKWISE-MIB') , - array('cRFCfgRedundancyOperMode','.1.3.6.1.4.1.9.9.176.1.2.14.','cRFCfgRedundancyOperMode','VSS Mode', 'CISCO-RF-MIB') , - array('cRFStatusUnitState','.1.3.6.1.4.1.9.9.176.1.1.2.','cRFStatusUnitState','VSS Device State', 'CISCO-RF-MIB') , - array('cRFStatusPeerUnitState','.1.3.6.1.4.1.9.9.176.1.1.4.','cRFStatusPeerUnitState','VSS Peer State', 'CISCO-RF-MIB') -); +$tables = [ + ['num_oid' => '.1.3.6.1.4.1.9.9.13.1.2.1.7.', 'oid' => 'ciscoEnvMonVoltageStatusTable', 'state_name' => 'ciscoEnvMonVoltageState', 'mib' => 'CISCO-ENVMON-MIB', 'descr' => 'ciscoEnvMonVoltageStatusDescr'], + ['num_oid' => '.1.3.6.1.4.1.9.9.13.1.3.1.6.', 'oid' => 'ciscoEnvMonTemperatureStatusTable', 'state_name' => 'ciscoEnvMonTemperatureState', 'mib' => 'CISCO-ENVMON-MIB', 'descr' => 'ciscoEnvMonTemperatureStatusDescr'], + ['num_oid' => '.1.3.6.1.4.1.9.9.13.1.4.1.3.', 'oid' => 'ciscoEnvMonFanStatusTable', 'state_name' => 'ciscoEnvMonFanState', 'mib' => 'CISCO-ENVMON-MIB', 'descr' => 'ciscoEnvMonFanStatusDescr'], + ['num_oid' => '.1.3.6.1.4.1.9.9.13.1.5.1.3.', 'oid' => 'ciscoEnvMonSupplyStatusTable', 'state_name' => 'ciscoEnvMonSupplyState', 'mib' => 'CISCO-ENVMON-MIB', 'descr' => 'ciscoEnvMonSupplyStatusDescr'], + ['num_oid' => '.1.3.6.1.4.1.9.9.117.1.1.2.1.2.', 'oid' => 'cefcFRUPowerStatusTable', 'state_name' => 'cefcFRUPowerOperStatus', 'mib' => 'CISCO-ENTITY-FRU-CONTROL-MIB', 'descr' => 'Sensor Name'], + ['num_oid' => '.1.3.6.1.4.1.9.9.176.1.1.2.', 'oid' => 'cRFStatusUnitState', 'state_name' => 'cRFStatusUnitState', 'mib' => 'CISCO-RF-MIB', 'descr' => 'VSS Device State'], + ['num_oid' => '.1.3.6.1.4.1.9.9.176.1.1.4.', 'oid' => 'cRFStatusPeerUnitState', 'state_name' => 'cRFStatusPeerUnitState', 'mib' => 'CISCO-RF-MIB', 'descr' => 'VSS Peer State'], + ['num_oid' => '.1.3.6.1.4.1.9.9.176.1.2.14.', 'oid' => 'cRFCfgRedundancyOperMode', 'state_name' => 'cRFCfgRedundancyOperMode', 'mib' => 'CISCO-RF-MIB', 'descr' => 'VSS Mode'], + ['num_oid' => '.1.3.6.1.4.1.9.9.500.1.1.3.', 'oid' => 'cswGlobals', 'state_name' => 'cswRingRedundant', 'mib' => 'CISCO-STACKWISE-MIB', 'descr' => 'Stack Ring - Redundant'], + ['num_oid' => '.1.3.6.1.4.1.9.9.500.1.2.1.1.3.', 'oid' => 'cswSwitchRole', 'state_name' => 'cswSwitchRole', 'mib' => 'CISCO-STACKWISE-MIB', 'descr' => 'Stack Role - Switch#'], + ['num_oid' => '.1.3.6.1.4.1.9.9.500.1.2.1.1.6.', 'oid' => 'cswSwitchState', 'state_name' => 'cswSwitchState', 'mib' => 'CISCO-STACKWISE-MIB', 'descr' => 'Stack State - Switch#'], + ['num_oid' => '.1.3.6.1.4.1.9.9.500.1.2.2.1.1.', 'oid' => 'cswStackPortOperStatus', 'state_name' => 'cswStackPortOperStatus', 'mib' => 'CISCO-STACKWISE-MIB', 'descr' => 'Stack Port Status - '], +]; foreach ($tables as $tablevalue) { //Some switches on 15.x expose this information regardless if they are stacked or not, we try to mitigate that by doing the following. - if (($tablevalue[0] == 'cswGlobals' || $tablevalue[0] == 'cswSwitchRole' || $tablevalue[0] == 'cswSwitchState' || $tablevalue[0] == 'cswStackPortOperStatus') && $redundant_data == 'false' && count($role_data) == 1) { + if (($tablevalue['oid'] == 'cswGlobals' || $tablevalue['oid'] == 'cswSwitchRole' || $tablevalue['oid'] == 'cswSwitchState' || $tablevalue['oid'] == 'cswStackPortOperStatus') && $redundant_data == 'false' && count($role_data) == 1) { continue; } - $temp = snmpwalk_cache_multi_oid($device, $tablevalue[0], array(), $tablevalue[4]); - $cur_oid = $tablevalue[1]; + $temp = snmpwalk_cache_multi_oid($device, $tablevalue['oid'], [], $tablevalue['mib']); + $cur_oid = $tablevalue['num_oid']; if (is_array($temp)) { - if ($temp[0][$tablevalue[2]] == 'nonRedundant' || $temp[0]['cswMaxSwitchNum'] == '1') { + if ($temp[0][$tablevalue['state_name']] == 'nonRedundant' || $temp[0]['cswMaxSwitchNum'] == '1') { break; } //Create State Index - $state_name = $tablevalue[2]; + $state_name = $tablevalue['state_name']; //Create State Translation - if ($state_index_id !== null) { - if ($state_name == 'cRFStatusUnitState' || $state_name == 'cRFStatusPeerUnitState') { - $states = [ - ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'notKnown'], - ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'disabled'], - ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'initialization'], - ['value' => 4, 'generic' => 1, 'graph' => 0, 'descr' => 'negotiation'], - ['value' => 5, 'generic' => 1, 'graph' => 0, 'descr' => 'standbyCold'], - ['value' => 6, 'generic' => 1, 'graph' => 0, 'descr' => 'standbyColdConfig'], - ['value' => 7, 'generic' => 1, 'graph' => 0, 'descr' => 'standbyColdFileSys'], - ['value' => 8, 'generic' => 1, 'graph' => 0, 'descr' => 'standbyColdBulk'], - ['value' => 9, 'generic' => 0, 'graph' => 0, 'descr' => 'standbyHot'], - ['value' => 10, 'generic' => 1, 'graph' => 0, 'descr' => 'activeFast'], - ['value' => 11, 'generic' => 1, 'graph' => 0, 'descr' => 'activeDrain'], - ['value' => 12, 'generic' => 1, 'graph' => 0, 'descr' => 'activePreconfig'], - ['value' => 13, 'generic' => 1, 'graph' => 0, 'descr' => 'activePostconfig'], - ['value' => 14, 'generic' => 0, 'graph' => 0, 'descr' => 'active'], - ['value' => 15, 'generic' => 1, 'graph' => 0, 'descr' => 'activeExtraload'], - ['value' => 16, 'generic' => 1, 'graph' => 0, 'descr' => 'activeHandback'] - ]; - } elseif ($state_name == 'cRFCfgRedundancyOperMode') { - $states = [ - ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'nonRedundant'], - ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'staticLoadShareNonRedundant'], - ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'dynamicLoadShareNonRedundant'], - ['value' => 4, 'generic' => 0, 'graph' => 0, 'descr' => 'staticLoadShareRedundant'], - ['value' => 5, 'generic' => 0, 'graph' => 0, 'descr' => 'dynamicLoadShareRedundant'], - ['value' => 6, 'generic' => 0, 'graph' => 0, 'descr' => 'coldStandbyRedundant'], - ['value' => 7, 'generic' => 0, 'graph' => 0, 'descr' => 'warmStandbyRedundant'], - ['value' => 8, 'generic' => 0, 'graph' => 0, 'descr' => 'hotStandbyRedundant'] - ]; - } elseif ($state_name == 'cswRingRedundant') { - $states = [ - ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'true'], - ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'false'] - ]; - } elseif ($state_name == 'cswSwitchRole') { - $states = [ - ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'master'], - ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'member'], - ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'notMember'], - ['value' => 4, 'generic' => 0, 'graph' => 0, 'descr' => 'standby'] - ]; - } elseif ($state_name == 'cswSwitchState') { - $states = [ - ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'waiting'], - ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'progressing'], - ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'added'], - ['value' => 4, 'generic' => 0, 'graph' => 0, 'descr' => 'ready'], - ['value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'sdmMismatch'], - ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'verMismatch'], - ['value' => 7, 'generic' => 2, 'graph' => 0, 'descr' => 'featureMismatch'], - ['value' => 8, 'generic' => 2, 'graph' => 0, 'descr' => 'newMasterInit'], - ['value' => 9, 'generic' => 1, 'graph' => 0, 'descr' => 'provisioned'], - ['value' => 10, 'generic' => 2, 'graph' => 0, 'descr' => 'invalid'], - ['value' => 11, 'generic' => 1, 'graph' => 0, 'descr' => 'removed'] - ]; - } elseif ($state_name == 'cefcFRUPowerOperStatus') { - $states = [ - ['value' => 1, 'generic' => 2, 'graph' => 0, 'descr' => 'off (other)'], - ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'on'], - ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'off (admin)'], - ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'off (denied)'], - ['value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'off (environmental)'], - ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'off (temperature)'], - ['value' => 7, 'generic' => 2, 'graph' => 0, 'descr' => 'off (fan)'], - ['value' => 8, 'generic' => 2, 'graph' => 0, 'descr' => 'failed'], - ['value' => 9, 'generic' => 1, 'graph' => 0, 'descr' => 'on (fan failed)'], - ['value' => 10, 'generic' => 2, 'graph' => 0, 'descr' => 'off (cooling)'], - ['value' => 11, 'generic' => 2, 'graph' => 0, 'descr' => 'off (connector rating)'], - ['value' => 12, 'generic' => 1, 'graph' => 0, 'descr' => 'on (no inline power)'] - ]; - } else { - $states = [ - ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'normal'], - ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'warning'], - ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'critical'], - ['value' => 4, 'generic' => 3, 'graph' => 0, 'descr' => 'shutdown'], - ['value' => 5, 'generic' => 3, 'graph' => 0, 'descr' => 'notPresent'], - ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'notFunctioning'] - ]; - } - - create_state_index($state_name, $states); + if ($state_name == 'cRFStatusUnitState' || $state_name == 'cRFStatusPeerUnitState') { + $states = [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'notKnown'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'disabled'], + ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'initialization'], + ['value' => 4, 'generic' => 1, 'graph' => 0, 'descr' => 'negotiation'], + ['value' => 5, 'generic' => 1, 'graph' => 0, 'descr' => 'standbyCold'], + ['value' => 6, 'generic' => 1, 'graph' => 0, 'descr' => 'standbyColdConfig'], + ['value' => 7, 'generic' => 1, 'graph' => 0, 'descr' => 'standbyColdFileSys'], + ['value' => 8, 'generic' => 1, 'graph' => 0, 'descr' => 'standbyColdBulk'], + ['value' => 9, 'generic' => 0, 'graph' => 0, 'descr' => 'standbyHot'], + ['value' => 10, 'generic' => 1, 'graph' => 0, 'descr' => 'activeFast'], + ['value' => 11, 'generic' => 1, 'graph' => 0, 'descr' => 'activeDrain'], + ['value' => 12, 'generic' => 1, 'graph' => 0, 'descr' => 'activePreconfig'], + ['value' => 13, 'generic' => 1, 'graph' => 0, 'descr' => 'activePostconfig'], + ['value' => 14, 'generic' => 0, 'graph' => 0, 'descr' => 'active'], + ['value' => 15, 'generic' => 1, 'graph' => 0, 'descr' => 'activeExtraload'], + ['value' => 16, 'generic' => 1, 'graph' => 0, 'descr' => 'activeHandback'] + ]; + } elseif ($state_name == 'cRFCfgRedundancyOperMode') { + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'nonRedundant'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'staticLoadShareNonRedundant'], + ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'dynamicLoadShareNonRedundant'], + ['value' => 4, 'generic' => 0, 'graph' => 0, 'descr' => 'staticLoadShareRedundant'], + ['value' => 5, 'generic' => 0, 'graph' => 0, 'descr' => 'dynamicLoadShareRedundant'], + ['value' => 6, 'generic' => 0, 'graph' => 0, 'descr' => 'coldStandbyRedundant'], + ['value' => 7, 'generic' => 0, 'graph' => 0, 'descr' => 'warmStandbyRedundant'], + ['value' => 8, 'generic' => 0, 'graph' => 0, 'descr' => 'hotStandbyRedundant'] + ]; + } elseif ($state_name == 'cswRingRedundant') { + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'true'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'false'] + ]; + } elseif ($state_name == 'cswSwitchRole') { + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'master'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'member'], + ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'notMember'], + ['value' => 4, 'generic' => 0, 'graph' => 0, 'descr' => 'standby'] + ]; + } elseif ($state_name == 'cswSwitchState') { + $states = [ + ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'waiting'], + ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'progressing'], + ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'added'], + ['value' => 4, 'generic' => 0, 'graph' => 0, 'descr' => 'ready'], + ['value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'sdmMismatch'], + ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'verMismatch'], + ['value' => 7, 'generic' => 2, 'graph' => 0, 'descr' => 'featureMismatch'], + ['value' => 8, 'generic' => 2, 'graph' => 0, 'descr' => 'newMasterInit'], + ['value' => 9, 'generic' => 1, 'graph' => 0, 'descr' => 'provisioned'], + ['value' => 10, 'generic' => 2, 'graph' => 0, 'descr' => 'invalid'], + ['value' => 11, 'generic' => 1, 'graph' => 0, 'descr' => 'removed'] + ]; + } elseif ($state_name == 'cefcFRUPowerOperStatus') { + $states = [ + ['value' => 1, 'generic' => 2, 'graph' => 0, 'descr' => 'off (other)'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'on'], + ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'off (admin)'], + ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'off (denied)'], + ['value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'off (environmental)'], + ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'off (temperature)'], + ['value' => 7, 'generic' => 2, 'graph' => 0, 'descr' => 'off (fan)'], + ['value' => 8, 'generic' => 2, 'graph' => 0, 'descr' => 'failed'], + ['value' => 9, 'generic' => 1, 'graph' => 0, 'descr' => 'on (fan failed)'], + ['value' => 10, 'generic' => 2, 'graph' => 0, 'descr' => 'off (cooling)'], + ['value' => 11, 'generic' => 2, 'graph' => 0, 'descr' => 'off (connector rating)'], + ['value' => 12, 'generic' => 1, 'graph' => 0, 'descr' => 'on (no inline power)'] + ]; + } else { + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'normal'], + ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'warning'], + ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'critical'], + ['value' => 4, 'generic' => 3, 'graph' => 0, 'descr' => 'shutdown'], + ['value' => 5, 'generic' => 3, 'graph' => 0, 'descr' => 'notPresent'], + ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'notFunctioning'] + ]; } + create_state_index($state_name, $states); foreach ($temp as $index => $entry) { - if ($tablevalue[2] == 'ciscoEnvMonTemperatureState' && (empty($temp[$index][$tablevalue[3]]))) { + if ($tablevalue['state_name'] == 'ciscoEnvMonTemperatureState' && (empty($temp[$index][$tablevalue['descr']]))) { d_echo('Invalid sensor, skipping..'); } else { //Discover Sensors - $descr = ucwords($temp[$index][$tablevalue[3]]); + $descr = ucwords($temp[$index][$tablevalue['descr']]); if ($state_name == 'cRFStatusUnitState' || $state_name == 'cRFStatusPeerUnitState' || $state_name == 'cRFCfgRedundancyOperMode' || $state_name == 'cswRingRedundant') { - $descr = $tablevalue[3]; + $descr = $tablevalue['descr']; } elseif ($state_name == 'cswSwitchRole') { $swrolenumber++; - $descr = $tablevalue[3] . $swrolenumber; + $descr = $tablevalue['descr'] . $swrolenumber; } elseif ($state_name == 'cswSwitchState') { $swstatenumber++; - $descr = $tablevalue[3] . $swstatenumber; + $descr = $tablevalue['descr'] . $swstatenumber; } elseif ($state_name == 'cswStackPortOperStatus') { $stack_port_descr = get_port_by_index_cache($device['device_id'], $index); - $descr = $tablevalue[3] . $stack_port_descr['ifDescr']; + $descr = $tablevalue['descr'] . $stack_port_descr['ifDescr']; } elseif ($state_name == 'cefcFRUPowerOperStatus') { $descr = snmp_get($device, 'entPhysicalName.'.$index, '-Oqv', 'ENTITY-MIB'); } - discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp[$index][$tablevalue[2]], 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp[$index][$tablevalue['state_name']], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); diff --git a/includes/discovery/sensors/state/ciscosb.inc.php b/includes/discovery/sensors/state/ciscosb.inc.php index 00883331cb..c05f2d846f 100644 --- a/includes/discovery/sensors/state/ciscosb.inc.php +++ b/includes/discovery/sensors/state/ciscosb.inc.php @@ -10,38 +10,24 @@ * the source code distribution for details. */ -$temp = snmpwalk_cache_multi_oid($device, 'swIfOperSuspendedStatus', array(), 'CISCOSB-rlInterfaces'); +$temp = snmpwalk_cache_multi_oid($device, 'swIfOperSuspendedStatus', [], 'CISCOSB-rlInterfaces'); $cur_oid = '.1.3.6.1.4.1.9.6.1.101.43.1.1.24.'; if (is_array($temp)) { //Create State Index $state_name = 'swIfOperSuspendedStatus'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id !== null) { - $states = array( - array($state_index_id, 'true', 0, 1, 2), - array($state_index_id, 'false', 0, 2, 0), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 2, 'graph' => 0, 'descr' => 'true'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'false'], + ]; + create_state_index($state_name, $states); foreach ($temp as $index => $entry) { $port_descr = get_port_by_index_cache($device['device_id'], str_replace('1.', '', $index)); $descr = $port_descr['ifDescr'] . ' Suspended Status'; if (str_contains($descr, ['ethernet','Ethernet'])) { //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp[$index]['swIfOperSuspendedStatus'], 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp[$index]['swIfOperSuspendedStatus'], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); diff --git a/includes/discovery/sensors/state/commander-plus.inc.php b/includes/discovery/sensors/state/commander-plus.inc.php index b56702dce9..e31e4f4519 100644 --- a/includes/discovery/sensors/state/commander-plus.inc.php +++ b/includes/discovery/sensors/state/commander-plus.inc.php @@ -24,28 +24,18 @@ */ $start_oid = '.1.3.6.1.4.1.18642.1.2.4'; -$state_table = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.18642.1.2.4', array(), 'CCPOWER-MIB'); +$state_table = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.18642.1.2.4', [], 'CCPOWER-MIB'); $x = 1; foreach ($state_table[0] as $state_name => $state_value) { - $state_index_id = create_state_index($state_name); //Create State Translation - $states = array( - array($state_index_id,'inactive',1,1,2), - array($state_index_id,'active',1,2,0), - ); + $states = [ + ['value' => 1, 'generic' => 2, 'graph' => 1, 'descr' => 'inactive'], + ['value' => 2, 'generic' => 0, 'graph' => 1, 'descr' => 'active'], + ]; + create_state_index($state_name, $states); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } $descr = $state_name; - discover_sensor($valid['sensor'], 'state', $device, $start_oid.'.'.$x.'.0', $state_name, $state_name, $descr, '1', '1', null, null, null, null, $state_value, 'snmp'); + discover_sensor($valid['sensor'], 'state', $device, $start_oid.'.'.$x.'.0', $state_name, $state_name, $descr, 1, 1, null, null, null, null, $state_value, 'snmp'); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $state_name); diff --git a/includes/discovery/sensors/state/compas.inc.php b/includes/discovery/sensors/state/compas.inc.php index e53014957e..eeecffea85 100644 --- a/includes/discovery/sensors/state/compas.inc.php +++ b/includes/discovery/sensors/state/compas.inc.php @@ -28,18 +28,18 @@ $index = 'es1dc1DataBatBatTestState'; if (is_numeric($batteryTestState)) { //Create State Index $state_name = 'es1dc1DataBatBatTestState'; - $states = array( - array('value' => 0, 'generic' => 0, 'graph' => 0, 'descr' => 'Never Tested'), - array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Success'), - array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'On Going'), - array('value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: Timeout'), - array('value' => 4, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: Vbus Too Low'), - array('value' => 5, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: Load Too Low'), - array('value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'Failed: AC Failure'), - array('value' => 7, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: Canceled'), - array('value' => 8, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: LVD Opened'), - array('value' => 9, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: No Battery'), - ); + $states = [ + ['value' => 0, 'generic' => 0, 'graph' => 0, 'descr' => 'Never Tested'], + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Success'], + ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'On Going'], + ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: Timeout'], + ['value' => 4, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: Vbus Too Low'], + ['value' => 5, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: Load Too Low'], + ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'Failed: AC Failure'], + ['value' => 7, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: Canceled'], + ['value' => 8, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: LVD Opened'], + ['value' => 9, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: No Battery'], + ]; create_state_index($state_name, $states); $descr = 'Battery Test Status'; @@ -54,13 +54,13 @@ $index = 'es1dc1DataSystemDCMode'; if (is_numeric($dcMode)) { //Create State Index $state_name = 'es1dc1DataSystemDCMode'; - $states = array( - array('value' => 0, 'generic' => 0, 'graph' => 0, 'descr' => 'Float'), - array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Equalize'), - array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Battery Test'), - array('value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'AC Failure'), - array('value' => 5, 'generic' => 0, 'graph' => 0, 'descr' => 'Safe'), - ); + $states = [ + ['value' => 0, 'generic' => 0, 'graph' => 0, 'descr' => 'Float'], + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Equalize'], + ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Battery Test'], + ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'AC Failure'], + ['value' => 5, 'generic' => 0, 'graph' => 0, 'descr' => 'Safe'], + ]; create_state_index($state_name, $states); $descr = 'System DC Mode'; diff --git a/includes/discovery/sensors/state/ctm.inc.php b/includes/discovery/sensors/state/ctm.inc.php index cfa708960e..26fc73b86c 100644 --- a/includes/discovery/sensors/state/ctm.inc.php +++ b/includes/discovery/sensors/state/ctm.inc.php @@ -23,46 +23,46 @@ * @author Paul Heinrichs */ -$states = array( - 'power' => array( - array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Power On'), - array('value' => 0, 'generic' => 1, 'graph' => 0, 'descr' => 'Power Off'), - ), - 'sync' => array( - array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Sync Enabled'), - array('value' => 0, 'generic' => 1, 'graph' => 0, 'descr' => 'Sync Off'), - ) -); -$octetSetup = array( - array( +$states = [ + 'power' => [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Power On'], + ['value' => 0, 'generic' => 1, 'graph' => 0, 'descr' => 'Power Off'], + ], + 'sync' => [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Sync Enabled'], + ['value' => 0, 'generic' => 1, 'graph' => 0, 'descr' => 'Sync Off'], + ] +]; +$octetSetup = [ + [ 'oid' => 'portOnM.0', 'state_name' => 'portOnM', 'states' => $states['power'], 'name' => 'Master Port Enabled', 'num_oid' => '.1.3.6.1.4.1.25868.1.12.0' - ), - array( + ], + [ 'oid' => 'portSyncM.0', 'state_name' => 'portSyncM', 'states' => $states['sync'], 'name' => 'Master Port Sync Status', 'num_oid' => '.1.3.6.1.4.1.25868.1.13.0' - ), - array( + ], + [ 'oid' => 'portOnS.0', 'state_name' => 'portOnS', 'states' => $states['power'], 'name' => 'Slave Port Enabled', 'num_oid' => '.1.3.6.1.4.1.25868.1.29.0' - ), - array( + ], + [ 'oid' => 'portSyncS.0', 'state_name' => 'portSyncS', 'states' => $states['sync'], 'name' => 'Slave Port Sync Status', 'num_oid' => '.1.3.6.1.4.1.25868.1.30.0' - ), -); + ], +]; foreach ($octetSetup as $entry) { $octetString = snmp_get($device, $entry['oid'], "-Ovqe", "CTMMIBCUSTOM"); diff --git a/includes/discovery/sensors/state/dell.inc.php b/includes/discovery/sensors/state/dell.inc.php index 0eccff6700..f0cb3616a6 100644 --- a/includes/discovery/sensors/state/dell.inc.php +++ b/includes/discovery/sensors/state/dell.inc.php @@ -10,116 +10,101 @@ * the source code distribution for details. */ -$tables = array( +$tables = [ // One could add more entrys from deviceGroup, but this will do as a start - array('processorDeviceStatusTable','.1.3.6.1.4.1.674.10892.1.1100.32.1.5.','processorDeviceStatusStatus','processorDeviceStatusLocationName','MIB-Dell-10892') , - array('memoryDeviceTable','.1.3.6.1.4.1.674.10892.1.1100.50.1.5.','memoryDeviceStatus','memoryDeviceLocationName','MIB-Dell-10892') , - array('powerSupplyTable','.1.3.6.1.4.1.674.10892.1.600.12.1.5.','powerSupplyStatus','powerSupplyLocationName','MIB-Dell-10892') , - array('intrusionTable','.1.3.6.1.4.1.674.10892.1.300.70.1.5.','intrusionStatus','Intrusion','MIB-Dell-10892') , - array('controllerTable','.1.3.6.1.4.1.674.10893.1.20.130.1.1.5.','controllerState','controllerName','StorageManagement-MIB') , - array('arrayDiskTable','.1.3.6.1.4.1.674.10893.1.20.130.4.1.4.','arrayDiskState','arrayDiskName','StorageManagement-MIB') , - array('virtualDiskTable','.1.3.6.1.4.1.674.10893.1.20.140.1.1.4.','virtualDiskState','virtualDiskDeviceName','StorageManagement-MIB') , - array('batteryTable','.1.3.6.1.4.1.674.10893.1.20.130.15.1.4.','batteryState','batteryName','StorageManagement-MIB') , -); + ['processorDeviceStatusTable','.1.3.6.1.4.1.674.10892.1.1100.32.1.5.','processorDeviceStatusStatus','processorDeviceStatusLocationName','MIB-Dell-10892'], + ['memoryDeviceTable','.1.3.6.1.4.1.674.10892.1.1100.50.1.5.','memoryDeviceStatus','memoryDeviceLocationName','MIB-Dell-10892'], + ['powerSupplyTable','.1.3.6.1.4.1.674.10892.1.600.12.1.5.','powerSupplyStatus','powerSupplyLocationName','MIB-Dell-10892'], + ['intrusionTable','.1.3.6.1.4.1.674.10892.1.300.70.1.5.','intrusionStatus','Intrusion','MIB-Dell-10892'], + ['controllerTable','.1.3.6.1.4.1.674.10893.1.20.130.1.1.5.','controllerState','controllerName','StorageManagement-MIB'], + ['arrayDiskTable','.1.3.6.1.4.1.674.10893.1.20.130.4.1.4.','arrayDiskState','arrayDiskName','StorageManagement-MIB'], + ['virtualDiskTable','.1.3.6.1.4.1.674.10893.1.20.140.1.1.4.','virtualDiskState','virtualDiskDeviceName','StorageManagement-MIB'], + ['batteryTable','.1.3.6.1.4.1.674.10893.1.20.130.15.1.4.','batteryState','batteryName','StorageManagement-MIB'], +]; foreach ($tables as $tablevalue) { - $temp = snmpwalk_cache_multi_oid($device, $tablevalue[0], array(), $tablevalue[4]); + $temp = snmpwalk_cache_multi_oid($device, $tablevalue[0], [], $tablevalue[4]); $cur_oid = $tablevalue[1]; if (is_array($temp)) { //Create State Index $state_name = $tablevalue[2]; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id !== null) { - if ($state_name == 'processorDeviceStatusStatus' || $state_name == 'memoryDeviceStatus' || $state_name == 'powerSupplyStatus' || $state_name == 'intrusionStatus') { - $states = array( - array($state_index_id,'other',0,1,3) , - array($state_index_id,'unknown',0,2,3) , - array($state_index_id,'ok',0,3,0) , - array($state_index_id,'nonCritical',0,4,1) , - array($state_index_id,'critical',0,5,2) , - array($state_index_id,'nonRecoverable',0,6,2) - ); - } elseif ($state_name == 'controllerState') { - $states = array( - array($state_index_id,'ready',0,1,0) , - array($state_index_id,'failed',0,2,2) , - array($state_index_id,'online',0,3,0) , - array($state_index_id,'offline',0,4,1) , - array($state_index_id,'degraded',0,6,2) - ); - } elseif ($state_name == 'arrayDiskState') { - $states = array( - array($state_index_id,'ready',0,1,0) , - array($state_index_id,'failed',0,2,2) , - array($state_index_id,'online',0,3,0) , - array($state_index_id,'offline',0,4,2) , - array($state_index_id,'degraded',0,5,2) , - array($state_index_id,'recovering',0,6,1) , - array($state_index_id,'removed',0,7,1) , - array($state_index_id,'non-raid',0,8,3) , - array($state_index_id,'notReady',0,9,1) , - array($state_index_id,'resynching',0,10,1) , - array($state_index_id,'replacing',0,11,1) , - array($state_index_id,'spinningDown',0,12,1) , - array($state_index_id,'rebuild',0,13,1) , - array($state_index_id,'noMedia',0,14,1) , - array($state_index_id,'formatting',0,15,1) , - array($state_index_id,'diagnostics',0,16,1) , - array($state_index_id,'predictiveFailure',0,17,2) , - array($state_index_id,'initializing',0,18,1) , - array($state_index_id,'foreign',0,19,1) , - array($state_index_id,'clear',0,20,1) , - array($state_index_id,'unsupported',0,21,2) , - array($state_index_id,'incompatible',0,22,2) , - array($state_index_id,'readOnly',0,23,2) - ); - } elseif ($state_name == 'virtualDiskState') { - $states = array( - array($state_index_id,'unknown',0,0,3) , - array($state_index_id,'ready',1,1,0) , - array($state_index_id,'failed',1,2,2) , - array($state_index_id,'online',1,3,1) , - array($state_index_id,'offline',1,4,2) , - array($state_index_id,'degraded',1,6,2) , - array($state_index_id,'verifying',1,7,1) , - array($state_index_id,'resynching',1,15,1) , - array($state_index_id,'regenerating',1,16,1) , - array($state_index_id,'failedRedundancy',1,18,2) , - array($state_index_id,'rebuilding',1,24,1) , - array($state_index_id,'formatting',1,26,1) , - array($state_index_id,'reconstructing',1,32,1) , - array($state_index_id,'initializing',1,35,1) , - array($state_index_id,'backgroundInit',1,36,1) , - array($state_index_id,'permanentlyDegraded',1,52,2) - ); - } elseif ($state_name == 'batteryState') { - $states = array( - array($state_index_id,'ready',0,1,0) , - array($state_index_id,'failed',1,2,2) , - array($state_index_id,'degraded',1,6,2) , - array($state_index_id,'reconditioning',1,7,1) , - array($state_index_id,'high',1,9,1) , - array($state_index_id,'low',1,10,1) , - array($state_index_id,'charging',1,12,1) , - array($state_index_id,'missing',1,21,2) , - array($state_index_id,'learning',1,36,1) - ); - } - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } + if ($state_name == 'processorDeviceStatusStatus' || $state_name == 'memoryDeviceStatus' || $state_name == 'powerSupplyStatus' || $state_name == 'intrusionStatus') { + $states = [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'other'], + ['value' => 2, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'ok'], + ['value' => 4, 'generic' => 1, 'graph' => 0, 'descr' => 'nonCritical'], + ['value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'critical'], + ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'nonRecoverable'], + ]; + } elseif ($state_name == 'controllerState') { + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'ready'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'failed'], + ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'online'], + ['value' => 4, 'generic' => 1, 'graph' => 0, 'descr' => 'offline'], + ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'degraded'], + ]; + } elseif ($state_name == 'arrayDiskState') { + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'ready'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'failed'], + ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'online'], + ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'offline'], + ['value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'degraded'], + ['value' => 6, 'generic' => 1, 'graph' => 0, 'descr' => 'recovering'], + ['value' => 7, 'generic' => 1, 'graph' => 0, 'descr' => 'removed'], + ['value' => 8, 'generic' => 3, 'graph' => 0, 'descr' => 'non-raid'], + ['value' => 9, 'generic' => 1, 'graph' => 0, 'descr' => 'notReady'], + ['value' => 10, 'generic' => 1, 'graph' => 0, 'descr' => 'resynching'], + ['value' => 11, 'generic' => 1, 'graph' => 0, 'descr' => 'replacing'], + ['value' => 12, 'generic' => 1, 'graph' => 0, 'descr' => 'spinningDown'], + ['value' => 13, 'generic' => 1, 'graph' => 0, 'descr' => 'rebuild'], + ['value' => 14, 'generic' => 1, 'graph' => 0, 'descr' => 'noMedia'], + ['value' => 15, 'generic' => 1, 'graph' => 0, 'descr' => 'formatting'], + ['value' => 16, 'generic' => 1, 'graph' => 0, 'descr' => 'diagnostics'], + ['value' => 17, 'generic' => 2, 'graph' => 0, 'descr' => 'predictiveFailure'], + ['value' => 18, 'generic' => 1, 'graph' => 0, 'descr' => 'initializing'], + ['value' => 19, 'generic' => 1, 'graph' => 0, 'descr' => 'foreign'], + ['value' => 20, 'generic' => 1, 'graph' => 0, 'descr' => 'clear'], + ['value' => 21, 'generic' => 2, 'graph' => 0, 'descr' => 'unsupported'], + ['value' => 22, 'generic' => 2, 'graph' => 0, 'descr' => 'incompatible'], + ['value' => 23, 'generic' => 2, 'graph' => 0, 'descr' => 'readOnly'], + ]; + } elseif ($state_name == 'virtualDiskState') { + $states = [ + ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'ready'], + ['value' => 2, 'generic' => 2, 'graph' => 1, 'descr' => 'failed'], + ['value' => 3, 'generic' => 1, 'graph' => 1, 'descr' => 'online'], + ['value' => 4, 'generic' => 2, 'graph' => 1, 'descr' => 'offline'], + ['value' => 6, 'generic' => 2, 'graph' => 1, 'descr' => 'degraded'], + ['value' => 7, 'generic' => 1, 'graph' => 1, 'descr' => 'verifying'], + ['value' => 15, 'generic' => 1, 'graph' => 1, 'descr' => 'resynching'], + ['value' => 16, 'generic' => 1, 'graph' => 1, 'descr' => 'regenerating'], + ['value' => 18, 'generic' => 2, 'graph' => 1, 'descr' => 'failedRedundancy'], + ['value' => 24, 'generic' => 1, 'graph' => 1, 'descr' => 'rebuilding'], + ['value' => 26, 'generic' => 1, 'graph' => 1, 'descr' => 'formatting'], + ['value' => 32, 'generic' => 1, 'graph' => 1, 'descr' => 'reconstructing'], + ['value' => 35, 'generic' => 1, 'graph' => 1, 'descr' => 'initializing'], + ['value' => 36, 'generic' => 1, 'graph' => 1, 'descr' => 'backgroundInit'], + ['value' => 52, 'generic' => 2, 'graph' => 1, 'descr' => 'permanentlyDegraded'], + ]; + } elseif ($state_name == 'batteryState') { + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'ready'], + ['value' => 2, 'generic' => 2, 'graph' => 1, 'descr' => 'failed'], + ['value' => 6, 'generic' => 2, 'graph' => 1, 'descr' => 'degraded'], + ['value' => 7, 'generic' => 1, 'graph' => 1, 'descr' => 'reconditioning'], + ['value' => 9, 'generic' => 1, 'graph' => 1, 'descr' => 'high'], + ['value' => 10, 'generic' => 1, 'graph' => 1, 'descr' => 'low'], + ['value' => 12, 'generic' => 1, 'graph' => 1, 'descr' => 'charging'], + ['value' => 21, 'generic' => 2, 'graph' => 1, 'descr' => 'missing'], + ['value' => 36, 'generic' => 1, 'graph' => 1, 'descr' => 'learning'], + ]; } + create_state_index($state_name, $states); foreach ($temp as $index => $entry) { if (strpos($index, '54.') === false) { //Because Dell is buggy @@ -133,7 +118,7 @@ foreach ($tables as $tablevalue) { $descr = clean($temp[$index][$tablevalue[3]]); // Use clean as virtualDiskDeviceName is user defined } //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp[$index][$tablevalue[2]], 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp[$index][$tablevalue[2]], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); diff --git a/includes/discovery/sensors/state/drac.inc.php b/includes/discovery/sensors/state/drac.inc.php index 48fff7b0c2..b04c299d37 100644 --- a/includes/discovery/sensors/state/drac.inc.php +++ b/includes/discovery/sensors/state/drac.inc.php @@ -21,7 +21,7 @@ $tables = [ foreach ($tables as $tablevalue) { list($table_oid, $num_oid, $value_oid, $descr_oid) = $tablevalue; - $temp = snmpwalk_cache_multi_oid($device, $table_oid, array(), 'IDRAC-MIB-SMIv2', null, '-OQUse'); + $temp = snmpwalk_cache_multi_oid($device, $table_oid, [], 'IDRAC-MIB-SMIv2', null, '-OQUse'); // '-OQUsetX' if (!empty($temp)) { diff --git a/includes/discovery/sensors/state/dsm.inc.php b/includes/discovery/sensors/state/dsm.inc.php index 41ba89d2c1..1a7ce7facc 100644 --- a/includes/discovery/sensors/state/dsm.inc.php +++ b/includes/discovery/sensors/state/dsm.inc.php @@ -10,28 +10,14 @@ $index = '0'; if (is_numeric($state)) { //Create State Index $state_name = 'systemStatusState'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'Normal',0,1,0) , - array($state_index_id,'Failed',0,2,2) , - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'Failed'], + ]; + create_state_index($state_name, $states); //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'System Status', '1', '1', null, null, null, null, $state, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'System Status', 1, 1, null, null, null, null, $state, 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); @@ -45,28 +31,14 @@ $index = '0'; if (is_numeric($state)) { //Create State Index $state_name = 'powerStatusState'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'Normal',0,1,0) , - array($state_index_id,'Failed',0,2,2) , - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'Failed'], + ]; + create_state_index($state_name, $states); //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'Power Status', '1', '1', null, null, null, null, $state, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'Power Status', 1, 1, null, null, null, null, $state, 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); @@ -80,29 +52,15 @@ $index = '0'; if (is_numeric($state)) { //Create State Index $state_name = 'systemFanStatusState'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'Normal',0,1,0) , - array($state_index_id,'Failed',0,2,2) , - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'Failed'], + ]; + create_state_index($state_name, $states); //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'System Fan Status', '1', '1', null, null, null, null, $state, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'System Fan Status', 1, 1, null, null, null, null, $state, 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); @@ -116,28 +74,14 @@ $index = '0'; if (is_numeric($state)) { //Create State Index $state_name = 'cpuFanStatusState'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'Normal',0,1,0) , - array($state_index_id,'Failed',0,2,2) , - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'Failed'], + ]; + create_state_index($state_name, $states); //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'CPU Fan Status', '1', '1', null, null, null, null, $state, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'CPU Fan Status', 1, 1, null, null, null, null, $state, 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); @@ -151,74 +95,48 @@ $index = '0'; if (is_numeric($state)) { //Create State Index $state_name = 'upgradeAvailableState'; - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'Available',0,1,1) , - array($state_index_id,'Unavailable',0,2,0) , - array($state_index_id,'Connecting',0,3,3) , - array($state_index_id,'Disconnected',0,4,3) , - array($state_index_id,'Others',0,5,3) , - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'Available'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Unavailable'], + ['value' => 3, 'generic' => 3, 'graph' => 0, 'descr' => 'Connecting'], + ['value' => 4, 'generic' => 3, 'graph' => 0, 'descr' => 'Disconnected'], + ['value' => 5, 'generic' => 3, 'graph' => 0, 'descr' => 'Others'], + ]; + create_state_index($state_name, $states); //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'Upgrade Availability', '1', '1', null, null, null, null, $state, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'Upgrade Availability', 1, 1, null, null, null, null, $state, 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); } // RAID Status OID (Value : 1 Normal, 2 Repairing, 3 Migrating, 4 Expanding, 5 Deleting, 6 Creating, 7 RaidSyncing, 8 RaidParityChecking, 9 RaidAssembling, 10 Canceling, 11 Degrade, 12 Crashed) -$oids = snmpwalk_cache_multi_oid($device, 'raidTable', array(), 'SYNOLOGY-RAID-MIB'); +$oids = snmpwalk_cache_multi_oid($device, 'raidTable', [], 'SYNOLOGY-RAID-MIB'); $cur_oid = '.1.3.6.1.4.1.6574.3.1.1.3.'; if (is_array($oids)) { //Create State Index $state_name = 'raidStatusState'; - $state_index_id = create_state_index($state_name); + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'], + ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Repairing'], + ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'Migrating'], + ['value' => 4, 'generic' => 1, 'graph' => 0, 'descr' => 'Expanding'], + ['value' => 5, 'generic' => 1, 'graph' => 0, 'descr' => 'Deleting'], + ['value' => 6, 'generic' => 1, 'graph' => 0, 'descr' => 'Creating'], + ['value' => 7, 'generic' => 1, 'graph' => 0, 'descr' => 'RaidSyncing'], + ['value' => 8, 'generic' => 1, 'graph' => 0, 'descr' => 'RaidParityChecking'], + ['value' => 9, 'generic' => 1, 'graph' => 0, 'descr' => 'RaidAssembling'], + ['value' => 10, 'generic' => 1, 'graph' => 0, 'descr' => 'Canceling'], + ['value' => 11, 'generic' => 2, 'graph' => 0, 'descr' => 'Degrade'], + ['value' => 12, 'generic' => 2, 'graph' => 0, 'descr' => 'Crashed'], + ]; + create_state_index($state_name, $states); - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'Normal',0,1,0) , - array($state_index_id,'Repairing',0,2,1) , - array($state_index_id,'Migrating',0,3,1) , - array($state_index_id,'Expanding',0,4,1) , - array($state_index_id,'Deleting',0,5,1) , - array($state_index_id,'Creating',0,6,1) , - array($state_index_id,'RaidSyncing',0,7,1) , - array($state_index_id,'RaidParityChecking',0,8,1) , - array($state_index_id,'RaidAssembling',0,9,1) , - array($state_index_id,'Canceling',0,10,1) , - array($state_index_id,'Degrade',0,11,2) , - array($state_index_id,'Crashed',0,12,2) , - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } foreach ($oids as $index => $entry) { //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, 'RAID Status', '1', '1', null, null, null, null, $entry['raidStatus'], 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, 'RAID Status', 1, 1, null, null, null, null, $entry['raidStatus'], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); @@ -226,37 +144,24 @@ if (is_array($oids)) { } // Disks Status OID (Value : 1 Normal, 2 Initialized, 3 Not Initialized, 4 System Partition Failed, 5 Crashed ) -$oids = snmpwalk_cache_multi_oid($device, 'diskTable', array(), 'SYNOLOGY-DISK-MIB'); +$oids = snmpwalk_cache_multi_oid($device, 'diskTable', [], 'SYNOLOGY-DISK-MIB'); $cur_oid = '.1.3.6.1.4.1.6574.2.1.1.5.'; if (is_array($oids)) { //Create State Index $state_name = 'diskStatusState'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'Normal',0,1,0) , - array($state_index_id,'Initialized',0,2,1) , - array($state_index_id,'Not Initialized',0,3,1) , - array($state_index_id,'System Partition Failed',0,4,2) , - array($state_index_id,'Crashed',0,5,2) , - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'], + ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'Initialized'], + ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'Not Initialized'], + ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'System Partition Failed'], + ['value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'Crashed'], + ]; + create_state_index($state_name, $states); + foreach ($oids as $index => $entry) { //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, 'Disk Status '.$index, '1', '1', null, null, null, null, $entry['diskStatus'], 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, 'Disk Status '.$index, 1, 1, null, null, null, null, $entry['diskStatus'], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); diff --git a/includes/discovery/sensors/state/eltek-webpower.inc.php b/includes/discovery/sensors/state/eltek-webpower.inc.php index e97450dc46..20473ca324 100644 --- a/includes/discovery/sensors/state/eltek-webpower.inc.php +++ b/includes/discovery/sensors/state/eltek-webpower.inc.php @@ -24,17 +24,18 @@ */ // Battery banks symmetry status discovery -$symmetry_oid = array('.1.3.6.1.4.1.12148.9.3.19.3.1.3.0', - '.1.3.6.1.4.1.12148.9.3.19.3.1.6.0', - '.1.3.6.1.4.1.12148.9.3.19.3.1.9.0', - '.1.3.6.1.4.1.12148.9.3.19.3.1.12.0', - '.1.3.6.1.4.1.12148.9.3.19.3.1.15.0', - '.1.3.6.1.4.1.12148.9.3.19.3.1.18.0', - '.1.3.6.1.4.1.12148.9.3.19.3.1.21.0', - '.1.3.6.1.4.1.12148.9.3.19.3.1.24.0' -); +$symmetry_oid = [ + '.1.3.6.1.4.1.12148.9.3.19.3.1.3.0', + '.1.3.6.1.4.1.12148.9.3.19.3.1.6.0', + '.1.3.6.1.4.1.12148.9.3.19.3.1.9.0', + '.1.3.6.1.4.1.12148.9.3.19.3.1.12.0', + '.1.3.6.1.4.1.12148.9.3.19.3.1.15.0', + '.1.3.6.1.4.1.12148.9.3.19.3.1.18.0', + '.1.3.6.1.4.1.12148.9.3.19.3.1.21.0', + '.1.3.6.1.4.1.12148.9.3.19.3.1.24.0' +]; $oid = snmp_get_multi($device, 'batteryBanksSymmetry1enable.0 batteryBanksSymmetry2enable.0 batteryBanksSymmetry3enable.0 batteryBanksSymmetry4enable.0 batteryBanksSymmetry5enable.0 batteryBanksSymmetry6enable.0 batteryBanksSymmetry7enable.0 batteryBanksSymmetry8enable.0 batteryBanksSymmetry1status.0 batteryBanksSymmetry2status.0 batteryBanksSymmetry3status.0 batteryBanksSymmetry4status.0 batteryBanksSymmetry5status.0 batteryBanksSymmetry6status.0 batteryBanksSymmetry7status.0 batteryBanksSymmetry8status.0', '-OQUs', 'ELTEK-DISTRIBUTED-MIB'); -$count = array(1, 2, 3, 4, 5, 6, 7, 8); +$count = [1, 2, 3, 4, 5, 6, 7, 8]; foreach ($count as &$countValue) { if ($oid[0]['batteryBanksSymmetry'.$countValue.'enable'] == 'enable') { if ($oid[0]['batteryBanksSymmetry'.$countValue.'status'] == 'ok') { @@ -54,55 +55,22 @@ foreach ($count as &$countValue) { } $state_name = 'batteryBanksSymmetry'.$countValue.'status.0'; - $state_index_id = create_state_index($state_name); - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'ok',0,0,0) , - array($state_index_id,'minorAlarm',0,1,1) , - array($state_index_id,'majorAlarm',0,2,2) , - array($state_index_id,'disabled',0,3,3) , - array($state_index_id,'error',0,4,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 0, 'generic' => 0, 'graph' => 0, 'descr' => 'ok'], + ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'minorAlarm'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'majorAlarm'], + ['value' => 3, 'generic' => 3, 'graph' => 0, 'descr' => 'disabled'], + ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'error'], + ]; + create_state_index($state_name, $states); + $index = 0; $limit = 10; - $warnlimit = null; - $lowlimit = null; - $lowwarnlimit = null; $divisor = 1; $num_oid = $symmetry_oid[$countValue-1]; $state = $state_numeric / $divisor; $descr = 'Battery banks symmetry '.$countValue; - discover_sensor( - $valid['sensor'], - 'state', - $device, - $num_oid, - $index, - $state_name, - $descr, - $divisor, - '1', - $lowlimit, - $lowwarnlimit, - $warnlimit, - $limit, - $state - ); - create_sensor_to_state_index( - $device, - $state_name, - $index - ); + discover_sensor($valid['sensor'], 'state', $device, $num_oid, $index, $state_name, $descr, $divisor, '1', null, null, null, $limit, $state); + create_sensor_to_state_index($device, $state_name, $index); } } diff --git a/includes/discovery/sensors/state/enlogic-pdu.inc.php b/includes/discovery/sensors/state/enlogic-pdu.inc.php index ff3a7c8cb4..a65754e4ec 100644 --- a/includes/discovery/sensors/state/enlogic-pdu.inc.php +++ b/includes/discovery/sensors/state/enlogic-pdu.inc.php @@ -27,33 +27,21 @@ foreach ($pre_cache['enlogic_pdu_status'] as $index => $data) { if (is_array($data)) { $oid = '.1.3.6.1.4.1.38446.1.2.4.1.3.' . $index; $state_name = 'pduUnitStatusLoadState'; - $state_index_id = create_state_index($state_name); $current = $data['pduUnitStatusLoadState']; //Create State Translation - if ($state_index_id !== null) { - $states = array( - array($state_index_id, 'upperCritical', 1, 1, 2), - array($state_index_id, 'upperWarning', 1, 2, 1), - array($state_index_id, 'lowerWarning', 1, 3, 1), - array($state_index_id, 'lowerCritical', 1, 4, 2), - array($state_index_id, 'normal', 1, 5, 0), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 2, 'graph' => 1, 'descr' => 'upperCritical'], + ['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'upperWarning'], + ['value' => 3, 'generic' => 1, 'graph' => 1, 'descr' => 'lowerWarning'], + ['value' => 4, 'generic' => 2, 'graph' => 1, 'descr' => 'lowerCritical'], + ['value' => 5, 'generic' => 0, 'graph' => 1, 'descr' => 'normal'], + ]; + create_state_index($state_name, $states); $descr = "Load state #$index"; //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $current); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $current); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); } @@ -67,29 +55,17 @@ foreach ($pre_cache['enlogic_pdu_input'] as $index => $data) { $current = $data['pduInputPhaseStatusCurrentState']; $descr = "Current state #$index"; if (!is_numeric($current)) { - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id !== null) { - $states = array( - array($state_index_id, 'upperCritical', 1, 1, 2), - array($state_index_id, 'upperWarning', 1, 2, 1), - array($state_index_id, 'lowerWarning', 1, 3, 1), - array($state_index_id, 'lowerCritical', 1, 4, 2), - array($state_index_id, 'normal', 1, 5, 0), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 2, 'graph' => 1, 'descr' => 'upperCritical'], + ['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'upperWarning'], + ['value' => 3, 'generic' => 1, 'graph' => 1, 'descr' => 'lowerWarning'], + ['value' => 4, 'generic' => 2, 'graph' => 1, 'descr' => 'lowerCritical'], + ['value' => 5, 'generic' => 0, 'graph' => 1, 'descr' => 'normal'], + ]; + create_state_index($state_name, $states); + //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $oid, $tmp_index, $state_name, $descr, '1', '1', null, null, null, null, $current); + discover_sensor($valid['sensor'], 'state', $device, $oid, $tmp_index, $state_name, $descr, 1, 1, null, null, null, null, $current); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $tmp_index); } @@ -100,29 +76,17 @@ foreach ($pre_cache['enlogic_pdu_input'] as $index => $data) { $current = $data['pduInputPhaseStatusVoltageState']; $descr = "Voltage state #$index"; if (!is_numeric($current)) { - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id !== null) { - $states = array( - array($state_index_id, 'upperCritical', 1, 1, 2), - array($state_index_id, 'upperWarning', 1, 2, 1), - array($state_index_id, 'lowerWarning', 1, 3, 1), - array($state_index_id, 'lowerCritical', 1, 4, 2), - array($state_index_id, 'normal', 1, 5, 0), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 2, 'graph' => 1, 'descr' => 'upperCritical'], + ['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'upperWarning'], + ['value' => 3, 'generic' => 1, 'graph' => 1, 'descr' => 'lowerWarning'], + ['value' => 4, 'generic' => 2, 'graph' => 1, 'descr' => 'lowerCritical'], + ['value' => 5, 'generic' => 0, 'graph' => 1, 'descr' => 'normal'], + ]; + create_state_index($state_name, $states); + //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $oid, $tmp_index, $state_name, $descr, '1', '1', null, null, null, null, $current); + discover_sensor($valid['sensor'], 'state', $device, $oid, $tmp_index, $state_name, $descr, 1, 1, null, null, null, null, $current); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $tmp_index); } @@ -133,34 +97,22 @@ foreach ($pre_cache['enlogic_pdu_circuit'] as $index => $data) { if (is_array($data)) { $oid = '.1.3.6.1.4.1.38446.1.4.4.1.4.' . $index; $state_name = 'pduCircuitBreakerStatusLoadState'; - $state_index_id = create_state_index($state_name); $current = $data['pduCircuitBreakerStatusLoadState']; if (!is_numeric($current)) { //Create State Translation - if ($state_index_id !== null) { - $states = array( - array($state_index_id, 'upperCritical', 1, 1, 2), - array($state_index_id, 'upperWarning', 1, 2, 1), - array($state_index_id, 'lowerWarning', 1, 3, 1), - array($state_index_id, 'lowerCritical', 1, 4, 2), - array($state_index_id, 'normal', 1, 5, 0), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 2, 'graph' => 1, 'descr' => 'upperCritical'], + ['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'upperWarning'], + ['value' => 3, 'generic' => 1, 'graph' => 1, 'descr' => 'lowerWarning'], + ['value' => 4, 'generic' => 2, 'graph' => 1, 'descr' => 'lowerCritical'], + ['value' => 5, 'generic' => 0, 'graph' => 1, 'descr' => 'normal'], + ]; + create_state_index($state_name, $states); $descr = "Circuit breaker state {$data['pduCircuitBreakerLabel']}"; //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $current); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $current); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); } diff --git a/includes/discovery/sensors/state/equallogic.inc.php b/includes/discovery/sensors/state/equallogic.inc.php index 2d8d01e097..62c15f37aa 100644 --- a/includes/discovery/sensors/state/equallogic.inc.php +++ b/includes/discovery/sensors/state/equallogic.inc.php @@ -40,26 +40,13 @@ if (!empty($oids)) { $descr='Health'; $state_name = 'eqlMemberHealthStatus'; - $state_index_id = create_state_index($state_name); - - if ($state_index_id) { - $states = array( - array($state_index_id,'unknown',0,0,3) , - array($state_index_id,'normal',1,1,0) , - array($state_index_id,'warning',1,2,1) , - array($state_index_id,'critical',1,3,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'normal'], + ['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'warning'], + ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'critical'], + ]; + create_state_index($state_name, $states); foreach (explode("\n", $oids) as $data) { $data = trim($data); @@ -97,26 +84,13 @@ eqlMemberHealthDetailsPowerSupplyCurrentState failed-or-no-data (3) -- has ac but no dc out or we have no data } */ - $state_name1 = 'eqlMemberPowerSupplyCurrentState'; - $state_index_id1 = create_state_index($state_name1); - - if ($state_index_id1) { - $states1 = array( - array($state_index_id1,'on-and-operating',1,1,0) , - array($state_index_id1,'no-ac-power',1,2,1) , - array($state_index_id1,'failed-or-no-data',1,3,2) - ); - foreach ($states1 as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $state_name = 'eqlMemberPowerSupplyCurrentState'; + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'on-and-operating'], + ['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'no-ac-power'], + ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'failed-or-no-data'], + ]; + create_state_index($state_name, $states); foreach (explode("\n", $oids1) as $data) { $data = trim($data); @@ -135,8 +109,8 @@ eqlMemberHealthDetailsPowerSupplyCurrentState $index = (100 + $index); $low_limit = 0.5; $high_limit = 1.5; - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name1, $descr, 1, 1, $low_limit, $low_limit, $high_limit, $high_limit, $pstatus, 'snmp', $index); - create_sensor_to_state_index($device, $state_name1, $index); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, $low_limit, $low_limit, $high_limit, $high_limit, $pstatus, 'snmp', $index); + create_sensor_to_state_index($device, $state_name, $index); } }//end if }//end foreach @@ -151,31 +125,18 @@ d_echo($oids_disks."\n"); $disks_base_oid = '.1.3.6.1.4.1.12740.3.1.1.1.8.1.'; // eqlDiskStatus if (!empty($oids_disks)) { - $disks_state_name = 'eqlDiskStatus'; - $disks_state_index_id = create_state_index($disks_state_name); - - if ($disks_state_index_id) { - $disk_states = array( - array($disks_state_index_id,'on-line',1,1,0), - array($disks_state_index_id,'spare',1,2,0), - array($disks_state_index_id,'failed',1,3,2), - array($disks_state_index_id,'off-line',1,4,1), - array($disks_state_index_id,'alt-sig',1,5,1), - array($disks_state_index_id,'too-small',1,6,2), - array($disks_state_index_id,'history-of-failures',1,7,1), - array($disks_state_index_id,'unsupported-version',1,8,1), - ); - foreach ($disk_states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $state_name = 'eqlDiskStatus'; + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'on-line'], + ['value' => 2, 'generic' => 0, 'graph' => 1, 'descr' => 'spare'], + ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'failed'], + ['value' => 4, 'generic' => 1, 'graph' => 1, 'descr' => 'off-line'], + ['value' => 5, 'generic' => 1, 'graph' => 1, 'descr' => 'alt-sig'], + ['value' => 6, 'generic' => 2, 'graph' => 1, 'descr' => 'too-small'], + ['value' => 7, 'generic' => 0, 'graph' => 1, 'descr' => 'history-of-failures'], + ['value' => 8, 'generic' => 1, 'graph' => 1, 'descr' => 'unsupported-version'], + ]; + create_state_index($state_name, $states); foreach (explode("\n", $oids_disks) as $data) { $data = trim($data); @@ -193,8 +154,8 @@ if (!empty($oids_disks)) { $index = 'eqlDiskStatus.'.$disk_index; $low_limit = 0.5; $high_limit = 1.5; - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $disks_state_name, "Disk $disk_index - $descr", 1, 1, $low_limit, $low_limit, $high_limit, $high_limit, $pstatus, 'snmp', $index); - create_sensor_to_state_index($device, $disks_state_name, $index); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, "Disk $disk_index - $descr", 1, 1, $low_limit, $low_limit, $high_limit, $high_limit, $pstatus, 'snmp', $index); + create_sensor_to_state_index($device, $state_name, $index); unset( $index, $low_limit, diff --git a/includes/discovery/sensors/state/extendair.inc.php b/includes/discovery/sensors/state/extendair.inc.php index abd5edcfd8..7776f5ceb8 100644 --- a/includes/discovery/sensors/state/extendair.inc.php +++ b/includes/discovery/sensors/state/extendair.inc.php @@ -23,329 +23,42 @@ * @author Neil Lathwood */ -$temp = snmp_get($device, 'remLinkState.0', "-Ovqe", "ExaltComProducts"); -$cur_oid = '.1.3.6.1.4.1.25651.1.2.4.2.4.1.1.0'; +// Common States +$states = [ + ['value' => 0, 'generic' => 0, 'graph' => 1, 'descr' => 'almNORMAL'], + ['value' => 1, 'generic' => 1, 'graph' => 1, 'descr' => 'almMINOR'], + ['value' => 2, 'generic' => 2, 'graph' => 1, 'descr' => 'almMAJOR'], + ['value' => 3, 'generic' => 1, 'graph' => 1, 'descr' => 'almDisable'], + ['value' => 4, 'generic' => 1, 'graph' => 1, 'descr' => 'almNotAvailable'], + ['value' => 5, 'generic' => 1, 'graph' => 1, 'descr' => 'almClearChanel'], + ['value' => 6, 'generic' => 1, 'graph' => 1, 'descr' => 'almNonOccupant'], +]; -if (is_numeric($temp)) { - $state_name = 'remLinkState'; - $index = $state_name; - $state_index_id = create_state_index($state_name); +$sensors = [ + ['num_oid' => '.1.3.6.1.4.1.25651.1.2.4.2.4.1.1.0', 'state_name' => 'remLinkState', 'descr' => 'Link status (far end radio)'], + ['num_oid' => '.1.3.6.1.4.1.25651.1.2.4.2.3.1.1.0', 'state_name' => 'locLinkState', 'descr' => 'Link status (local radio)'], + ['num_oid' => '.1.3.6.1.4.1.25651.1.2.4.2.3.1.2.0', 'state_name' => 'locTempAlarm', 'descr' => 'Temperature status (local radio)'], + ['num_oid' => '.1.3.6.1.4.1.25651.1.2.4.2.4.1.2.0', 'state_name' => 'remTempAlarm', 'descr' => 'Temperature status (far end radio)'], + ['num_oid' => '.1.3.6.1.4.1.25651.1.2.4.2.4.1.9.0', 'state_name' => 'remLinkSecMismatch', 'descr' => 'Link security status'], + ['num_oid' => '.1.3.6.1.4.1.25651.1.2.4.2.3.1.15.0', 'state_name' => 'locLinkStateV', 'descr' => 'Vertial link status (local radio)'], + ['num_oid' => '.1.3.6.1.4.1.25651.1.2.4.2.3.1.16.0', 'state_name' => 'locLinkStateH', 'descr' => 'Horizontal link status (local radio)'], + ['num_oid' => '.1.3.6.1.4.1.25651.1.2.4.2.4.1.15.0', 'state_name' => 'remLinkStateV', 'descr' => 'Vertial link status (far end radio)'], + ['num_oid' => '.1.3.6.1.4.1.25651.1.2.4.2.4.1.16.0', 'state_name' => 'remLinkStateH', 'descr' => 'Horizontal link status (far end radio)'], +]; - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'almNORMAL',1,0,0) , - array($state_index_id,'almMINOR',1,1,1) , - array($state_index_id,'almMAJOR',1,2,2) , - array($state_index_id,'almDisable',1,3,1) , - array($state_index_id,'almNotAvailable',1,4,1), - array($state_index_id,'almClearChanel',1,5,1), - array($state_index_id,'almNonOccupant',1,6,1), - ); +foreach ($sensors as $sensor) { + $temp = snmp_get($device, $sensor['state_name'].'.0', "-Ovqe", "ExaltComProducts"); + $cur_oid = $sensor['num_oid']; - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } + if (is_numeric($temp)) { + $state_name = $sensor['state_name']; + $index = $state_name; + create_state_index($state_name, $states); + + $descr = $sensor['descr']; + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp); + create_sensor_to_state_index($device, $state_name, $index); } - - $descr = 'Link status (far end radio)'; - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp); - create_sensor_to_state_index($device, $state_name, $index); -} - -$temp = snmp_get($device, 'locLinkState.0', "-Ovqe", "ExaltComProducts"); -$cur_oid = '.1.3.6.1.4.1.25651.1.2.4.2.3.1.1.0'; - -if (is_numeric($temp)) { - $state_name = 'locLinkState'; - $index = $state_name; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'almNORMAL',1,0,0) , - array($state_index_id,'almMINOR',1,1,1) , - array($state_index_id,'almMAJOR',1,2,2) , - array($state_index_id,'almDisable',1,3,1) , - array($state_index_id,'almNotAvailable',1,4,1), - array($state_index_id,'almClearChanel',1,5,1), - array($state_index_id,'almNonOccupant',1,6,1), - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - $descr = 'Link status (local radio)'; - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp); - create_sensor_to_state_index($device, $state_name, $index); -} - -$temp = snmp_get($device, 'locTempAlarm.0', "-Ovqe", "ExaltComProducts"); -$cur_oid = '.1.3.6.1.4.1.25651.1.2.4.2.3.1.2.0'; - -if (is_numeric($temp)) { - $state_name = 'locTempAlarm'; - $index = $state_name; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'almNORMAL',1,0,0) , - array($state_index_id,'almMINOR',1,1,1) , - array($state_index_id,'almMAJOR',1,2,2) , - array($state_index_id,'almDisable',1,3,1) , - array($state_index_id,'almNotAvailable',1,4,1), - array($state_index_id,'almClearChanel',1,5,1), - array($state_index_id,'almNonOccupant',1,6,1), - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - $descr = 'Temperature status (local radio)'; - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp); - create_sensor_to_state_index($device, $state_name, $index); -} - - -$temp = snmp_get($device, 'remTempAlarm.0', "-Ovqe", "ExaltComProducts"); -$cur_oid = '.1.3.6.1.4.1.25651.1.2.4.2.4.1.2.0'; - -if (is_numeric($temp)) { - $state_name = 'remTempAlarm'; - $index = $state_name; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'almNORMAL',1,0,0) , - array($state_index_id,'almMINOR',1,1,1) , - array($state_index_id,'almMAJOR',1,2,2) , - array($state_index_id,'almDisable',1,3,1) , - array($state_index_id,'almNotAvailable',1,4,1), - array($state_index_id,'almClearChanel',1,5,1), - array($state_index_id,'almNonOccupant',1,6,1), - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - $descr = 'Temperature status (far end radio)'; - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp); - create_sensor_to_state_index($device, $state_name, $index); -} - -$temp = snmp_get($device, 'remLinkSecMismatch.0', "-Ovqe", "ExaltComProducts"); -$cur_oid = '.1.3.6.1.4.1.25651.1.2.4.2.4.1.9.0'; - -if (is_numeric($temp)) { - $state_name = 'remLinkSecMismatch'; - $index = $state_name; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'almNORMAL',1,0,0) , - array($state_index_id,'almMINOR',1,1,1) , - array($state_index_id,'almMAJOR',1,2,2) , - array($state_index_id,'almDisable',1,3,1) , - array($state_index_id,'almNotAvailable',1,4,1), - array($state_index_id,'almClearChanel',1,5,1), - array($state_index_id,'almNonOccupant',1,6,1), - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - $descr = 'Link security status'; - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp); - create_sensor_to_state_index($device, $state_name, $index); -} - -$temp = snmp_get($device, 'locLinkStateV.0', "-Ovqe", "ExaltComProducts"); -$cur_oid = '.1.3.6.1.4.1.25651.1.2.4.2.3.1.15.0'; - -if (is_numeric($temp)) { - $state_name = 'locLinkStateV'; - $index = $state_name; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'almNORMAL',1,0,0) , - array($state_index_id,'almMINOR',1,1,1) , - array($state_index_id,'almMAJOR',1,2,2) , - array($state_index_id,'almDisable',1,3,1) , - array($state_index_id,'almNotAvailable',1,4,1), - array($state_index_id,'almClearChanel',1,5,1), - array($state_index_id,'almNonOccupant',1,6,1), - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - $descr = 'Vertial link status (local radio)'; - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp); - create_sensor_to_state_index($device, $state_name, $index); -} - -$temp = snmp_get($device, 'locLinkStateH.0', "-Ovqe", "ExaltComProducts"); -$cur_oid = '.1.3.6.1.4.1.25651.1.2.4.2.3.1.16.0'; - -if (is_numeric($temp)) { - $state_name = 'locLinkStateH'; - $index = $state_name; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'almNORMAL',1,0,0) , - array($state_index_id,'almMINOR',1,1,1) , - array($state_index_id,'almMAJOR',1,2,2) , - array($state_index_id,'almDisable',1,3,1) , - array($state_index_id,'almNotAvailable',1,4,1), - array($state_index_id,'almClearChanel',1,5,1), - array($state_index_id,'almNonOccupant',1,6,1), - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - $descr = 'Horizontal link status (local radio)'; - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp); - create_sensor_to_state_index($device, $state_name, $index); -} - -$temp = snmp_get($device, 'remLinkStateV.0', "-Ovqe", "ExaltComProducts"); -$cur_oid = '.1.3.6.1.4.1.25651.1.2.4.2.4.1.15.0'; - -if (is_numeric($temp)) { - $state_name = 'remLinkStateV'; - $index = $state_name; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'almNORMAL',1,0,0) , - array($state_index_id,'almMINOR',1,1,1) , - array($state_index_id,'almMAJOR',1,2,2) , - array($state_index_id,'almDisable',1,3,1) , - array($state_index_id,'almNotAvailable',1,4,1), - array($state_index_id,'almClearChanel',1,5,1), - array($state_index_id,'almNonOccupant',1,6,1), - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - $descr = 'Vertial link status (far end radio)'; - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp); - create_sensor_to_state_index($device, $state_name, $index); -} - -$temp = snmp_get($device, 'remLinkStateH.0', "-Ovqe", "ExaltComProducts"); -$cur_oid = '.1.3.6.1.4.1.25651.1.2.4.2.4.1.16.0'; - -if (is_numeric($temp)) { - $state_name = 'remLinkStateH'; - $index = $state_name; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'almNORMAL',1,0,0) , - array($state_index_id,'almMINOR',1,1,1) , - array($state_index_id,'almMAJOR',1,2,2) , - array($state_index_id,'almDisable',1,3,1) , - array($state_index_id,'almNotAvailable',1,4,1), - array($state_index_id,'almClearChanel',1,5,1), - array($state_index_id,'almNonOccupant',1,6,1), - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - $descr = 'Horizontal link status (far end radio)'; - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp); - create_sensor_to_state_index($device, $state_name, $index); } unset( diff --git a/includes/discovery/sensors/state/f5.inc.php b/includes/discovery/sensors/state/f5.inc.php index 7fa0caa2ae..45924dd9bb 100644 --- a/includes/discovery/sensors/state/f5.inc.php +++ b/includes/discovery/sensors/state/f5.inc.php @@ -1,209 +1,134 @@ 0, 'generic' => 2, 'graph' => 0, 'descr' => 'Bad'], + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Good'], + ['value' => 2, 'generic' => 3, 'graph' => 0, 'descr' => 'NotPresent'], +]; +$temp = snmpwalk_cache_multi_oid($device, 'sysChassisPowerSupplyTable', [], 'F5-BIGIP-SYSTEM-MIB'); if (is_array($temp)) { echo 'F5 power supply: '; //Create State Index $state_name = 'sysChassisPowerSupplyStatus'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'Bad',0,0,2) , - array($state_index_id,'Good',0,1,0) , - array($state_index_id,'NotPresent',0,2,3), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], // Value polled from device - 'state_generic_value' => $value[4], // Set value based on the Nagios standard 0=OK, 1=Warning, 2=Critical, 3=Unknown - ); - dbInsert($insert, 'state_translations'); - } - } + create_state_index($state_name, $states); foreach ($temp as $index => $data) { $descr = "sysChassisPowerSupplyStatus.".$temp[$index]['sysChassisPowerSupplyIndex']; $current = $data['sysChassisPowerSupplyStatus']; $sensorType = 'f5'; $oid = '.1.3.6.1.4.1.3375.2.1.3.2.2.2.1.2.'.$index; - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $current, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $current, 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); } // End foreach (array_keys($temp) as $index) } // End if (is_array($temp)) -$temp1 = snmpwalk_cache_multi_oid($device, 'sysCmFailoverStatus', array(), 'F5-BIGIP-SYSTEM-MIB'); - -if (is_array($temp1)) { - echo 'F5 FailOver State: '; - //Create State Index - $state_name = 'sysCmFailoverStatusId'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'Unknown',0,0,3), - array($state_index_id,'OffLine',0,1,2), - array($state_index_id,'ForcedOffline',0,2,2), - array($state_index_id,'Standby',0,3,1), - array($state_index_id,'Active',0,4,0), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], // Value polled from device - 'state_generic_value' => $value[4], // Set value based on the Nagios standard 0=OK, 1=Warning, 2=Critical, 3=Unknown - ); - dbInsert($insert, 'state_translations'); - } - } - - foreach (array_keys($temp1) as $index) { - $descr = "sysCmFailoverStatusId.".$temp1[$index]['sysCmFailoverStatusId']; - $current = $temp1[$index]['sysCmFailoverStatusId']; - $sensorType = 'f5'; - $oid = '.1.3.6.1.4.1.3375.2.1.14.3.1.'.$index; - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $current, 'snmp', $index); - - //Create Sensor To State Index - create_sensor_to_state_index($device, $state_name, $index); - } // End foreach (array_keys($temp1) as $index) -} // End if (is_array($temp1)) - -$temp1 = snmpwalk_cache_multi_oid($device, 'sysCmSyncStatusId', array(), 'F5-BIGIP-SYSTEM-MIB'); - -if (is_array($temp1)) { - echo 'F5 Sync State: '; - //Create State Index - $state_name = 'sysCmSyncStatusId'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'unknown',0,0,3), - array($state_index_id,'syncing',0,1,0), - array($state_index_id,'needManualSync',0,2,1), - array($state_index_id,'inSync',0,3,0), - array($state_index_id,'syncFailed',0,4,1), - array($state_index_id,'syncDisconnected',0,5,2), - array($state_index_id,'standalone',0,6,0), - array($state_index_id,'awaitingInitialSync',0,7,1), - array($state_index_id,'incompatibleVersion',0,8,2), - array($state_index_id,'partialSync',0,8,2), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], // Value polled from device - 'state_generic_value' => $value[4], // Set value based on the Nagios standard 0=OK, 1=Warning, 2=Critical, 3=Unknown - ); - dbInsert($insert, 'state_translations'); - } - } - - foreach (array_keys($temp1) as $index) { - $descr = "sysCmSyncStatusId.".$index; - $current = $temp1[$index]['sysCmSyncStatusId']; - $sensorType = 'f5'; - $oid = '.1.3.6.1.4.1.3375.2.1.14.1.1.'.$index; - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $current, 'snmp', $index); - - //Create Sensor To State Index - create_sensor_to_state_index($device, $state_name, $index); - } // End foreach (array_keys($temp1) as $index) -} // End if (is_array($temp1)) - -$temp1 = snmpwalk_cache_multi_oid($device, 'sysCmFailoverStatusColor', array(), 'F5-BIGIP-SYSTEM-MIB'); - -if (is_array($temp1)) { - echo 'F5 FailOver State Color: '; - //Create State Index - $state_name = 'sysCmFailoverStatusColor'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'Green: functioning correctly',0,0,0), - array($state_index_id,'Yellow: functioning suboptimally',0,1,1), - array($state_index_id,'Red: requires attention to function correctly',0,2,2), - array($state_index_id,'Blue: status is unknown',0,3,3), - array($state_index_id,'Gray: intentionally not functioning',0,4,0), - array($state_index_id,'Black: not connected to any peers',0,5,2), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], // Value polled from device - 'state_generic_value' => $value[4], // Set value based on the Nagios standard 0=OK, 1=Warning, 2=Critical, 3=Unknown - ); - dbInsert($insert, 'state_translations'); - } - } - - foreach (array_keys($temp1) as $index) { - $descr = "sysCmFailoverStatusColor.".$index; - $current = $temp1[$index]['sysCmFailoverStatusColor']; - $sensorType = 'f5'; - $oid = '.1.3.6.1.4.1.3375.2.1.14.3.3.'.$index; - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $current, 'snmp', $index); - - //Create Sensor To State Index - create_sensor_to_state_index($device, $state_name, $index); - } // End foreach (array_keys($temp1) as $index) -} // End if (is_array($temp1)) - -$temp3 = snmpwalk_cache_multi_oid($device, 'sysChassisFanStatus', array(), 'F5-BIGIP-SYSTEM-MIB'); - -if (is_array($temp3)) { +$temp = snmpwalk_cache_multi_oid($device, 'sysChassisFanStatus', [], 'F5-BIGIP-SYSTEM-MIB'); +if (is_array($temp)) { echo 'F5 FanSpeed State: '; //Create State Index $state_name = 'sysChassisFanStatus'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'Bad',0,0,2), - array($state_index_id,'Good',0,1,0), - array($state_index_id,'NotPresent',0,2,3), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], // Value polled from device - 'state_generic_value' => $value[4], // Set value based on the Nagios standard 0=OK, 1=Warning, 2=Critical, 3=Unknown - ); - dbInsert($insert, 'state_translations'); - } - } - - foreach (array_keys($temp3) as $index) { + create_state_index($state_name, $states); + foreach (array_keys($temp) as $index) { $descr = "Fan Speed Status ".$index; - $current = $temp3[$index]['sysChassisFanStatus']; + $current = $temp[$index]['sysChassisFanStatus']; $sensorType = 'f5'; $oid = '.1.3.6.1.4.1.3375.2.1.3.2.1.2.1.2.'.$index; - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $current, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $current, 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); - } // End foreach (array_keys($temp3) as $index) -} // End if (is_array($temp3)) + } // End foreach (array_keys($temp) as $index) +} // End if (is_array($temp)) + + +$temp = snmpwalk_cache_multi_oid($device, 'sysCmFailoverStatus', [], 'F5-BIGIP-SYSTEM-MIB'); + +if (is_array($temp)) { + echo 'F5 FailOver State: '; + //Create State Index + $state_name = 'sysCmFailoverStatusId'; + $states = [ + ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'Unknown'], + ['value' => 1, 'generic' => 2, 'graph' => 0, 'descr' => 'OffLine'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'ForcedOffline'], + ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'Standby'], + ['value' => 4, 'generic' => 0, 'graph' => 0, 'descr' => 'Active'], + ]; + create_state_index($state_name, $states); + + foreach (array_keys($temp) as $index) { + $descr = "sysCmFailoverStatusId.".$temp[$index]['sysCmFailoverStatusId']; + $current = $temp[$index]['sysCmFailoverStatusId']; + $sensorType = 'f5'; + $oid = '.1.3.6.1.4.1.3375.2.1.14.3.1.'.$index; + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $current, 'snmp', $index); + + //Create Sensor To State Index + create_sensor_to_state_index($device, $state_name, $index); + } // End foreach (array_keys($temp) as $index) +} // End if (is_array($temp)) + +$temp = snmpwalk_cache_multi_oid($device, 'sysCmSyncStatusId', [], 'F5-BIGIP-SYSTEM-MIB'); + +if (is_array($temp)) { + echo 'F5 Sync State: '; + //Create State Index + $state_name = 'sysCmSyncStatusId'; + $states = [ + ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'syncing'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'needManualSync'], + ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'inSync'], + ['value' => 4, 'generic' => 1, 'graph' => 0, 'descr' => 'syncFailed'], + ['value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'syncDisconnected'], + ['value' => 6, 'generic' => 0, 'graph' => 0, 'descr' => 'standalone'], + ['value' => 7, 'generic' => 1, 'graph' => 0, 'descr' => 'awaitingInitialSync'], + ['value' => 8, 'generic' => 2, 'graph' => 0, 'descr' => 'incompatibleVersion'], + ['value' => 9, 'generic' => 2, 'graph' => 0, 'descr' => 'partialSync'], + ]; + create_state_index($state_name, $states); + + foreach (array_keys($temp) as $index) { + $descr = "sysCmSyncStatusId.".$index; + $current = $temp[$index]['sysCmSyncStatusId']; + $sensorType = 'f5'; + $oid = '.1.3.6.1.4.1.3375.2.1.14.1.1.'.$index; + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $current, 'snmp', $index); + + //Create Sensor To State Index + create_sensor_to_state_index($device, $state_name, $index); + } // End foreach (array_keys($temp) as $index) +} // End if (is_array($temp)) + +$temp = snmpwalk_cache_multi_oid($device, 'sysCmFailoverStatusColor', [], 'F5-BIGIP-SYSTEM-MIB'); + +if (is_array($temp)) { + echo 'F5 FailOver State Color: '; + //Create State Index + $state_name = 'sysCmFailoverStatusColor'; + $states = [ + ['value' => 0, 'generic' => 0, 'graph' => 0, 'descr' => 'Green: functioning correctly'], + ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'Yellow: functioning suboptimally'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'Red: requires attention to function correctly'], + ['value' => 3, 'generic' => 3, 'graph' => 0, 'descr' => 'Blue: status is unknown'], + ['value' => 4, 'generic' => 0, 'graph' => 0, 'descr' => 'Gray: intentionally not functioning'], + ['value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'Black: not connected to any peers'], + ]; + create_state_index($state_name, $states); + + foreach (array_keys($temp) as $index) { + $descr = "sysCmFailoverStatusColor.".$index; + $current = $temp[$index]['sysCmFailoverStatusColor']; + $sensorType = 'f5'; + $oid = '.1.3.6.1.4.1.3375.2.1.14.3.3.'.$index; + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $current, 'snmp', $index); + + //Create Sensor To State Index + create_sensor_to_state_index($device, $state_name, $index); + } // End foreach (array_keys($temp) as $index) +} // End if (is_array($temp)) diff --git a/includes/discovery/sensors/state/fabos.inc.php b/includes/discovery/sensors/state/fabos.inc.php index 01743f4b8e..fc9a7fee77 100644 --- a/includes/discovery/sensors/state/fabos.inc.php +++ b/includes/discovery/sensors/state/fabos.inc.php @@ -26,32 +26,20 @@ foreach ($pre_cache['fabos_sensors'] as $data) { if (is_numeric($data['swSensorValue']) && $data['swSensorValue'] !== '-2147483648') { $descr = $data['swSensorInfo']; - $state_index_id = create_state_index($descr); - if ($state_index_id !== null) { - $states = array( - array($state_index_id, 'unknown', 0, 1, 3), - array($state_index_id, 'faulty', 1, 2, 2), - array($state_index_id, 'below-min', 1, 3, 1), - array($state_index_id, 'nominal', 1, 4, 0), - array($state_index_id, 'above-max', 1, 5, 1), - array($state_index_id, 'absent', 1, 6, 1), - ); + $states = [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ['value' => 2, 'generic' => 2, 'graph' => 1, 'descr' => 'faulty'], + ['value' => 3, 'generic' => 1, 'graph' => 1, 'descr' => 'below-min'], + ['value' => 4, 'generic' => 0, 'graph' => 1, 'descr' => 'nominal'], + ['value' => 5, 'generic' => 1, 'graph' => 1, 'descr' => 'above-max'], + ['value' => 6, 'generic' => 1, 'graph' => 1, 'descr' => 'absent'], + ]; + create_state_index($state_name, $states); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } $index = $data['swSensorIndex']; $oid = '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.3.' . $index; $value = $data['swSensorStatus']; - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $descr, $descr, '1', '1', null, null, null, null, $value); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $descr, $descr, 1, 1, null, null, null, null, $value); create_sensor_to_state_index($device, $descr, $index); } } diff --git a/includes/discovery/sensors/state/hirschmann.inc.php b/includes/discovery/sensors/state/hirschmann.inc.php index 14c8fd1f93..8e97d3a692 100644 --- a/includes/discovery/sensors/state/hirschmann.inc.php +++ b/includes/discovery/sensors/state/hirschmann.inc.php @@ -4,43 +4,39 @@ if ($device['os'] == 'hirschmann') { /////////////////////////// /// Power Supply Status /// /////////////////////////// - $oid = snmpwalk_cache_multi_oid($device, 'hmPSTable', array(), 'HMPRIV-MGMT-SNMP-MIB'); + $oid = snmpwalk_cache_multi_oid($device, 'hmPSTable', [], 'HMPRIV-MGMT-SNMP-MIB'); $cur_oid = '.1.3.6.1.4.1.248.14.1.2.1.3.'; if (is_array($oid)) { //Create State Index $state_name = 'hmPowerSupplyStatus'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'ok',0,1,0) , - array($state_index_id,'failed',0,2,2) , - array($state_index_id,'notInstalled',0,3,1) , - array($state_index_id,'unknown',0,4,3) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'ok'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'failed'], + ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'notInstalled'], + ['value' => 4, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ]; + create_state_index($state_name, $states); foreach ($oid as $index => $entry) { //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, 'hmPowerSupplyStatus'.$index, $state_name, 'Power Supply '.$oid[$index]['hmPSID'], '1', '1', null, null, null, null, $oid[$index]['hmPowerSupplyStatus'], 'snmp', 'hmPowerSupplyStatus'.$index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, 'hmPowerSupplyStatus'.$index, $state_name, 'Power Supply '.$oid[$index]['hmPSID'], 1, 1, null, null, null, null, $oid[$index]['hmPowerSupplyStatus'], 'snmp', 'hmPowerSupplyStatus'.$index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, 'hmPowerSupplyStatus'.$index); } } + //////////////////////////////// + /// Common LED Status States /// + //////////////////////////////// + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'off'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'green'], + ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'yellow'], + ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'red'], + ]; + /////////////////////////////// /// LED Status Power Supply /// /////////////////////////////// @@ -51,31 +47,11 @@ if ($device['os'] == 'hirschmann') { if (is_numeric($temp)) { //Create State Index $state_name = 'hmLEDRSPowerSupply'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'off',0,1,0) , - array($state_index_id,'green',0,2,0) , - array($state_index_id,'yellow',0,3,1) , - array($state_index_id,'red',0,4,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + create_state_index($state_name, $states); $descr = 'LED Status Power Supply'; //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, 'hmLEDRSPowerSupply.'.$index, $state_name, $descr, '1', '1', null, null, null, null, $temp, 'snmp', 'hmLEDRSPowerSupply.'.$index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, 'hmLEDRSPowerSupply.'.$index, $state_name, $descr, 1, 1, null, null, null, null, $temp, 'snmp', 'hmLEDRSPowerSupply.'.$index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, 'hmLEDRSPowerSupply.'.$index); @@ -91,31 +67,11 @@ if ($device['os'] == 'hirschmann') { if (is_numeric($temp)) { //Create State Index $state_name = 'hmLEDRStandby'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'off',0,1,0) , - array($state_index_id,'green',0,2,0) , - array($state_index_id,'yellow',0,3,1) , - array($state_index_id,'red',0,4,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + create_state_index($state_name, $states); $descr = 'LED Status Standby'; //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, 'hmLEDRStandby.'.$index, $state_name, $descr, '1', '1', null, null, null, null, $temp, 'snmp', 'hmLEDRStandby.'.$index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, 'hmLEDRStandby.'.$index, $state_name, $descr, 1, 1, null, null, null, null, $temp, 'snmp', 'hmLEDRStandby.'.$index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, 'hmLEDRStandby.'.$index); @@ -131,31 +87,11 @@ if ($device['os'] == 'hirschmann') { if (is_numeric($temp)) { //Create State Index $state_name = 'hmLEDRSRedundancyManager'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'off',0,1,0) , - array($state_index_id,'green',0,2,0) , - array($state_index_id,'yellow',0,3,1) , - array($state_index_id,'red',0,4,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + create_state_index($state_name, $states); $descr = 'LED Status Redundancy Manager'; //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, 'hmLEDRSRedundancyManager.'.$index, $state_name, $descr, '1', '1', null, null, null, null, $temp, 'snmp', 'hmLEDRSRedundancyManager.'.$index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, 'hmLEDRSRedundancyManager.'.$index, $state_name, $descr, 1, 1, null, null, null, null, $temp, 'snmp', 'hmLEDRSRedundancyManager.'.$index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, 'hmLEDRSRedundancyManager.'.$index); @@ -171,31 +107,11 @@ if ($device['os'] == 'hirschmann') { if (is_numeric($temp)) { //Create State Index $state_name = 'hmLEDRSFault'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'off',0,1,0) , - array($state_index_id,'green',0,2,0) , - array($state_index_id,'yellow',0,3,1) , - array($state_index_id,'red',0,4,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + create_state_index($state_name, $states); $descr = 'LED Status Fault'; //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, 'hmLEDRSFault.'.$index, $state_name, $descr, '1', '1', null, null, null, null, $temp, 'snmp', 'hmLEDRSFault.'.$index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, 'hmLEDRSFault.'.$index, $state_name, $descr, 1, 1, null, null, null, null, $temp, 'snmp', 'hmLEDRSFault.'.$index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, 'hmLEDRSFault.'.$index); diff --git a/includes/discovery/sensors/state/hpblmos.inc.php b/includes/discovery/sensors/state/hpblmos.inc.php index 09d8508bfb..0992f428a8 100644 --- a/includes/discovery/sensors/state/hpblmos.inc.php +++ b/includes/discovery/sensors/state/hpblmos.inc.php @@ -18,28 +18,15 @@ foreach (explode("\n", $fans) as $fan) { $descr = $fan_state_descr.$current_id; $state = snmp_get($device, $current_oid, '-Oqv'); if (!empty($state)) { - $state_index_id = create_state_index($fan_state_name); - if ($state_index_id) { - $states = array( - array($state_index_id, 'other', 0, 1, 3), - array($state_index_id, 'ok', 1, 2, 0), - array($state_index_id, 'degraded', 1, 3, 1), - array($state_index_id, 'failed', 1, 4, 2), - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'other'], + ['value' => 2, 'generic' => 0, 'graph' => 1, 'descr' => 'ok'], + ['value' => 3, 'generic' => 1, 'graph' => 1, 'descr' => 'degraded'], + ['value' => 4, 'generic' => 2, 'graph' => 1, 'descr' => 'failed'], + ]; + create_state_index($state_name, $states); } - discover_sensor($valid['sensor'], 'state', $device, $current_oid, $current_id, $fan_state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $current_id); + discover_sensor($valid['sensor'], 'state', $device, $current_oid, $current_id, $fan_state_name, $descr, 1, 1, null, null, null, null, $state, 'snmp', $current_id); create_sensor_to_state_index($device, $fan_state_name, $current_id); } } @@ -63,28 +50,15 @@ foreach (explode("\n", $psus) as $psu) { $descr = $psu_state_descr.$current_id; $state = snmp_get($device, $current_oid, '-Oqv'); if (!empty($state)) { - $state_index_id = create_state_index($psu_state_name); - if ($state_index_id) { - $states = array( - array($state_index_id, 'other', 0, 1, 3), - array($state_index_id, 'ok', 1, 2, 0), - array($state_index_id, 'degraded', 1, 3, 1), - array($state_index_id, 'failed', 1, 4, 2), - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'other'], + ['value' => 2, 'generic' => 0, 'graph' => 1, 'descr' => 'ok'], + ['value' => 3, 'generic' => 1, 'graph' => 1, 'descr' => 'degraded'], + ['value' => 4, 'generic' => 2, 'graph' => 1, 'descr' => 'failed'], + ]; + create_state_index($state_name, $states); } - discover_sensor($valid['sensor'], 'state', $device, $current_oid, $current_id, $psu_state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $current_id); + discover_sensor($valid['sensor'], 'state', $device, $current_oid, $current_id, $psu_state_name, $descr, 1, 1, null, null, null, null, $state, 'snmp', $current_id); create_sensor_to_state_index($device, $psu_state_name, $current_id); } } diff --git a/includes/discovery/sensors/state/ibm-amm.inc.php b/includes/discovery/sensors/state/ibm-amm.inc.php index f79ca9420e..1ec6ad2247 100644 --- a/includes/discovery/sensors/state/ibm-amm.inc.php +++ b/includes/discovery/sensors/state/ibm-amm.inc.php @@ -13,12 +13,12 @@ $index = 1; $state_name = 'ibm-amm_BlowerState'; $state_descr = 'Blower '; -$oids = array( +$oids = [ '.1.3.6.1.4.1.2.3.51.2.2.3.10.0', // BLADE-MIB::blower1State.0 '.1.3.6.1.4.1.2.3.51.2.2.3.11.0', // BLADE-MIB::blower2State.0 '.1.3.6.1.4.1.2.3.51.2.2.3.12.0', // BLADE-MIB::blower3State.0 '.1.3.6.1.4.1.2.3.51.2.2.3.13.0', // BLADE-MIB::blower4State.0 -); +]; /* BLADE-MIB: blower1State * unknown(0), * good(1), @@ -31,29 +31,15 @@ foreach ($oids as $oid) { $descr = $state_descr . $index; if (!empty($state)) { - $state_index_id = create_state_index($state_name); - - if ($state_index_id) { - $states = array( - array($state_index_id, 'unknown', 0, 0, 3), - array($state_index_id, 'good', 1, 1, 0), - array($state_index_id, 'warning', 1, 2, 1), - array($state_index_id, 'bad', 1, 3, 2), - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - }//end foreach - }//end if + $states = [ + ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'good'], + ['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'warning'], + ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'bad'], + ]; + create_state_index($state_name, $states); - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $state, 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); $index++; @@ -63,12 +49,12 @@ foreach ($oids as $oid) { $index = 1; $state_name = 'ibm-amm_BlowerControllerState'; $state_descr = 'Blower Controller '; -$oids = array( +$oids = [ '.1.3.6.1.4.1.2.3.51.2.2.3.30.0', // BLADE-MIB::blower1ControllerState.0 '.1.3.6.1.4.1.2.3.51.2.2.3.31.0', // BLADE-MIB::blower2ControllerState.0 '.1.3.6.1.4.1.2.3.51.2.2.3.32.0', // BLADE-MIB::blower3ControllerState.0 '.1.3.6.1.4.1.2.3.51.2.2.3.33.0', // BLADE-MIB::blower4ControllerState.0 -); +]; /* BLADE-MIB: blower1ControllerState * operational(0), @@ -82,30 +68,16 @@ foreach ($oids as $oid) { $descr = $state_descr . $index; if (is_numeric($state) && $state != 2) { - $state_index_id = create_state_index($state_name); + $states = [ + ['value' => 0, 'generic' => 0, 'graph' => 1, 'descr' => 'operational'], + ['value' => 1, 'generic' => 1, 'graph' => 1, 'descr' => 'flashing'], + ['value' => 2, 'generic' => -1, 'graph' => 1, 'descr' => 'notPresent'], + ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'communicationError'], + ['value' => 255, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ]; + create_state_index($state_name, $states); - if ($state_index_id) { - $states = array( - array($state_index_id, 'operational', 1, 0, 0), - array($state_index_id, 'flashing', 1, 1, 1), - array($state_index_id, 'notPresent', 1, 2, -1), - array($state_index_id, 'communicationError', 1, 3, 2), - array($state_index_id, 'unknown', 0, 255, 3), - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - }//end foreach - }//end if - - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $state, 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); $index++; @@ -116,7 +88,7 @@ $index = 1; $state_name = 'ibm-amm_PowerModuleState'; $state_descr = 'Power Module '; $powerModuleStateOid= '.1.3.6.1.4.1.2.3.51.2.2.4.1.1.3'; // BLADE-MIB::powerModuleState -$data = snmpwalk_cache_oid_num($device, $powerModuleStateOid, array()); +$data = snmpwalk_cache_oid_num($device, $powerModuleStateOid, []); /* BLADE-MIB: powerModuleState * unknown(0), @@ -130,30 +102,16 @@ foreach ($data as $oid => $array) { $descr = $state_descr . $index; if (is_numeric($state) && $state != 3) { - $state_index_id = create_state_index($state_name); + $states = [ + ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'good'], + ['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'warning'], + ['value' => 3, 'generic' => -1, 'graph' => 1, 'descr' => 'notAvailable'], + ['value' => 4, 'generic' => 2, 'graph' => 1, 'descr' => 'critical'], + ]; + create_state_index($state_name, $states); - if ($state_index_id) { - $states = array( - array($state_index_id, 'unknown', 0, 0, 3), - array($state_index_id, 'good', 1, 1, 0), - array($state_index_id, 'warning', 1, 2, 1), - array($state_index_id, 'notAvailable', 1, 3, -1), - array($state_index_id, 'critical', 1, 4, 2), - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - }//end foreach - }//end if - - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $state, 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); $index++; diff --git a/includes/discovery/sensors/state/ict-pdu.inc.php b/includes/discovery/sensors/state/ict-pdu.inc.php index 2b178f6f83..29c8295079 100644 --- a/includes/discovery/sensors/state/ict-pdu.inc.php +++ b/includes/discovery/sensors/state/ict-pdu.inc.php @@ -23,28 +23,15 @@ * @author Lorenzo Zafra */ -$oids = snmpwalk_cache_oid($device, 'outputEntry', array(), 'ICT-DISTRIBUTION-PANEL-MIB'); +$oids = snmpwalk_cache_oid($device, 'outputEntry', [], 'ICT-DISTRIBUTION-PANEL-MIB'); if (is_array($oids)) { $state_name = 'outputFuseStatus'; - $state_index_id = create_state_index($state_name); - - if ($state_index_id) { - $states = array( - array($state_index_id, 'OK', 0, 1, 0) , - array($state_index_id, 'OPEN', 0, 2, 2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'OK'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'OPEN'], + ]; + create_state_index($state_name, $states); foreach ($oids as $index => $entry) { $fuse_state_oid = '.1.3.6.1.4.1.39145.10.8.1.4.' . $index; @@ -58,7 +45,7 @@ if (is_array($oids)) { $current_value = 2; } - discover_sensor($valid['sensor'], 'state', $device, $fuse_state_oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $current_value, 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $fuse_state_oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $current_value, 'snmp', $index); create_sensor_to_state_index($device, $state_name, $index); } diff --git a/includes/discovery/sensors/state/ironware.inc.php b/includes/discovery/sensors/state/ironware.inc.php index f3af6fc4a9..38d44e8b55 100644 --- a/includes/discovery/sensors/state/ironware.inc.php +++ b/includes/discovery/sensors/state/ironware.inc.php @@ -10,32 +10,18 @@ * the source code distribution for details. */ -$temp = snmpwalk_cache_multi_oid($device, 'snChasPwrSupplyTable', array(), 'FOUNDRY-SN-AGENT-MIB'); +$temp = snmpwalk_cache_multi_oid($device, 'snChasPwrSupplyTable', [], 'FOUNDRY-SN-AGENT-MIB'); $cur_oid = '.1.3.6.1.4.1.1991.1.1.1.2.1.1.3.'; if (is_array($temp)) { //Create State Index $state_name = 'snChasPwrSupplyOperStatus'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'other',0,1,3) , - array($state_index_id,'normal',0,2,0) , - array($state_index_id,'failure',0,3,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'other'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'normal'], + ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'failure'], + ]; + create_state_index($state_name, $states); foreach ($temp as $index => $entry) { //Discover Sensors @@ -43,7 +29,7 @@ if (is_array($temp)) { if (empty($descr)) { $descr = "Power Supply " . $index; } - discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp[$index]['snChasPwrSupplyOperStatus'], 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp[$index]['snChasPwrSupplyOperStatus'], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); diff --git a/includes/discovery/sensors/state/juniper-mss.inc.php b/includes/discovery/sensors/state/juniper-mss.inc.php index 132064e491..024bfb282a 100644 --- a/includes/discovery/sensors/state/juniper-mss.inc.php +++ b/includes/discovery/sensors/state/juniper-mss.inc.php @@ -10,39 +10,25 @@ * the source code distribution for details. */ -$temp = snmpwalk_cache_multi_oid($device, 'trpzSysPowerSupplyTable', array(), 'TRAPEZE-NETWORKS-SYSTEM-MIB'); +$temp = snmpwalk_cache_multi_oid($device, 'trpzSysPowerSupplyTable', [], 'TRAPEZE-NETWORKS-SYSTEM-MIB'); $cur_oid = '.1.3.6.1.4.1.14525.4.8.1.1.13.1.2.1.2.'; if (is_array($temp)) { //Create State Index $state_name = 'trpzSysPowerSupplyStatus'; - $state_index_id = create_state_index($state_name); - - //Create State Translation - if ($state_index_id !== null) { - $states = array( - array($state_index_id, 'other', 0, 1, 1), - array($state_index_id, 'unknown', 0, 2, 3), - array($state_index_id, 'ac-failed', 0, 3, 2), - array($state_index_id, 'dc-failed', 0, 4, 2), - array($state_index_id, 'ac-ok-dc-ok', 0, 5, 0) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'other'], + ['value' => 2, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'ac-failed'], + ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'dc-failed'], + ['value' => 5, 'generic' => 0, 'graph' => 0, 'descr' => 'ac-ok-dc-ok'], + ]; + create_state_index($state_name, $states); foreach ($temp as $index => $entry) { $descr = $temp[$index]['trpzSysPowerSupplyDescr']; //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp[$index]['trpzSysPowerSupplyStatus'], 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp[$index]['trpzSysPowerSupplyStatus'], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); diff --git a/includes/discovery/sensors/state/linux.inc.php b/includes/discovery/sensors/state/linux.inc.php index a0abb93c52..9dfabc779c 100644 --- a/includes/discovery/sensors/state/linux.inc.php +++ b/includes/discovery/sensors/state/linux.inc.php @@ -29,25 +29,13 @@ if (!empty($pre_cache['raspberry_pi_sensors'])) { } $value = current($pre_cache['raspberry_pi_sensors']["raspberry." . $codec]); if (stripos($value, 'abled') !== false) { - $state_index_id = create_state_index($state); - if ($state_index_id) { - $states = [ - [$state_index_id, 'enabled', 1, 2, 0], - [$state_index_id, 'disabled', 1, 3, 2], - ]; - } + $states = [ + ['value' => 2, 'generic' => 0, 'graph' => 1, 'descr' => 'enabled'], + ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'disabled'], + ]; + create_state_index($state_name, $states); - foreach ($states as $value) { - $insert = [ - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ]; - dbInsert($insert, 'state_translations'); - } - discover_sensor($valid['sensor'], 'state', $device, $oid . $codec, $codec, $state, $descr, '1', '1', null, null, null, null, $value, 'snmp', $codec); + discover_sensor($valid['sensor'], 'state', $device, $oid . $codec, $codec, $state, $descr, 1, 1, null, null, null, null, $value, 'snmp', $codec); create_sensor_to_state_index($device, $state, $codec); } else { break; diff --git a/includes/discovery/sensors/state/mrv-od.inc.php b/includes/discovery/sensors/state/mrv-od.inc.php index bba10d3b16..5bd7ab5e0c 100644 --- a/includes/discovery/sensors/state/mrv-od.inc.php +++ b/includes/discovery/sensors/state/mrv-od.inc.php @@ -15,36 +15,26 @@ echo "MRV OptiDriver"; foreach ($pre_cache['mrv-od_port-table'] as $index => $entry) { + // Common Rx/Tx States + $states = [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'notSupported'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'lowAlarm'], + ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'lowWarning'], + ['value' => 4, 'generic' => 0, 'graph' => 0, 'descr' => 'ok'], + ['value' => 5, 'generic' => 1, 'graph' => 0, 'descr' => 'highWarning'], + ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'highAlarm'], + ]; + // RX Interface Power State if ($entry['nbsCmmcPortRxPowerLevel']) { $cur_oid = '.1.3.6.1.4.1.629.200.8.1.1.66.'; //Create State Index $state_name = 'nbsCmmcPortRxPowerLevel'; - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'notSupported',0,1,3) , - array($state_index_id,'lowAlarm',0,2,2) , - array($state_index_id,'lowWarning',0,3,1) , - array($state_index_id,'ok',0,4,0) , - array($state_index_id,'highWarning',0,5,1) , - array($state_index_id,'highAlarm',0,6,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifName`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Rx Power State'; + create_state_index($state_name, $states); + + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifName`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Rx Power State'; //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, '1', '1', null, null, null, null, $entry['nbsCmmcPortRxPowerLevel'], 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, 1, 1, null, null, null, null, $entry['nbsCmmcPortRxPowerLevel'], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); } @@ -53,291 +43,72 @@ foreach ($pre_cache['mrv-od_port-table'] as $index => $entry) { $cur_oid = '.1.3.6.1.4.1.629.200.8.1.1.65.'; //Create State Index $state_name = 'nbsCmmcPortTxPowerLevel'; - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'notSupported',0,1,3) , - array($state_index_id,'lowAlarm',0,2,2) , - array($state_index_id,'lowWarning',0,3,1) , - array($state_index_id,'ok',0,4,0) , - array($state_index_id,'highWarning',0,5,1) , - array($state_index_id,'highAlarm',0,6,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifName`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Tx Power State'; + create_state_index($state_name, $states); + + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifName`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Tx Power State'; //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, '1', '1', null, null, null, null, $entry['nbsCmmcPortTxPowerLevel'], 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, 1, 1, null, null, null, null, $entry['nbsCmmcPortTxPowerLevel'], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); } } foreach ($pre_cache['mrv-od_chassis-entry'] as $index => $entry) { - // Power Supply 1 - if ($entry['nbsCmmcChassisPS1Status']) { - $cur_oid = '.1.3.6.1.4.1.629.200.6.1.1.7.1'; - //Create State Index - $state_name = 'nbsCmmcChassisPS1Status'; - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'notInstalled',0,1,1) , - array($state_index_id,'acBad',0,2,2) , - array($state_index_id,'dcBad',0,3,2) , - array($state_index_id,'acGood',0,4,0) , - array($state_index_id,'dcGood',0,5,0) , - array($state_index_id,'notSupported',0,6,3) , - array($state_index_id,'good',0,7,0) , - array($state_index_id,'bad',0,8,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } + // Common Power Supply States + $states = [ + ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'notInstalled'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'acBad'], + ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'dcBad'], + ['value' => 4, 'generic' => 0, 'graph' => 0, 'descr' => 'acGood'], + ['value' => 5, 'generic' => 0, 'graph' => 0, 'descr' => 'dcGood'], + ['value' => 6, 'generic' => 3, 'graph' => 0, 'descr' => 'notSupported'], + ['value' => 7, 'generic' => 0, 'graph' => 0, 'descr' => 'good'], + ['value' => 8, 'generic' => 2, 'graph' => 0, 'descr' => 'bad'], + ]; + + $powerSupplies = [ + ['entity' => 'nbsCmmcChassisPS1Status', 'num_oid' => '.1.3.6.1.4.1.629.200.6.1.1.7.1', 'descr' => 'Power Supply 1'], + ['entity' => 'nbsCmmcChassisPS2Status', 'num_oid' => '.1.3.6.1.4.1.629.200.6.1.1.8.1', 'descr' => 'Power Supply 2'], + ['entity' => 'nbsCmmcChassisPS3Status', 'num_oid' => '.1.3.6.1.4.1.629.200.6.1.1.9.1', 'descr' => 'Power Supply 3'], + ['entity' => 'nbsCmmcChassisPS4Status', 'num_oid' => '.1.3.6.1.4.1.629.200.6.1.1.10.1', 'descr' => 'Power Supply 4'], + ]; + + foreach ($powerSupplies as $psu) { + if ($entry[$psu['entity']]) { + //Create State Index + $state_name = $psu['entity']; + create_state_index($state_name, $states); + + $cur_oid = $psu['num_oid']; + $descr = $psu['descr']; + + //Discover Sensors + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $oids[$state_name], 'snmp', 1); + //Create Sensor To State Index + create_sensor_to_state_index($device, $state_name, $index); } - //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'Power Supply 1', '1', '1', null, null, null, null, $oids['nbsCmmcChassisPS1Status'], 'snmp', 1); - //Create Sensor To State Index - create_sensor_to_state_index($device, $state_name, $index); } - // Power Supply 2 - if ($entry['nbsCmmcChassisPS2Status']) { - $cur_oid = '.1.3.6.1.4.1.629.200.6.1.1.8.1'; - //Create State Index - $state_name = 'nbsCmmcChassisPS2Status'; - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'notInstalled',0,1,1) , - array($state_index_id,'acBad',0,2,2) , - array($state_index_id,'dcBad',0,3,2) , - array($state_index_id,'acGood',0,4,0) , - array($state_index_id,'dcGood',0,5,0) , - array($state_index_id,'notSupported',0,6,3) , - array($state_index_id,'good',0,7,0) , - array($state_index_id,'bad',0,8,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } + + $fans = [ + ['entity' => 'nbsCmmcChassisFan1Status', 'num_oid' => '.1.3.6.1.4.1.629.200.6.1.1.11.1', 'descr' => 'Fan 1'], + ['entity' => 'nbsCmmcChassisFan2Status', 'num_oid' => '.1.3.6.1.4.1.629.200.6.1.1.12.1', 'descr' => 'Fan 2'], + ['entity' => 'nbsCmmcChassisFan3Status', 'num_oid' => '.1.3.6.1.4.1.629.200.6.1.1.13.1', 'descr' => 'Fan 3'], + ['entity' => 'nbsCmmcChassisFan4Status', 'num_oid' => '.1.3.6.1.4.1.629.200.6.1.1.14.1', 'descr' => 'Fan 4'], + ]; + + foreach ($fans as $fan) { + if ($entry[$psu['entity']]) { + //Create State Index + $state_name = $fan['entity']; + create_state_index($state_name, $states); + + $cur_oid = $fan['num_oid']; + $descr = $fan['descr']; + + //Discover Sensors + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $oids[$state_name], 'snmp', 1); + //Create Sensor To State Index + create_sensor_to_state_index($device, $state_name, $index); } - //Discover Sensor - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'Power Supply 2', '1', '1', null, null, null, null, $oids['nbsCmmcChassisPS2Status'], 'snmp', 1); - //Create Sensor To State Index - create_sensor_to_state_index($device, $state_name, $index); - } - // Power Supply 3 - if ($entry['nbsCmmcChassisPS3tatus']) { - $cur_oid = '.1.3.6.1.4.1.629.200.6.1.1.9.1'; - //Create State Index - $state_name = 'nbsCmmcChassisPS3Status'; - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'notInstalled',0,1,1) , - array($state_index_id,'acBad',0,2,2) , - array($state_index_id,'dcBad',0,3,2) , - array($state_index_id,'acGood',0,4,0) , - array($state_index_id,'dcGood',0,5,0) , - array($state_index_id,'notSupported',0,6,3) , - array($state_index_id,'good',0,7,0) , - array($state_index_id,'bad',0,8,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - //Discover Sensor - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'Power Supply 3', '1', '1', null, null, null, null, $oids['nbsCmmcChassisPS3Status'], 'snmp', 1); - //Create Sensor To State Index - create_sensor_to_state_index($device, $state_name, $index); - } - // Power Supply 4 - if ($entry['nbsCmmcChassisPS4Status']) { - $cur_oid = '.1.3.6.1.4.1.629.200.6.1.1.10.1'; - //Create State Index - $state_name = 'nbsCmmcChassisPS4Status'; - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'notInstalled',0,1,1) , - array($state_index_id,'acBad',0,2,2) , - array($state_index_id,'dcBad',0,3,2) , - array($state_index_id,'acGood',0,4,0) , - array($state_index_id,'dcGood',0,5,0) , - array($state_index_id,'notSupported',0,6,3) , - array($state_index_id,'good',0,7,0) , - array($state_index_id,'bad',0,8,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - //Discover Sensor - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'Power Supply 4', '1', '1', null, null, null, null, $oids['nbsCmmcChassisPS4Status'], 'snmp', 1); - //Create Sensor To State Index - create_sensor_to_state_index($device, $state_name, $index); - } - // Power Supply 4 - if ($entry['nbsCmmcChassisFan1Status']) { - $cur_oid = '.1.3.6.1.4.1.629.200.6.1.1.11.1'; - //Create State Index - $state_name = 'nbsCmmcChassisFan1Status'; - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'notSupported',0,1,3) , - array($state_index_id,'bad',0,2,2) , - array($state_index_id,'good',0,3,0) , - array($state_index_id,'notInstalled',0,4,1) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - //Discover Sensor - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'Fan 1', '1', '1', null, null, null, null, $oids['nbsCmmcChassisFan1Status'], 'snmp', 1); - //Create Sensor To State Index - create_sensor_to_state_index($device, $state_name, $index); - } - // Fan 2 - if ($entry['nbsCmmcChassisFan2Status']) { - $cur_oid = '.1.3.6.1.4.1.629.200.6.1.1.12.1'; - //Create State Index - $state_name = 'nbsCmmcChassisFan2Status'; - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'notSupported',0,1,3) , - array($state_index_id,'bad',0,2,2) , - array($state_index_id,'good',0,3,0) , - array($state_index_id,'notInstalled',0,4,1) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - //Discover Sensor - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'Fan 2', '1', '1', null, null, null, null, $oids['nbsCmmcChassisFan2Status'], 'snmp', 1); - //Create Sensor To State Index - create_sensor_to_state_index($device, $state_name, $index); - } - // Fan 3 - if ($entry['nbsCmmcChassisFan3Status']) { - $cur_oid = '.1.3.6.1.4.1.629.200.6.1.1.13.1'; - //Create State Index - $state_name = 'nbsCmmcChassisFan3Status'; - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'notSupported',0,1,3) , - array($state_index_id,'bad',0,2,2) , - array($state_index_id,'good',0,3,0) , - array($state_index_id,'notInstalled',0,4,1) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - //Discover Sensor - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'Fan 3', '1', '1', null, null, null, null, $oids['nbsCmmcChassisFan3Status'], 'snmp', 1); - //Create Sensor To State Index - create_sensor_to_state_index($device, $state_name, $index); - } - // Fan 4 - if ($entry['nbsCmmcChassisFan4Status']) { - $cur_oid = '.1.3.6.1.4.1.629.200.6.1.1.14.1'; - //Create State Index - $state_name = 'nbsCmmcChassisFan4Status'; - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'notSupported',0,1,3) , - array($state_index_id,'bad',0,2,2) , - array($state_index_id,'good',0,3,0) , - array($state_index_id,'notInstalled',0,4,1) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - //Discover Sensor - discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, 'Fan 4', '1', '1', null, null, null, null, $oids['nbsCmmcChassisFan4Status'], 'snmp', 1); - //Create Sensor To State Index - create_sensor_to_state_index($device, $state_name, $index); } } diff --git a/includes/discovery/sensors/state/netagent2.inc.php b/includes/discovery/sensors/state/netagent2.inc.php index 870a9a289b..3f653214bc 100644 --- a/includes/discovery/sensors/state/netagent2.inc.php +++ b/includes/discovery/sensors/state/netagent2.inc.php @@ -32,34 +32,20 @@ $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); if (!empty($ups_state) || $ups_state == 0) { // UPS state OID (Value : 0-1 Unknown, 2 On Line, 3 On Battery, 4 On Boost, 5 Sleeping, 6 On Bypass, 7 Rebooting, 8 Standby, 9 On Buck ) $state_name = 'netagent2upsstate'; - $state_index_id = create_state_index($state_name); + $states = [ + ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'OnLine'], + ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'OnBattery'], + ['value' => 4, 'generic' => 0, 'graph' => 0, 'descr' => 'OnBoost'], + ['value' => 5, 'generic' => 1, 'graph' => 0, 'descr' => 'Sleeping'], + ['value' => 6, 'generic' => 0, 'graph' => 0, 'descr' => 'OnBypass'], + ['value' => 7, 'generic' => 1, 'graph' => 0, 'descr' => 'Rebooting'], + ['value' => 8, 'generic' => 0, 'graph' => 0, 'descr' => 'Standby'], + ['value' => 9, 'generic' => 0, 'graph' => 0, 'descr' => 'OnBuck'], + ]; + create_state_index($state_name, $states); - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'unknown',0,0,3) , - array($state_index_id,'unknown',0,1,3) , - array($state_index_id,'OnLine',0,2,0) , - array($state_index_id,'OnBattery',0,3,1) , - array($state_index_id,'OnBoost',0,4,0) , - array($state_index_id,'Sleeping',0,4,1) , - array($state_index_id,'OnBypass',0,6,0) , - array($state_index_id,'Rebooting',0,7,1) , - array($state_index_id,'Standby',0,8,0) , - array($state_index_id,'OnBuck',0,9,0) - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - $index = 0; $limit = 10; $warnlimit = null; @@ -69,404 +55,28 @@ if (!empty($ups_state) || $ups_state == 0) { $state = $ups_state / $divisor; $descr = 'UPS state'; - discover_sensor( - $valid['sensor'], - 'state', - $device, - $ups_state_oid, - $index, - $state_name, - $descr, - $divisor, - '1', - $lowlimit, - $lowwarnlimit, - $warnlimit, - $limit, - $state - ); - create_sensor_to_state_index( - $device, - $state_name, - $index - ); + discover_sensor($valid['sensor'], 'state', $device, $ups_state_oid, $index, $state_name, $descr, $divisor, 1, $lowlimit, $lowwarnlimit, $warnlimit, $limit, $state); + create_sensor_to_state_index($device, $state_name, $index); } // Detect type of UPS (Signle-Phase/3 Phase) # Number of input lines - $upsInputNumLines_oid = '.1.3.6.1.2.1.33.1.3.2.0'; - $in_phaseNum = snmp_get($device, $upsInputNumLines_oid, '-Oqv'); +$upsInputNumLines_oid = '.1.3.6.1.2.1.33.1.3.2.0'; +$in_phaseNum = snmp_get($device, $upsInputNumLines_oid, '-Oqv'); // 3 Phase system states if ($in_phaseNum == '3') { - // Inverter active - $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.6.5.0'; - $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); - - if (!empty($ups_state) || $ups_state == 0) { - $state_name = 'upsThreePhaseUPSStatusInverterOperating'; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'yes',0,14,0) , - array($state_index_id,'no',0,16,2) - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - $index = 0; - $limit = 10; - $warnlimit = null; - $lowlimit = null; - $lowwarnlimit = null; - $divisor = 1; - $state = $ups_state / $divisor; - $descr = 'Inverter Operating'; - - discover_sensor( - $valid['sensor'], - 'state', - $device, - $ups_state_oid, - $index, - $state_name, - $descr, - $divisor, - '1', - $lowlimit, - $lowwarnlimit, - $warnlimit, - $limit, - $state - ); - create_sensor_to_state_index( - $device, - $state_name, - $index - ); - } - // AC Status - $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.6.3.0'; - $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); - - if (!empty($ups_state) || $ups_state == 0) { - $state_name = 'upsThreePhaseUPSStatusACStatus'; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'normal',0,10,0) , - array($state_index_id,'abnormal',0,11,2) - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - $index = 0; - $limit = 10; - $warnlimit = null; - $lowlimit = null; - $lowwarnlimit = null; - $divisor = 1; - $state = $ups_state / $divisor; - $descr = 'AC status'; - - discover_sensor( - $valid['sensor'], - 'state', - $device, - $ups_state_oid, - $index, - $state_name, - $descr, - $divisor, - '1', - $lowlimit, - $lowwarnlimit, - $warnlimit, - $limit, - $state - ); - create_sensor_to_state_index( - $device, - $state_name, - $index - ); - } - // Bypass braker status - $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.6.2.0'; - $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); - - if (!empty($ups_state) || $ups_state == 0) { - $state_name = 'upsThreePhaseUPSStatusManualBypassBreaker'; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'close',0,8,1) , - array($state_index_id,'open',0,9,) - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - $index = 0; - $limit = 10; - $warnlimit = null; - $lowlimit = null; - $lowwarnlimit = null; - $divisor = 1; - $state = $ups_state / $divisor; - $descr = 'Breaker Status'; - - discover_sensor( - $valid['sensor'], - 'state', - $device, - $ups_state_oid, - $index, - $state_name, - $descr, - $divisor, - '1', - $lowlimit, - $lowwarnlimit, - $warnlimit, - $limit, - $state - ); - create_sensor_to_state_index( - $device, - $state_name, - $index - ); - } - // Rectifier Operating - $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.5.7.0'; - $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); - - if (!empty($ups_state) || $ups_state == 0) { - $state_name = 'upsThreePhaseDCandRectifierStatusRecOperating'; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'yes',0,14,0) , - array($state_index_id,'no',0,16,2) - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - $index = 0; - $limit = 10; - $warnlimit = null; - $lowlimit = null; - $lowwarnlimit = null; - $divisor = 1; - $state = $ups_state / $divisor; - $descr = 'Rectifier Operating'; - - discover_sensor( - $valid['sensor'], - 'state', - $device, - $ups_state_oid, - $index, - $state_name, - $descr, - $divisor, - '1', - $lowlimit, - $lowwarnlimit, - $warnlimit, - $limit, - $state - ); - create_sensor_to_state_index( - $device, - $state_name, - $index - ); - } - // Charge Status - $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.5.6.0'; - $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); - - if (!empty($ups_state) || $ups_state == 0) { - $state_name = 'upsThreePhaseDCandRectifierStatusChargeStatus'; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'boost',0,6,0) , - array($state_index_id,'float',0,7,0) , - array($state_index_id,'no',0,16,2) - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - $index = 0; - $limit = 10; - $warnlimit = null; - $lowlimit = null; - $lowwarnlimit = null; - $divisor = 1; - $state = $ups_state / $divisor; - $descr = 'Charge Status'; - - discover_sensor( - $valid['sensor'], - 'state', - $device, - $ups_state_oid, - $index, - $state_name, - $descr, - $divisor, - '1', - $lowlimit, - $lowwarnlimit, - $warnlimit, - $limit, - $state - ); - create_sensor_to_state_index( - $device, - $state_name, - $index - ); - } - // Back Status - $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.5.5.0'; - $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); - - if (!empty($ups_state) || $ups_state == 0) { - $state_name = 'upsThreePhaseDCandRectifierStatusBatteryStatus'; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'backup',0,4,1) , - array($state_index_id,'acnormal',0,5,0) - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - $index = 0; - $limit = 10; - $warnlimit = null; - $lowlimit = null; - $lowwarnlimit = null; - $divisor = 1; - $state = $ups_state / $divisor; - $descr = 'Back Status'; - - discover_sensor( - $valid['sensor'], - 'state', - $device, - $ups_state_oid, - $index, - $state_name, - $descr, - $divisor, - '1', - $lowlimit, - $lowwarnlimit, - $warnlimit, - $limit, - $state - ); - create_sensor_to_state_index( - $device, - $state_name, - $index - ); - } // In And Out $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.5.4.0'; $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); if (!empty($ups_state) || $ups_state == 0) { $state_name = 'upsThreePhaseDCandRectifierStatusInAndOut'; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'threeInOneOut',0,2,3) , - array($state_index_id,'threeInThreeOut',0,3,3) - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 2, 'generic' => 3, 'graph' => 0, 'descr' => 'threeInOneOut'], + ['value' => 3, 'generic' => 3, 'graph' => 0, 'descr' => 'threeInThreeOut'], + ]; + create_state_index($state_name, $states); $index = 0; $limit = 10; @@ -477,53 +87,72 @@ if ($in_phaseNum == '3') { $state = $ups_state / $divisor; $descr = 'In And Out'; - discover_sensor( - $valid['sensor'], - 'state', - $device, - $ups_state_oid, - $index, - $state_name, - $descr, - $divisor, - '1', - $lowlimit, - $lowwarnlimit, - $warnlimit, - $limit, - $state - ); - create_sensor_to_state_index( - $device, - $state_name, - $index - ); + discover_sensor($valid['sensor'], 'state', $device, $ups_state_oid, $index, $state_name, $descr, $divisor, 1, $lowlimit, $lowwarnlimit, $warnlimit, $limit, $state); + create_sensor_to_state_index($device, $state_name, $index); } - // Rectifier Rotation Error - $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.5.1.0'; + + // Back Status + $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.5.5.0'; $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); if (!empty($ups_state) || $ups_state == 0) { - $state_name = 'upsThreePhaseDCandRectifierStatusRecRotError'; - $state_index_id = create_state_index($state_name); + $state_name = 'upsThreePhaseDCandRectifierStatusBatteryStatus'; + $states = [ + ['value' => 4, 'generic' => 1, 'graph' => 0, 'descr' => 'backup'], + ['value' => 5, 'generic' => 0, 'graph' => 0, 'descr' => 'acnormal'], + ]; + create_state_index($state_name, $states); - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'yes',0,14,2) , - array($state_index_id,'no',0,16,0) - ); + $index = 0; + $limit = 10; + $warnlimit = null; + $lowlimit = null; + $lowwarnlimit = null; + $divisor = 1; + $state = $ups_state / $divisor; + $descr = 'Back Status'; - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + discover_sensor($valid['sensor'], 'state', $device, $ups_state_oid, $index, $state_name, $descr, $divisor, 1, $lowlimit, $lowwarnlimit, $warnlimit, $limit, $state); + create_sensor_to_state_index($device, $state_name, $index); + } + + // Charge Status + $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.5.6.0'; + $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); + + if (!empty($ups_state) || $ups_state == 0) { + $state_name = 'upsThreePhaseDCandRectifierStatusChargeStatus'; + $states = [ + ['value' => 6, 'generic' => 0, 'graph' => 0, 'descr' => 'boost'], + ['value' => 7, 'generic' => 0, 'graph' => 0, 'descr' => 'float'], + ['value' => 16, 'generic' => 2, 'graph' => 0, 'descr' => 'no'], + ]; + create_state_index($state_name, $states); + + $index = 0; + $limit = 10; + $warnlimit = null; + $lowlimit = null; + $lowwarnlimit = null; + $divisor = 1; + $state = $ups_state / $divisor; + $descr = 'Charge Status'; + + discover_sensor($valid['sensor'], 'state', $device, $ups_state_oid, $index, $state_name, $descr, $divisor, 1, $lowlimit, $lowwarnlimit, $warnlimit, $limit, $state); + create_sensor_to_state_index($device, $state_name, $index); + } + + // Bypass braker status + $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.6.2.0'; + $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); + + if (!empty($ups_state) || $ups_state == 0) { + $state_name = 'upsThreePhaseUPSStatusManualBypassBreaker'; + $states = [ + ['value' => 8, 'generic' => 1, 'graph' => 0, 'descr' => 'close'], + ['value' => 9, 'generic' => 0, 'graph' => 0, 'descr' => 'open'], + ]; + create_state_index($state_name, $states); $index = 0; $limit = 10; @@ -532,55 +161,71 @@ if ($in_phaseNum == '3') { $lowwarnlimit = null; $divisor = 1; $state = $ups_state / $divisor; - $descr = 'Rectifier Rotation Error'; + $descr = 'Breaker Status'; - discover_sensor( - $valid['sensor'], - 'state', - $device, - $ups_state_oid, - $index, - $state_name, - $descr, - $divisor, - '1', - $lowlimit, - $lowwarnlimit, - $warnlimit, - $limit, - $state - ); - create_sensor_to_state_index( - $device, - $state_name, - $index - ); + discover_sensor($valid['sensor'], 'state', $device, $ups_state_oid, $index, $state_name, $descr, $divisor, 1, $lowlimit, $lowwarnlimit, $warnlimit, $limit, $state); + create_sensor_to_state_index($device, $state_name, $index); } - // Short Circuit - $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.7.7.0'; + + // AC Status + $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.6.3.0'; $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); if (!empty($ups_state) || $ups_state == 0) { - $state_name = 'upsThreePhaseFaultStatusShortCircuit'; - $state_index_id = create_state_index($state_name); + $state_name = 'upsThreePhaseUPSStatusACStatus'; + $states = [ + ['value' => 10, 'generic' => 0, 'graph' => 0, 'descr' => 'normal'], + ['value' => 11, 'generic' => 2, 'graph' => 0, 'descr' => 'abnormal'], + ]; + create_state_index($state_name, $states); - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'yes',0,14,2) , - array($state_index_id,'no',0,16,0) - ); + $index = 0; + $limit = 10; + $warnlimit = null; + $lowlimit = null; + $lowwarnlimit = null; + $divisor = 1; + $state = $ups_state / $divisor; + $descr = 'AC status'; - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + discover_sensor($valid['sensor'], 'state', $device, $ups_state_oid, $index, $state_name, $descr, $divisor, 1, $lowlimit, $lowwarnlimit, $warnlimit, $limit, $state); + create_sensor_to_state_index($device, $state_name, $index); + } + + // Common State - Inverter active, Rectifier Operating + $states = [ + ['value' => 14, 'generic' => 0, 'graph' => 0, 'descr' => 'yes'], + ['value' => 16, 'generic' => 2, 'graph' => 0, 'descr' => 'no'], + ]; + + // Inverter active + $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.6.5.0'; + $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); + + if (!empty($ups_state) || $ups_state == 0) { + $state_name = 'upsThreePhaseUPSStatusInverterOperating'; + create_state_index($state_name, $states); + + $index = 0; + $limit = 10; + $warnlimit = null; + $lowlimit = null; + $lowwarnlimit = null; + $divisor = 1; + $state = $ups_state / $divisor; + $descr = 'Inverter Operating'; + + discover_sensor($valid['sensor'], 'state', $device, $ups_state_oid, $index, $state_name, $descr, $divisor, 1, $lowlimit, $lowwarnlimit, $warnlimit, $limit, $state); + create_sensor_to_state_index($device, $state_name, $index); + } + + // Rectifier Operating + $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.5.7.0'; + $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); + + if (!empty($ups_state) || $ups_state == 0) { + $state_name = 'upsThreePhaseDCandRectifierStatusRecOperating'; + create_state_index($state_name, $states); $index = 0; $limit = 10; @@ -589,55 +234,23 @@ if ($in_phaseNum == '3') { $lowwarnlimit = null; $divisor = 1; $state = $ups_state / $divisor; - $descr = 'Short Circuit'; + $descr = 'Rectifier Operating'; - discover_sensor( - $valid['sensor'], - 'state', - $device, - $ups_state_oid, - $index, - $state_name, - $descr, - $divisor, - '1', - $lowlimit, - $lowwarnlimit, - $warnlimit, - $limit, - $state - ); - create_sensor_to_state_index( - $device, - $state_name, - $index - ); + discover_sensor($valid['sensor'], 'state', $device, $ups_state_oid, $index, $state_name, $descr, $divisor, 1, $lowlimit, $lowwarnlimit, $warnlimit, $limit, $state); + create_sensor_to_state_index($device, $state_name, $index); } + // Switch Mode $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.6.4.0'; $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); if (!empty($ups_state) || $ups_state == 0) { $state_name = 'upsThreePhaseUPSStaticSwitchMode'; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'invermode',0,12,0) , - array($state_index_id,'bypassmode',0,13,1) - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 12, 'generic' => 0, 'graph' => 0, 'descr' => 'invermode'], + ['value' => 13, 'generic' => 1, 'graph' => 0, 'descr' => 'bypassmode'], + ]; + create_state_index($state_name, $states); $index = 0; $limit = 10; @@ -648,53 +261,44 @@ if ($in_phaseNum == '3') { $state = $ups_state / $divisor; $descr = 'Switch Mode'; - discover_sensor( - $valid['sensor'], - 'state', - $device, - $ups_state_oid, - $index, - $state_name, - $descr, - $divisor, - '1', - $lowlimit, - $lowwarnlimit, - $warnlimit, - $limit, - $state - ); - create_sensor_to_state_index( - $device, - $state_name, - $index - ); + discover_sensor($valid['sensor'], 'state', $device, $ups_state_oid, $index, $state_name, $descr, $divisor, 1, $lowlimit, $lowwarnlimit, $warnlimit, $limit, $state); + create_sensor_to_state_index($device, $state_name, $index); } + + // Common State - Rectifier Rotation Error, Bypass Status and Short Circuit + $states = [ + ['value' => 14, 'generic' => 2, 'graph' => 0, 'descr' => 'yes'], + ['value' => 16, 'generic' => 0, 'graph' => 0, 'descr' => 'no'], + ]; + + // Rectifier Rotation Error + $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.5.1.0'; + $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); + + if (!empty($ups_state) || $ups_state == 0) { + $state_name = 'upsThreePhaseDCandRectifierStatusRecRotError'; + create_state_index($state_name, $states); + + $index = 0; + $limit = 10; + $warnlimit = null; + $lowlimit = null; + $lowwarnlimit = null; + $divisor = 1; + $state = $ups_state / $divisor; + $descr = 'Rectifier Rotation Error'; + + discover_sensor($valid['sensor'], 'state', $device, $ups_state_oid, $index, $state_name, $descr, $divisor, 1, $lowlimit, $lowwarnlimit, $warnlimit, $limit, $state); + create_sensor_to_state_index($device, $state_name, $index); + } + // Bypass Status $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.6.1.0'; $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); if (!empty($ups_state) || $ups_state == 0) { $state_name = 'upsThreePhaseUPSStatusBypassFreqFail'; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id,'yes',0,14,2) , - array($state_index_id,'no',0,16,0) - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + create_state_index($state_name, $states); $index = 0; $limit = 10; @@ -705,26 +309,28 @@ if ($in_phaseNum == '3') { $state = $ups_state / $divisor; $descr = 'Bypass freq. fail'; - discover_sensor( - $valid['sensor'], - 'state', - $device, - $ups_state_oid, - $index, - $state_name, - $descr, - $divisor, - '1', - $lowlimit, - $lowwarnlimit, - $warnlimit, - $limit, - $state - ); - create_sensor_to_state_index( - $device, - $state_name, - $index - ); + discover_sensor($valid['sensor'], 'state', $device, $ups_state_oid, $index, $state_name, $descr, $divisor, 1, $lowlimit, $lowwarnlimit, $warnlimit, $limit, $state); + create_sensor_to_state_index($device, $state_name, $index); + } + + // Short Circuit + $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.7.7.0'; + $ups_state = snmp_get($device, $ups_state_oid, '-Oqv'); + + if (!empty($ups_state) || $ups_state == 0) { + $state_name = 'upsThreePhaseFaultStatusShortCircuit'; + create_state_index($state_name, $states); + + $index = 0; + $limit = 10; + $warnlimit = null; + $lowlimit = null; + $lowwarnlimit = null; + $divisor = 1; + $state = $ups_state / $divisor; + $descr = 'Short Circuit'; + + discover_sensor($valid['sensor'], 'state', $device, $ups_state_oid, $index, $state_name, $descr, $divisor, 1, $lowlimit, $lowwarnlimit, $warnlimit, $limit, $state); + create_sensor_to_state_index($device, $state_name, $index); } } diff --git a/includes/discovery/sensors/state/nokia-isam.inc.php b/includes/discovery/sensors/state/nokia-isam.inc.php index b29ebbedd9..8459251992 100644 --- a/includes/discovery/sensors/state/nokia-isam.inc.php +++ b/includes/discovery/sensors/state/nokia-isam.inc.php @@ -6,49 +6,35 @@ foreach ($snmp_data['nokiaIsamEqpBoardTable'] as $index => $data) { if (is_array($data)) { $oid = '.1.3.6.1.4.1.637.61.1.23.3.1.7.' . $index; $state_name = 'eqptBoardOperError'; - $state_index_id = create_state_index($state_name); $current = $data['eqptBoardOperError']; $descr = $pre_cache['nokiaIsamSlot'][$index]['numBasedSlot'] . ' ' . $data['eqptSlotActualType'] . ' (' . $data['eqptSlotPlannedType'] . ')'; - - //Create State Translation - if ($state_index_id !== null) { - $states = [ - [ 1, 0, 0, $state_index_id, 'no-error' ], - [ 2, 1, 0, $state_index_id, 'type-mismatch' ], - [ 3, 2, 0, $state_index_id, 'board-missing' ], - [ 4, 2, 0, $state_index_id, 'board-installation-missing' ], - [ 5, 1, 0, $state_index_id, 'no-planned-board' ], - [ 6, 1, 0, $state_index_id, 'waiting-for-sw' ], - [ 7, 2, 0, $state_index_id, 'init-boot-failed' ], - [ 8, 2, 0, $state_index_id, 'init-download-failed' ], - [ 9, 2, 0, $state_index_id, 'init-connection-failed' ], - [ 10, 2, 0, $state_index_id, 'init-configuration-failed' ], - [ 11, 1, 0, $state_index_id, 'board-reset-protection' ], - [ 12, 2, 0, $state_index_id, 'invalid-parameter' ], - [ 13, 1, 0, $state_index_id, 'temperature-alarm' ], - [ 14, 2, 0, $state_index_id, 'tempshutdown' ], - [ 15, 1, 0, $state_index_id, 'defense' ], - [ 16, 1, 0, $state_index_id, 'board-not-licensed' ], - [ 17, 2, 0, $state_index_id, 'sem-power-fail' ], - [ 18, 2, 0, $state_index_id, 'sem-ups-fail' ], - [ 19, 2, 0, $state_index_id, 'board-in-incompatible-slot' ], - [ 21, 1, 0, $state_index_id, 'download-ongoing' ], - [ 255, 2, 0, $state_index_id, 'unknown-error' ], - ]; - foreach ($states as $value) { - $insert = [ - 'state_value' => $value[0], - 'state_generic_value' => $value[1], - 'state_draw_graph' => $value[2], - 'state_index_id' => $value[3], - 'state_descr' => $value[4], - ]; - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'no-error'], + ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'type-mismatch'], + ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'board-missing'], + ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'board-installation-missing'], + ['value' => 5, 'generic' => 1, 'graph' => 0, 'descr' => 'no-planned-board'], + ['value' => 6, 'generic' => 1, 'graph' => 0, 'descr' => 'waiting-for-sw'], + ['value' => 7, 'generic' => 2, 'graph' => 0, 'descr' => 'init-boot-failed'], + ['value' => 8, 'generic' => 2, 'graph' => 0, 'descr' => 'init-download-failed'], + ['value' => 9, 'generic' => 2, 'graph' => 0, 'descr' => 'init-connection-failed'], + ['value' => 10, 'generic' => 2, 'graph' => 0, 'descr' => 'init-configuration-failed'], + ['value' => 11, 'generic' => 1, 'graph' => 0, 'descr' => 'board-reset-protection'], + ['value' => 12, 'generic' => 2, 'graph' => 0, 'descr' => 'invalid-parameter'], + ['value' => 13, 'generic' => 1, 'graph' => 0, 'descr' => 'temperature-alarm'], + ['value' => 14, 'generic' => 2, 'graph' => 0, 'descr' => 'tempshutdown'], + ['value' => 15, 'generic' => 1, 'graph' => 0, 'descr' => 'defense'], + ['value' => 16, 'generic' => 1, 'graph' => 0, 'descr' => 'board-not-licensed'], + ['value' => 17, 'generic' => 2, 'graph' => 0, 'descr' => 'sem-power-fail'], + ['value' => 18, 'generic' => 2, 'graph' => 0, 'descr' => 'sem-ups-fail'], + ['value' => 19, 'generic' => 2, 'graph' => 0, 'descr' => 'board-in-incompatible-slot'], + ['value' => 21, 'generic' => 1, 'graph' => 0, 'descr' => 'download-ongoing'], + ['value' => 255, 'generic' => 2, 'graph' => 0, 'descr' => 'unknown-error'], + ]; + create_state_index($state_name, $states); //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $current); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $current); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); } diff --git a/includes/discovery/sensors/state/nxos.inc.php b/includes/discovery/sensors/state/nxos.inc.php index 0d97e194c5..bc55adfe50 100644 --- a/includes/discovery/sensors/state/nxos.inc.php +++ b/includes/discovery/sensors/state/nxos.inc.php @@ -11,7 +11,7 @@ */ $fan_tray_oid = '.1.3.6.1.4.1.9.9.117.1.4.1.1.1'; -$fan_trays = snmpwalk_cache_oid_num($device, $fan_tray_oid, array()); +$fan_trays = snmpwalk_cache_oid_num($device, $fan_tray_oid, []); /* CISCO-ENTITY-FRU-CONTROL-MIB cefcFanTrayOperStatus * unknown(1), @@ -31,26 +31,13 @@ if (is_array($fan_trays)) { $descr = trim(snmp_get($device, "$entity_oid.$index", '-Ovq'), '"'); $state_name = "cefcFanTrayOperStatus"; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id, 'unknown', 0, 1, 3), - array($state_index_id, 'up', 1, 2, 0), - array($state_index_id, 'down', 1, 3, 2), - array($state_index_id, 'warning', 1, 4, 1), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ['value' => 2, 'generic' => 0, 'graph' => 1, 'descr' => 'up'], + ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'down'], + ['value' => 4, 'generic' => 1, 'graph' => 1, 'descr' => 'warning'], + ]; + create_state_index($state_name, $states); discover_sensor($valid['sensor'], 'state', $device, $current_oid, $index, $state_name, $descr, 1, 1); create_sensor_to_state_index($device, $state_name, $index); diff --git a/includes/discovery/sensors/state/pcoweb.inc.php b/includes/discovery/sensors/state/pcoweb.inc.php index 76dc2e7b85..b866c16112 100644 --- a/includes/discovery/sensors/state/pcoweb.inc.php +++ b/includes/discovery/sensors/state/pcoweb.inc.php @@ -12,12 +12,12 @@ $divisor = '1'; $type = 'pcoweb'; -$compressors = array( +$compressors = [ ".1.3.6.1.4.1.9839.2.1.1.1.0", #compressore1.0 ".1.3.6.1.4.1.9839.2.1.1.2.0", #compressore2.0 ".1.3.6.1.4.1.9839.2.1.1.3.0", #compressore3.0 ".1.3.6.1.4.1.9839.2.1.1.4.0" #compressore4.0 -); +]; foreach ($compressors as $compressor_oid) { $current = snmp_get($device, $compressor_oid, '-OqvU', 'CAREL-ug40cdz-MIB'); diff --git a/includes/discovery/sensors/state/powervault.inc.php b/includes/discovery/sensors/state/powervault.inc.php index 4f21d2cedc..344794fe47 100644 --- a/includes/discovery/sensors/state/powervault.inc.php +++ b/includes/discovery/sensors/state/powervault.inc.php @@ -16,27 +16,14 @@ list($oid, $value) = explode(' ', $state); if (is_numeric($value)) { $descr = "Global Status"; $state_name = "shadowStatusGlobalStatus"; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - $states = array( - array($state_index_id, 'other', 0, 1, 2), - array($state_index_id, 'unknown', 1, 2, 3), - array($state_index_id, 'ok', 1, 3, 0), - array($state_index_id, 'critical', 1, 4, 2), - array($state_index_id, 'non-Recoverable', 1, 5, 2), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 2, 'descr' => 'other'], + ['value' => 2, 'generic' => 0, 'graph' => 3, 'descr' => 'unknown'], + ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'ok'], + ['value' => 4, 'generic' => 0, 'graph' => 2, 'descr' => 'critical'], + ['value' => 5, 'generic' => 0, 'graph' => 2, 'descr' => 'non-Recoverable'], + ]; + create_state_index($state_name, $states); discover_sensor($valid['sensor'], 'state', $device, $oid, 1, $state_name, $descr, 1, 1); create_sensor_to_state_index($device, $state_name, 1); diff --git a/includes/discovery/sensors/state/procurve.inc.php b/includes/discovery/sensors/state/procurve.inc.php index 3ea2f4c1ce..b4051398ac 100644 --- a/includes/discovery/sensors/state/procurve.inc.php +++ b/includes/discovery/sensors/state/procurve.inc.php @@ -24,32 +24,21 @@ */ foreach ($pre_cache['procurve_hpicfSensorTable'] as $index => $data) { - $status_name = $data['hpicfSensorObjectId']; - $status_oid = '.1.3.6.1.4.1.11.2.14.11.1.2.6.1.4.'; - $status_descr = $data['hpicfSensorDescr']; + $state_name = $data['hpicfSensorObjectId']; + $state_oid = '.1.3.6.1.4.1.11.2.14.11.1.2.6.1.4.'; + $state_descr = $data['hpicfSensorDescr']; $state = $data['hpicfSensorStatus']; - $tmp_index = $status_name . '.' . $index; - $state_index_id = create_state_index($status_name); - if ($state_index_id !== null) { - $states = array( - array($state_index_id, 'unknown', 0, 1, 3), - array($state_index_id, 'bad', 1, 2, 2), - array($state_index_id, 'warning', 1, 3, 1), - array($state_index_id, 'good', 1, 4, 0), - array($state_index_id, 'notPresent', 0, 5, 3), - ); + $state_index = $state_name . '.' . $index; - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - discover_sensor($valid['sensor'], 'state', $device, $status_oid . $index, $tmp_index, $status_name, $status_descr, '1', '1', null, null, null, null, $state); - create_sensor_to_state_index($device, $status_name, $tmp_index); + $states = [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ['value' => 2, 'generic' => 2, 'graph' => 1, 'descr' => 'bad'], + ['value' => 3, 'generic' => 1, 'graph' => 1, 'descr' => 'warning'], + ['value' => 4, 'generic' => 0, 'graph' => 1, 'descr' => 'good'], + ['value' => 5, 'generic' => 3, 'graph' => 0, 'descr' => 'notPresent'], + ]; + create_state_index($state_name, $states); + + discover_sensor($valid['sensor'], 'state', $device, $state_oid . $index, $state_index, $state_name, $state_descr, '1', '1', null, null, null, null, $state); + create_sensor_to_state_index($device, $state_name, $state_index); } diff --git a/includes/discovery/sensors/state/qnap.inc.php b/includes/discovery/sensors/state/qnap.inc.php index 14b0f31d81..fb5c3c20c3 100644 --- a/includes/discovery/sensors/state/qnap.inc.php +++ b/includes/discovery/sensors/state/qnap.inc.php @@ -24,29 +24,16 @@ for ($i = 1; $i <= $total_disks; $i++) { $status_name = 'qnap_hdd_status_' . $i; $status_descr = 'HDD ' . $i . ' status'; if (is_numeric($state)) { - $state_index_id = create_state_index($status_name); + $states = [ + ['value' => 0, 'generic' => 0, 'graph' => 1, 'descr' => 'ready'], + ['value' => -4, 'generic' => 1, 'graph' => 0, 'descr' => 'unknown'], + ['value' => -5, 'generic' => 1, 'graph' => 0, 'descr' => 'no disk'], + ['value' => -6, 'generic' => 1, 'graph' => 0, 'descr' => 'invalid'], + ['value' => -9, 'generic' => 2, 'graph' => 2, 'descr' => 'rw Error'], + ]; + create_state_index($state_name, $states); - if ($state_index_id !== null) { - $states = array( - array($state_index_id, 'ready', 1, 0, 0), - array($state_index_id, 'unknown', 0, -4, 1), - array($state_index_id, 'no disk', 0, -5, 1), - array($state_index_id, 'invalid', 0, -6, 1), - array($state_index_id, 'rw Error', 2, -9, 2), - ); - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - discover_sensor($valid['sensor'], 'state', $device, $status_oid . $i, 1, $status_name, $status_descr, '1', '1', null, null, null, null, $state, 'snmp', 1); + discover_sensor($valid['sensor'], 'state', $device, $status_oid . $i, 1, $status_name, $status_descr, 1, 1, null, null, null, null, $state, 'snmp', 1); create_sensor_to_state_index($device, $status_name, 1); } } @@ -70,26 +57,14 @@ for ($i = 1; $i <= $total_disks; $i++) { } if (is_numeric($state)) { - $state_index_id = create_state_index($smart_name); - if ($state_index_id !== null) { - $states = array( - array($state_index_id, 'normal', 1, 1, 0), - array($state_index_id, 'no disk', 0, 0, 1), - array($state_index_id, 'warning', 2, 2, 2), - ); + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'normal'], + ['value' => 0, 'generic' => 1, 'graph' => 0, 'descr' => 'no disk'], + ['value' => 2, 'generic' => 2, 'graph' => 2, 'descr' => 'warning'], + ]; + create_state_index($state_name, $states); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - discover_sensor($valid['sensor'], 'state', $device, $smart_oid . $i, 1, $smart_name, $smart_descr, '1', '1', null, null, null, null, $state, 'snmp', 1); + discover_sensor($valid['sensor'], 'state', $device, $smart_oid . $i, 1, $smart_name, $smart_descr, 1, 1, null, null, null, null, $state, 'snmp', 1); create_sensor_to_state_index($device, $smart_name, 1); } } diff --git a/includes/discovery/sensors/state/quanta.inc.php b/includes/discovery/sensors/state/quanta.inc.php index 5e191da77f..274caa61a1 100644 --- a/includes/discovery/sensors/state/quanta.inc.php +++ b/includes/discovery/sensors/state/quanta.inc.php @@ -12,49 +12,35 @@ d_echo('Quanta Chassis Power Supply state'); -$tables = array( - array('powerSupplyTable', 'boxServicesPowSupplyItemState', 'quantaPowerSupplyStatus', 'Power Supply ', 'NETGEAR-BOXSERVICES-PRIVATE-MIB', '.1.3.6.1.4.1.4413.1.1.43.1.7.1.3'), -); +$tables = [ + ['powerSupplyTable', 'boxServicesPowSupplyItemState', 'quantaPowerSupplyStatus', 'Power Supply ', 'NETGEAR-BOXSERVICES-PRIVATE-MIB', '.1.3.6.1.4.1.4413.1.1.43.1.7.1.3'], +]; foreach ($tables as $tablevalue) { - $temp = snmpwalk_cache_multi_oid($device, $tablevalue[1], array(), $tablevalue[4]); + $temp = snmpwalk_cache_multi_oid($device, $tablevalue[1], [], $tablevalue[4]); $cur_oid = $tablevalue[1]; if (is_array($temp)) { $state_name = $tablevalue[2]; - $state_index_id = create_state_index($state_name); - - if ($state_index_id !== null) { - if ($state_name == 'quantaPowerSupplyStatus') { - $states = array( - array($state_index_id, 'other', 0, 0, 3), - array($state_index_id, 'notpresent', 0, 1, 3), - array($state_index_id, 'operational', 1, 2, 0), - array($state_index_id, 'failed', 0, 3, 2), - array($state_index_id, 'powering', 1, 4, 0), - array($state_index_id, 'nopower', 0, 5, 1), - array($state_index_id, 'notpowering', 0, 6, 1), - array($state_index_id, 'incompatible', 0, 7, 2), - ); - } - - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } + if ($state_name == 'quantaPowerSupplyStatus') { + $states = [ + ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'other'], + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'notpresent'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'operational'], + ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'failed'], + ['value' => 4, 'generic' => 0, 'graph' => 0, 'descr' => 'powering'], + ['value' => 5, 'generic' => 1, 'graph' => 0, 'descr' => 'nopower'], + ['value' => 6, 'generic' => 1, 'graph' => 0, 'descr' => 'notpowering'], + ['value' => 7, 'generic' => 2, 'graph' => 0, 'descr' => 'incompatible'], + ]; } + create_state_index($state_name, $states); foreach ($temp as $index => $entry) { $descr = $tablevalue[3] . $index; $oid_for_entry = $tablevalue[5] . '.' . $index; - discover_sensor($valid['sensor'], 'state', $device, $oid_for_entry, $index, $state_name, $descr, '1', '1', null, null, null, null, $entry[$cur_oid], 'snmp'); + discover_sensor($valid['sensor'], 'state', $device, $oid_for_entry, $index, $state_name, $descr, 1, 1, null, null, null, null, $entry[$cur_oid], 'snmp'); create_sensor_to_state_index($device, $state_name, $index); } } diff --git a/includes/discovery/sensors/state/ray.inc.php b/includes/discovery/sensors/state/ray.inc.php index 10a9b91ea9..78e6be1099 100644 --- a/includes/discovery/sensors/state/ray.inc.php +++ b/includes/discovery/sensors/state/ray.inc.php @@ -9,12 +9,12 @@ if ($state) { $state_name = 'systemStatus'; create_state_index( $state_name, - array( - array('value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'Unknown'), - array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Ok'), - array('value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'Warning'), - array('value' => 3, 'generic' => 3, 'graph' => 0, 'descr' => 'Alarm'), - ) + [ + ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'Unknown'], + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Ok'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'Warning'], + ['value' => 3, 'generic' => 3, 'graph' => 0, 'descr' => 'Alarm'], + ] ); $sensor_index = 0; @@ -48,13 +48,13 @@ if ($state) { $state_name = 'lineStatus'; create_state_index( $state_name, - array( - array('value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'Unknown'), - array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Ok'), - array('value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'Analyzer'), - array('value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'Connecting'), - array('value' => 4, 'generic' => 3, 'graph' => 0, 'descr' => 'Searching'), - ) + [ + ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'Unknown'], + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Ok'], + ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'Analyzer'], + ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'Connecting'], + ['value' => 4, 'generic' => 3, 'graph' => 0, 'descr' => 'Searching'], + ] ); $sensor_index = 1; @@ -88,11 +88,11 @@ if ($state) { $state_name = 'rfPowerStatus'; create_state_index( $state_name, - array( - array('value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'Unknown'), - array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Ok'), - array('value' => 2, 'generic' => 3, 'graph' => 0, 'descr' => 'Failure'), - ) + [ + ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'Unknown'], + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Ok'], + ['value' => 2, 'generic' => 3, 'graph' => 0, 'descr' => 'Failure'], + ] ); $sensor_index = 2; @@ -126,11 +126,11 @@ if ($state) { $state_name = 'ethPeer'; create_state_index( $state_name, - array( - array('value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'Unknown'), - array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Up'), - array('value' => 2, 'generic' => 3, 'graph' => 0, 'descr' => 'Down'), - ) + [ + ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'Unknown'], + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Up'], + ['value' => 2, 'generic' => 3, 'graph' => 0, 'descr' => 'Down'], + ] ); $sensor_index = 3; diff --git a/includes/discovery/sensors/state/rfc1628.inc.php b/includes/discovery/sensors/state/rfc1628.inc.php index 3ad43055c6..bc9c7d92e7 100644 --- a/includes/discovery/sensors/state/rfc1628.inc.php +++ b/includes/discovery/sensors/state/rfc1628.inc.php @@ -9,12 +9,12 @@ if (is_numeric($state)) { $state_name = 'upsBatteryStatusState'; create_state_index( $state_name, - array( - array('value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'Unknown'), - array('value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'), - array('value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'Low'), - array('value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'Depleted'), - ) + [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'Unknown'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'], + ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'Low'], + ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'Depleted'], + ] ); $sensor_index = 0; @@ -48,15 +48,15 @@ if (is_numeric($state)) { $state_name = 'upsOutputSourceState'; create_state_index( $state_name, - array( - array('value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'Other'), - array('value' => 2, 'generic' => 3, 'graph' => 0, 'descr' => 'None'), - array('value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'), - array('value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'Bypass'), - array('value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'Battery'), - array('value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'Booster'), - array('value' => 7, 'generic' => 2, 'graph' => 0, 'descr' => 'Reducer'), - ) + [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'Other'], + ['value' => 2, 'generic' => 3, 'graph' => 0, 'descr' => 'None'], + ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'], + ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'Bypass'], + ['value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'Battery'], + ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'Booster'], + ['value' => 7, 'generic' => 2, 'graph' => 0, 'descr' => 'Reducer'], + ] ); $sensor_index = 0; diff --git a/includes/discovery/sensors/state/serveriron.inc.php b/includes/discovery/sensors/state/serveriron.inc.php index a34210f8b9..2e3960bf7e 100644 --- a/includes/discovery/sensors/state/serveriron.inc.php +++ b/includes/discovery/sensors/state/serveriron.inc.php @@ -9,7 +9,7 @@ for ($i=1; $i != 3; $i++) { $power_oid = '.1.3.6.1.4.1.1991.1.1.1.2.1.1.3.'.$i; $power_status = snmp_get($device, $power_oid, '-Oqv'); if (!empty($power_status)) { - discover_sensor($valid['sensor'], 'state', $device, $power_oid, 'powerstatus'.$i, 'snmp', 'Power Supply '.$i.' Status', '1', '1', '1', null, null, '3', $power_status); + discover_sensor($valid['sensor'], 'state', $device, $power_oid, 'powerstatus'.$i, 'snmp', 'Power Supply '.$i.' Status', 1, 1, '1', null, null, '3', $power_status); } } @@ -18,6 +18,6 @@ for ($i=1; $i != 7; $i++) { $fan_oid = '.1.3.6.1.4.1.1991.1.1.1.3.1.1.3.'.$i; $fan_status = snmp_get($device, $fan_oid, '-Oqv'); if (!empty($fan_status)) { - discover_sensor($valid['sensor'], 'state', $device, $fan_oid, 'fanstatus'.$i, 'snmp', 'Fan '.$i.' Status', '1', '1', '1', null, null, '3', $fan_status); + discover_sensor($valid['sensor'], 'state', $device, $fan_oid, 'fanstatus'.$i, 'snmp', 'Fan '.$i.' Status', 1, 1, '1', null, null, '3', $fan_status); } } diff --git a/includes/discovery/sensors/state/serverscheck.inc.php b/includes/discovery/sensors/state/serverscheck.inc.php index 6e45952392..e4eb587e2c 100644 --- a/includes/discovery/sensors/state/serverscheck.inc.php +++ b/includes/discovery/sensors/state/serverscheck.inc.php @@ -32,34 +32,23 @@ $serverscheck_oids = [ ]; foreach ($pre_cache['serverscheck_control'] as $oid_name => $oid_value) { - if ((str_contains($oid_name, 'name')) && (str_contains($oid_value, array('Flooding', 'Leckage')))) { + if ((str_contains($oid_name, 'name')) && (str_contains($oid_value, ['Flooding', 'Leckage']))) { preg_match("/(\d+)/", $oid_name, $temp_x); $tmp_oid = 'sensor' . $temp_x[0] . 'Value.0'; $current = $pre_cache['serverscheck_control'][$tmp_oid]; - $state = 'Serverscheck_FloodSensor'; + $state_name = 'Serverscheck_FloodSensor'; if ($current) { $index = str_replace('.0', '', $oid_name); $descr = $oid_value; - $state_index_id = create_state_index($state); - if ($state_index_id) { - $states = [ - [$state_index_id, '-', 1, 1, 1], - [$state_index_id, 'DRY', 1, 2, 0], - [$state_index_id, 'WET', 1, 4, 2], - ]; - foreach ($states as $value) { - $insert = [ - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ]; - dbInsert($insert, 'state_translations'); - } - } - discover_sensor($valid['sensor'], 'state', $device, $serverscheck_oids[$tmp_oid], $index, $state, $descr, 1, 1, null, null, null, null, 1); - create_sensor_to_state_index($device, $state, $index); + $states = [ + ['value' => 1, 'generic' => 1, 'graph' => 1, 'descr' => '-'], + ['value' => 2, 'generic' => 0, 'graph' => 1, 'descr' => 'DRY'], + ['value' => 4, 'generic' => 2, 'graph' => 1, 'descr' => 'WET'], + ]; + create_state_index($state_name, $states); + + discover_sensor($valid['sensor'], 'state', $device, $serverscheck_oids[$tmp_oid], $index, $state_name, $descr, 1, 1, null, null, null, null, 1); + create_sensor_to_state_index($device, $state_name, $index); } } } diff --git a/includes/discovery/sensors/state/timos.inc.php b/includes/discovery/sensors/state/timos.inc.php index 5f0cc5285c..cdde228ce0 100644 --- a/includes/discovery/sensors/state/timos.inc.php +++ b/includes/discovery/sensors/state/timos.inc.php @@ -1,39 +1,37 @@ 1, 'generic' => 3, 'graph' => 0, 'descr' => 'Unknown'), - array('value' => 2, 'generic' => 3, 'graph' => 0, 'descr' => 'Not Equipped'), - array('value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'OK'), - array('value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'Failed'), - array('value' => 5, 'generic' => 1, 'graph' => 0, 'descr' => 'Out of Service') - ); - + $dev_states = [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'Unknown'], + ['value' => 2, 'generic' => 3, 'graph' => 0, 'descr' => 'Not Equipped'], + ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'OK'], + ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'Failed'], + ['value' => 5, 'generic' => 1, 'graph' => 0, 'descr' => 'Out of Service'] + ]; create_state_index($dev_state_name, $dev_states); $ps_state_name = 'tmnxChassisPowerSupplyAssignedTypes'; - $ps_states = array( - array('value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'None'), - array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'DC'), - array('value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Single AC'), - array('value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'Multiple AC') - ); - + $ps_states = [ + ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'None'], + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'DC'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Single AC'], + ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'Multiple AC'] + ]; create_state_index($ps_state_name, $ps_states); - $ps_table = array( - array('tbl_index' => 2, 'desc' => 'AC Status PS ', 'type' => $dev_state_name), - array('tbl_index' => 3, 'desc' => 'DC Status PS ', 'type' => $dev_state_name), - array('tbl_index' => 4, 'desc' => 'Temperature Status PS ', 'type' => $dev_state_name), - array('tbl_index' => 6, 'desc' => 'Power Supply 1 Status PS ', 'type' => $dev_state_name), - array('tbl_index' => 7, 'desc' => 'Power Supply 2 Status PS ', 'type' => $dev_state_name), - array('tbl_index' => 8, 'desc' => 'Assigned Type PS ', 'type' => $ps_state_name), - array('tbl_index' => 9, 'desc' => 'Input Status PS ', 'type' => $dev_state_name), - array('tbl_index' => 10, 'desc' => 'Output Status PS ', 'type' => $dev_state_name), - ); + $ps_table = [ + ['tbl_index' => 2, 'desc' => 'AC Status PS ', 'type' => $dev_state_name], + ['tbl_index' => 3, 'desc' => 'DC Status PS ', 'type' => $dev_state_name], + ['tbl_index' => 4, 'desc' => 'Temperature Status PS ', 'type' => $dev_state_name], + ['tbl_index' => 6, 'desc' => 'Power Supply 1 Status PS ', 'type' => $dev_state_name], + ['tbl_index' => 7, 'desc' => 'Power Supply 2 Status PS ', 'type' => $dev_state_name], + ['tbl_index' => 8, 'desc' => 'Assigned Type PS ', 'type' => $ps_state_name], + ['tbl_index' => 9, 'desc' => 'Input Status PS ', 'type' => $dev_state_name], + ['tbl_index' => 10, 'desc' => 'Output Status PS ', 'type' => $dev_state_name], + ]; $base_oid = '.1.3.6.1.4.1.6527.3.1.2.2.1.5.1.'; diff --git a/includes/discovery/sensors/state/voss.inc.php b/includes/discovery/sensors/state/voss.inc.php index bd8f8ea1da..fba434848c 100644 --- a/includes/discovery/sensors/state/voss.inc.php +++ b/includes/discovery/sensors/state/voss.inc.php @@ -20,7 +20,7 @@ * down(3), */ -$fan = snmpwalk_cache_multi_oid($device, 'rcChasFanOperStatus', array(), 'RAPID-CITY'); +$fan = snmpwalk_cache_multi_oid($device, 'rcChasFanOperStatus', [], 'RAPID-CITY'); if (is_array($fan)) { foreach ($fan as $oid => $array) { @@ -31,27 +31,14 @@ if (is_array($fan)) { $descr = "Fan $index"; $state_name = 'rcChasFanOperStatus'; - $state_index_id = create_state_index($state_name); + $states = [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'up'], + ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'down'], + ]; + create_state_index($state_name, $states); - if ($state_index_id !== null) { - $states = array( - array($state_index_id, 'unknown', 0, 1, 3), - array($state_index_id, 'up', 0, 2, 0), - array($state_index_id, 'down', 0, 3, 1), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - discover_sensor($valid['sensor'], 'state', $device, $current_oid, "rcChasFanOperStatus.$index", $state_name, $descr, '1', '1', null, null, '3', '3', $state); + discover_sensor($valid['sensor'], 'state', $device, $current_oid, "rcChasFanOperStatus.$index", $state_name, $descr, 1, 1, null, null, 3, 3, $state); create_sensor_to_state_index($device, $state_name, "rcChasFanOperStatus.$index"); } } @@ -63,7 +50,7 @@ if (is_array($fan)) { * down(4) */ -$power_supply = snmpwalk_cache_multi_oid($device, 'rcChasPowerSupplyOperStatus', array(), 'RAPID-CITY'); +$power_supply = snmpwalk_cache_multi_oid($device, 'rcChasPowerSupplyOperStatus', [], 'RAPID-CITY'); if (is_array($power_supply)) { foreach ($power_supply as $oid => $array) { @@ -74,28 +61,15 @@ if (is_array($power_supply)) { $descr = "Power Supply $index"; $state_name = 'rcChasPowerSupplyOperStatus'; - $state_index_id = create_state_index($state_name); + $states = [ + ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'empty'], + ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'up'], + ['value' => 4, 'generic' => 1, 'graph' => 0, 'descr' => 'down'], + ]; + create_state_index($state_name, $states); - if ($state_index_id !== null) { - $states = array( - array($state_index_id, 'unknown', 0, 1, 3), - array($state_index_id, 'empty', 0, 2, 0), - array($state_index_id, 'up', 0, 3, 0), - array($state_index_id, 'down', 0, 4, 1), - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } - - discover_sensor($valid['sensor'], 'state', $device, $current_oid, "rcChasPowerSupplyOperStatus.$index", $state_name, $descr, '1', '1', null, null, '4', '4', $state); + discover_sensor($valid['sensor'], 'state', $device, $current_oid, "rcChasPowerSupplyOperStatus.$index", $state_name, $descr, 1, 1, null, null, 4, 4, $state); create_sensor_to_state_index($device, $state_name, "rcChasPowerSupplyOperStatus.$index"); } } diff --git a/includes/discovery/sensors/state/wipipe.inc.php b/includes/discovery/sensors/state/wipipe.inc.php index 60d9b5ec60..0dcf9f4969 100644 --- a/includes/discovery/sensors/state/wipipe.inc.php +++ b/includes/discovery/sensors/state/wipipe.inc.php @@ -20,72 +20,48 @@ foreach ($pre_cache['wipipe_oids'] as $index => $entry) { $cur_oid = '.1.3.6.1.4.1.20992.1.2.2.1.5.'; //Create State Index $state_name = 'mdmStatus'; - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'established',0,1,0) , - array($state_index_id,'establishing',0,2,0) , - array($state_index_id,'ready',0,3,0) , - array($state_index_id,'error',0,4,2) , - array($state_index_id,'disconnected',0,5,2) , - array($state_index_id,'disconnecting',0,6,1) , - array($state_index_id,'suspended',0,7,2) , - array($state_index_id,'empty',0,8,3) , - array($state_index_id,'notconfigured',0,9,3) , - array($state_index_id,'userstopped',0,10,1) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'established'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'establishing'], + ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'ready'], + ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'error'], + ['value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'disconnected'], + ['value' => 6, 'generic' => 1, 'graph' => 0, 'descr' => 'disconnecting'], + ['value' => 7, 'generic' => 2, 'graph' => 0, 'descr' => 'suspended'], + ['value' => 8, 'generic' => 3, 'graph' => 0, 'descr' => 'empty'], + ['value' => 9, 'generic' => 3, 'graph' => 0, 'descr' => 'notconfigured'], + ['value' => 10, 'generic' => 1, 'graph' => 0, 'descr' => 'userstopped'], + ]; + create_state_index($state_name, $states); + // Get Modem Model & Phone Number for description $modemdesc = $entry['mdmDescr']; $modemmdn = $entry['mdmMDN']; $descr = "mdmStatus - " . $modemdesc . " - " . $modemmdn; //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, '1', '1', null, null, null, null, $entry['mdmStatus'], 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, 1, 1, null, null, null, null, $entry['mdmStatus'], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); } } // Device Firmware Upgrade Status -$upgradestatus = snmpwalk_cache_oid($device, 'devFWUpgradeStatus', array(), 'WIPIPE-MIB'); +$upgradestatus = snmpwalk_cache_oid($device, 'devFWUpgradeStatus', [], 'WIPIPE-MIB'); foreach ($upgradestatus as $index => $entry) { $cur_oid = '.1.3.6.1.4.1.20992.1.1.4.'; //Create State Index $state_name = 'devFWUpgradeStatus'; - $state_index_id = create_state_index($state_name); - //Create State Translation - if ($state_index_id) { - $states = array( - array($state_index_id,'idle',0,1,0) , - array($state_index_id,'upgrading',0,2,0) , - array($state_index_id,'uptodate',0,3,0) , - array($state_index_id,'updateAvail',0,4,1) , - array($state_index_id,'failure',0,5,2) - ); - foreach ($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] - ); - dbInsert($insert, 'state_translations'); - } - } + $states = [ + ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'idle'], + ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'upgrading'], + ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'uptodate'], + ['value' => 4, 'generic' => 1, 'graph' => 0, 'descr' => 'updateAvail'], + ['value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'failure'], + ]; + create_state_index($state_name, $states); + $descr = "Firmware Upgrade Status"; //Discover Sensors - discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, '1', '1', null, null, null, null, $entry['devFWUpgradeStatus'], 'snmp', $index); + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, 1, 1, null, null, null, null, $entry['devFWUpgradeStatus'], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); } diff --git a/includes/discovery/sensors/temperature/adva_fsp150.inc.php b/includes/discovery/sensors/temperature/adva_fsp150.inc.php index db2ab5e7b1..1909073b21 100644 --- a/includes/discovery/sensors/temperature/adva_fsp150.inc.php +++ b/includes/discovery/sensors/temperature/adva_fsp150.inc.php @@ -20,56 +20,26 @@ // ***** Temperature Sensors for ADVA FSP150CC Series // ************************************************************* - $sensors_adva = array - ( - array( - 'sensor_name' => 'ethernetNTEGE114CardTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.26.1.6'), - array( - 'sensor_name' => 'ethernetNTEGE114SCardTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.46.1.6'), - array( - 'sensor_name' => 'ethernetNTEXG210CardTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.30.1.6'), - array( - 'sensor_name' => 'ethernetXG1XCCCardTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.31.1.6'), - array( - 'sensor_name' => 'ethernet10x1GHighPerCardTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.37.1.5'), - array( - 'sensor_name' => 'ethernet1x10GHighPerCardTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.36.1.5'), - array( - 'sensor_name' => 'ethernetSWFCardTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.20.1.5'), - array( - 'sensor_name' => 'psuTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.4.1.7'), - array( - 'sensor_name' => 'scuTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.6.1.6'), - array( - 'sensor_name' => 'nemiTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.7.1.6'), - array( - 'sensor_name' => 'amiTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.22.1.5'), - array( - 'sensor_name' => 'ethernetGE8SCCCardTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.41.1.6'), - array( - 'sensor_name' => 'stuHighPerCardTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.47.1.5'), - array( - 'sensor_name' => 'stiHighPerTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.48.1.5'), - array( - 'sensor_name' => 'ethernetGE8ECCCardTemperature', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.49.1.6')); + $sensors_adva = [ + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.26.1.6', 'sensor_name' => 'ethernetNTEGE114CardTemperature'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.46.1.6', 'sensor_name' => 'ethernetNTEGE114SCardTemperature'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.30.1.6', 'sensor_name' => 'ethernetNTEXG210CardTemperature'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.31.1.6', 'sensor_name' => 'ethernetXG1XCCCardTemperature'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.37.1.5', 'sensor_name' => 'ethernet10x1GHighPerCardTemperature'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.36.1.5', 'sensor_name' => 'ethernet1x10GHighPerCardTemperature'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.20.1.5', 'sensor_name' => 'ethernetSWFCardTemperature'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.4.1.7', 'sensor_name' => 'psuTemperature'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.6.1.6', 'sensor_name' => 'scuTemperature'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.7.1.6', 'sensor_name' => 'nemiTemperature'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.22.1.5', 'sensor_name' => 'amiTemperature'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.41.1.6', 'sensor_name' => 'ethernetGE8SCCCardTemperature'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.47.1.5', 'sensor_name' => 'stuHighPerCardTemperature'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.48.1.5', 'sensor_name' => 'stiHighPerTemperature'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.49.1.6', 'sensor_name' => 'ethernetGE8ECCCardTemperature'], + ]; - $multiplier = 1; - $divisor = 1; + $multiplier = 1; + $divisor = 1; foreach (array_keys($pre_cache['adva_fsp150']) as $index) { foreach ($sensors_adva as $entry) { diff --git a/includes/discovery/sensors/temperature/apc.inc.php b/includes/discovery/sensors/temperature/apc.inc.php index be52da254f..08fd895898 100644 --- a/includes/discovery/sensors/temperature/apc.inc.php +++ b/includes/discovery/sensors/temperature/apc.inc.php @@ -16,7 +16,7 @@ if ($oids) { // Environmental monitoring on UPSes etc // FIXME emConfigProbesTable may also be used? But not filled out on my device... -$apc_env_data = snmpwalk_cache_oid($device, 'iemConfigProbesTable', array(), 'PowerNet-MIB'); +$apc_env_data = snmpwalk_cache_oid($device, 'iemConfigProbesTable', [], 'PowerNet-MIB'); $apc_env_data = snmpwalk_cache_oid($device, 'iemStatusProbesTable', $apc_env_data, 'PowerNet-MIB'); foreach (array_keys($apc_env_data) as $index) { @@ -32,7 +32,7 @@ foreach (array_keys($apc_env_data) as $index) { discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $sensorType, $descr, '1', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current); } -$apc_env_data = snmpwalk_cache_oid($device, 'emsProbeStatus', array(), 'PowerNet-MIB'); +$apc_env_data = snmpwalk_cache_oid($device, 'emsProbeStatus', [], 'PowerNet-MIB'); foreach (array_keys($apc_env_data) as $index) { if ($apc_env_data[$index]['emsProbeStatusProbeCommStatus'] != 'commsNeverDiscovered') { @@ -54,12 +54,12 @@ foreach (array_keys($apc_env_data) as $index) { $oids = snmp_get($device, 'airIRRCGroupSetpointsCoolMetric.0', '-OsqnU', 'PowerNet-MIB'); if ($oids) { echo 'APC InRow Chiller '; - $temps = array(); - $temps['.1.3.6.1.4.1.318.1.1.13.3.2.2.2.7'] = 'Rack Inlet'; //airIRRCUnitStatusRackInletTempMetric - $temps['.1.3.6.1.4.1.318.1.1.13.3.2.2.2.9'] = 'Supply Air'; //airIRRCUnitStatusSupplyAirTempMetric - $temps['.1.3.6.1.4.1.318.1.1.13.3.2.2.2.11'] = 'Return Air'; //airIRRCUnitStatusReturnAirTempMetric + $temps = []; + $temps['.1.3.6.1.4.1.318.1.1.13.3.2.2.2.7'] = 'Rack Inlet'; //airIRRCUnitStatusRackInletTempMetric + $temps['.1.3.6.1.4.1.318.1.1.13.3.2.2.2.9'] = 'Supply Air'; //airIRRCUnitStatusSupplyAirTempMetric + $temps['.1.3.6.1.4.1.318.1.1.13.3.2.2.2.11'] = 'Return Air'; //airIRRCUnitStatusReturnAirTempMetric $temps['.1.3.6.1.4.1.318.1.1.13.3.2.2.2.24'] = 'Entering Fluid'; //airIRRCUnitStatusEnteringFluidTemperatureMetric - $temps['.1.3.6.1.4.1.318.1.1.13.3.2.2.2.26'] = 'Leaving Fluid'; //airIRRCUnitStatusLeavingFluidTemperatureMetric + $temps['.1.3.6.1.4.1.318.1.1.13.3.2.2.2.26'] = 'Leaving Fluid'; //airIRRCUnitStatusLeavingFluidTemperatureMetric foreach ($temps as $obj => $descr) { $oids = snmp_get($device, $obj.'.0', '-OsqnU', 'PowerNet-MIB'); list($oid,$current) = explode(' ', $oids); @@ -137,7 +137,7 @@ if ($oids !== false) { discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $sensorType, $descr, $precision, '1', null, null, null, null, $current); } -$cooling_unit = snmpwalk_cache_oid($device, 'coolingUnitExtendedAnalogEntry', array(), 'PowerNet-MIB'); +$cooling_unit = snmpwalk_cache_oid($device, 'coolingUnitExtendedAnalogEntry', [], 'PowerNet-MIB'); foreach ($cooling_unit as $index => $data) { $cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.6.1.2.1.3.' . $index; $descr = $data['coolingUnitExtendedAnalogDescription']; diff --git a/includes/discovery/sensors/temperature/arris-c4.inc.php b/includes/discovery/sensors/temperature/arris-c4.inc.php index 5e2b093d1d..11ce21e672 100644 --- a/includes/discovery/sensors/temperature/arris-c4.inc.php +++ b/includes/discovery/sensors/temperature/arris-c4.inc.php @@ -1,5 +1,5 @@ $entry) { diff --git a/includes/discovery/sensors/temperature/ciscowlc.inc.php b/includes/discovery/sensors/temperature/ciscowlc.inc.php index 14eedef771..bb675236d4 100644 --- a/includes/discovery/sensors/temperature/ciscowlc.inc.php +++ b/includes/discovery/sensors/temperature/ciscowlc.inc.php @@ -12,9 +12,9 @@ echo ' AIRESPACE temperature '; -$temp = snmpwalk_cache_multi_oid($device, 'bsnSensorTemperature', array(), 'AIRESPACE-WIRELESS-MIB'); -$low = snmpwalk_cache_multi_oid($device, 'bsnTemperatureAlarmLowLimit', array(), 'AIRESPACE-WIRELESS-MIB'); -$high = snmpwalk_cache_multi_oid($device, 'bsnTemperatureAlarmHighLimit', array(), 'AIRESPACE-WIRELESS-MIB'); +$temp = snmpwalk_cache_multi_oid($device, 'bsnSensorTemperature', [], 'AIRESPACE-WIRELESS-MIB'); +$low = snmpwalk_cache_multi_oid($device, 'bsnTemperatureAlarmLowLimit', [], 'AIRESPACE-WIRELESS-MIB'); +$high = snmpwalk_cache_multi_oid($device, 'bsnTemperatureAlarmHighLimit', [], 'AIRESPACE-WIRELESS-MIB'); if (is_array($temp)) { $cur_oid = '.1.3.6.1.4.1.14179.2.3.1.13.'; diff --git a/includes/discovery/sensors/temperature/comware.inc.php b/includes/discovery/sensors/temperature/comware.inc.php index 30d347050e..9e044a3239 100644 --- a/includes/discovery/sensors/temperature/comware.inc.php +++ b/includes/discovery/sensors/temperature/comware.inc.php @@ -12,10 +12,10 @@ echo 'Comware '; -$entphydata = dbFetchRows("SELECT `entPhysicalIndex`, `entPhysicalClass`, `entPhysicalName` FROM `entPhysical` WHERE `device_id` = ? AND `entPhysicalClass` REGEXP 'module|sensor' ORDER BY `entPhysicalIndex`", array($device['device_id'])); +$entphydata = dbFetchRows("SELECT `entPhysicalIndex`, `entPhysicalClass`, `entPhysicalName` FROM `entPhysical` WHERE `device_id` = ? AND `entPhysicalClass` REGEXP 'module|sensor' ORDER BY `entPhysicalIndex`", [$device['device_id']]); if (!empty($entphydata)) { - $tempdata = snmpwalk_cache_multi_oid($device, 'hh3cEntityExtTemperature', array(), 'HH3C-ENTITY-EXT-MIB'); + $tempdata = snmpwalk_cache_multi_oid($device, 'hh3cEntityExtTemperature', [], 'HH3C-ENTITY-EXT-MIB'); $tempdata = snmpwalk_cache_multi_oid($device, 'hh3cEntityExtTemperatureThreshold', $tempdata, 'HH3C-ENTITY-EXT-MIB'); foreach ($entphydata as $index) { foreach ($tempdata as $tempindex => $value) { @@ -55,7 +55,7 @@ $divisor_alarm = 1000; foreach ($pre_cache['comware_oids'] as $index => $entry) { if (is_numeric($entry['hh3cTransceiverTemperature']) && $entry['hh3cTransceiverTemperature'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { $oid = '.1.3.6.1.4.1.25506.2.70.1.1.1.15.' . $index; - $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array($index,$device['device_id'])); + $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", [$index,$device['device_id']]); $limit_low = $entry['hh3cTransceiverTempLoAlarm'] / $divisor_alarm; $warn_limit_low = $entry['hh3cTransceiverTempLoWarn'] / $divisor_alarm; $limit = $entry['hh3cTransceiverTempHiAlarm'] / $divisor_alarm; diff --git a/includes/discovery/sensors/temperature/dell.inc.php b/includes/discovery/sensors/temperature/dell.inc.php index 499c1f8600..1f418ac4f4 100644 --- a/includes/discovery/sensors/temperature/dell.inc.php +++ b/includes/discovery/sensors/temperature/dell.inc.php @@ -10,7 +10,7 @@ * the source code distribution for details. */ -$temp = snmpwalk_cache_multi_oid($device, 'temperatureProbeTable', array(), 'MIB-Dell-10892'); +$temp = snmpwalk_cache_multi_oid($device, 'temperatureProbeTable', [], 'MIB-Dell-10892'); $cur_oid = '.1.3.6.1.4.1.674.10892.1.700.20.1.6.'; $divisor = '10'; diff --git a/includes/discovery/sensors/temperature/dnos.inc.php b/includes/discovery/sensors/temperature/dnos.inc.php index 34eb4c3d06..8eb8a28609 100644 --- a/includes/discovery/sensors/temperature/dnos.inc.php +++ b/includes/discovery/sensors/temperature/dnos.inc.php @@ -22,7 +22,7 @@ foreach (explode("\n", $temps) as $i => $t) { // F10-S-SERIES-CHASSIS-MIB::chStackUnitModelID.1 = STRING: S25-01-GE-24V echo 'FTOS C-Series '; -$oids = snmpwalk_cache_oid($device, 'chStackUnitTemp', array(), 'F10-S-SERIES-CHASSIS-MIB', 'ftos'); +$oids = snmpwalk_cache_oid($device, 'chStackUnitTemp', [], 'F10-S-SERIES-CHASSIS-MIB', 'ftos'); $oids = snmpwalk_cache_oid($device, 'chStackUnitSysType', $oids, 'F10-S-SERIES-CHASSIS-MIB', 'ftos'); if (is_array($oids)) { @@ -39,7 +39,7 @@ if (is_array($oids)) { // DELL-NETWORKING-CHASSIS-MIB::dellNetStackUnitModelId.1 = INTEGER: m-MXL(25) echo 'FTOS M-Series '; -$oids = snmpwalk_cache_oid($device, 'dellNetStackUnitTemp', array(), 'DELL-NETWORKING-CHASSIS-MIB', 'dnos'); +$oids = snmpwalk_cache_oid($device, 'dellNetStackUnitTemp', [], 'DELL-NETWORKING-CHASSIS-MIB', 'dnos'); if (is_array($oids)) { foreach ($oids as $index => $entry) { diff --git a/includes/discovery/sensors/temperature/dsm.inc.php b/includes/discovery/sensors/temperature/dsm.inc.php index 7218a4f920..e9f49f9358 100644 --- a/includes/discovery/sensors/temperature/dsm.inc.php +++ b/includes/discovery/sensors/temperature/dsm.inc.php @@ -13,7 +13,7 @@ $diskstation_temperature = snmp_get($device, $diskstation_temperature_oid, '-Oqv discover_sensor($valid['sensor'], 'temperature', $device, $diskstation_temperature_oid, '99', 'snmp', 'System Temperature', '1', '1', null, null, null, null, $diskstation_temperature); // Get all disks in the device -$disks = snmpwalk_cache_multi_oid($device, 'diskTable', array(), 'SYNOLOGY-DISK-MIB'); +$disks = snmpwalk_cache_multi_oid($device, 'diskTable', [], 'SYNOLOGY-DISK-MIB'); // Parse all disks in the device to get the temperature if (is_array($disks)) { foreach ($disks as $disk_number => $entry) { diff --git a/includes/discovery/sensors/temperature/f5.inc.php b/includes/discovery/sensors/temperature/f5.inc.php index 02051861a0..c109ff27f4 100644 --- a/includes/discovery/sensors/temperature/f5.inc.php +++ b/includes/discovery/sensors/temperature/f5.inc.php @@ -1,9 +1,9 @@ $entry) { $entry['descr'] = 'Slot '.$index; @@ -29,7 +29,7 @@ if (is_array($oids)) { echo 'FTOS E-Series '; -$oids = snmpwalk_cache_oid($device, 'chSysCardUpperTemp', array(), 'F10-CHASSIS-MIB', 'ftos'); +$oids = snmpwalk_cache_oid($device, 'chSysCardUpperTemp', [], 'F10-CHASSIS-MIB', 'ftos'); if (is_array($oids)) { foreach ($oids as $index => $entry) { diff --git a/includes/discovery/sensors/temperature/geist-watchdog.inc.php b/includes/discovery/sensors/temperature/geist-watchdog.inc.php index 344ddce452..13b78d91b2 100644 --- a/includes/discovery/sensors/temperature/geist-watchdog.inc.php +++ b/includes/discovery/sensors/temperature/geist-watchdog.inc.php @@ -37,7 +37,7 @@ if ($value) { discover_sensor($valid['sensor'], 'temperature', $device, $current_oid, 'climateTempF', 'geist-watchdog', $descr, 1, 1, null, null, null, null, $value, null, null, null, 'fahrenheit_to_celsius'); } -$temp_table = snmpwalk_cache_oid($device, 'tempSensorTable', array(), 'GEIST-MIB-V3'); +$temp_table = snmpwalk_cache_oid($device, 'tempSensorTable', [], 'GEIST-MIB-V3'); foreach ($temp_table as $index => $temp_data) { if ($temp_data['tempSensorAvail'] == 1) { diff --git a/includes/discovery/sensors/temperature/ibmnos.inc.php b/includes/discovery/sensors/temperature/ibmnos.inc.php index 750efda41d..0600d0a48d 100644 --- a/includes/discovery/sensors/temperature/ibmnos.inc.php +++ b/includes/discovery/sensors/temperature/ibmnos.inc.php @@ -5,7 +5,7 @@ if (strstr($device['sysDescr'], 'IBM Flex System Fabric')) { if ($check_oids !== false) { $index = 0; echo 'IBM Flex System Fabric '; - $temps = array(); + $temps = []; $temps['.1.3.6.1.4.1.20301.2.5.1.3.1.22.0'] = 'Temperature Sensor 1'; $temps['.1.3.6.1.4.1.20301.2.5.1.3.1.23.0'] = 'Temperature Sensor 2'; $temps['.1.3.6.1.4.1.20301.2.5.1.3.1.26.0'] = 'Temperature Sensor 3'; diff --git a/includes/discovery/sensors/temperature/ies.inc.php b/includes/discovery/sensors/temperature/ies.inc.php index fc77bfae6f..c464ae70db 100644 --- a/includes/discovery/sensors/temperature/ies.inc.php +++ b/includes/discovery/sensors/temperature/ies.inc.php @@ -2,7 +2,7 @@ echo 'ZyXEL IES '; -$oids = array(); +$oids = []; $oids = snmpwalk_cache_multi_oid($device, 'accessSwitchSysTempCurValue', $oids, 'ZYXEL-AS-MIB'); $oids = snmpwalk_cache_multi_oid($device, 'accessSwitchSysTempHighThresh', $oids, 'ZYXEL-AS-MIB'); diff --git a/includes/discovery/sensors/temperature/junos.inc.php b/includes/discovery/sensors/temperature/junos.inc.php index 6ebc69a6b3..b74fa46bc2 100644 --- a/includes/discovery/sensors/temperature/junos.inc.php +++ b/includes/discovery/sensors/temperature/junos.inc.php @@ -29,7 +29,7 @@ $divisor = 1; foreach ($pre_cache['junos_oids'] as $index => $entry) { if (is_numeric($entry['jnxDomCurrentModuleTemperature']) && $entry['jnxDomCurrentModuleTemperature'] != 0 && $entry['jnxDomCurrentModuleTemperatureLowAlarmThreshold']) { $oid = '.1.3.6.1.4.1.2636.3.60.1.1.1.1.8.'.$index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Temperature'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Temperature'; $limit_low = $entry['jnxDomCurrentModuleTemperatureLowAlarmThreshold']/$divisor; $warn_limit_low = $entry['jnxDomCurrentModuleTemperatureLowWarningThreshold']/$divisor; $limit = $entry['jnxDomCurrentModuleTemperatureHighAlarmThreshold']/$divisor; diff --git a/includes/discovery/sensors/temperature/junose.inc.php b/includes/discovery/sensors/temperature/junose.inc.php index f922af5cea..68015b1429 100644 --- a/includes/discovery/sensors/temperature/junose.inc.php +++ b/includes/discovery/sensors/temperature/junose.inc.php @@ -1,7 +1,7 @@ $entry) { if (is_numeric($entry['juniSystemTempValue']) && is_numeric($index) && $entry['juniSystemTempValue'] > '0') { diff --git a/includes/discovery/sensors/temperature/liebert.inc.php b/includes/discovery/sensors/temperature/liebert.inc.php index cd218eddf3..df42c1a994 100644 --- a/includes/discovery/sensors/temperature/liebert.inc.php +++ b/includes/discovery/sensors/temperature/liebert.inc.php @@ -23,7 +23,7 @@ * @author Neil Lathwood */ -$lib_data = snmpwalk_cache_oid($device, 'lgpEnvTemperatureEntryDegC', array(), 'LIEBERT-GP-ENVIRONMENTAL-MIB'); +$lib_data = snmpwalk_cache_oid($device, 'lgpEnvTemperatureEntryDegC', [], 'LIEBERT-GP-ENVIRONMENTAL-MIB'); foreach ($lib_data as $index => $data) { if (is_numeric($data['lgpEnvTemperatureMeasurementTenthsDegC'])) { diff --git a/includes/discovery/sensors/temperature/mgeups.inc.php b/includes/discovery/sensors/temperature/mgeups.inc.php index 10fd44c9da..ed1ef71028 100644 --- a/includes/discovery/sensors/temperature/mgeups.inc.php +++ b/includes/discovery/sensors/temperature/mgeups.inc.php @@ -4,7 +4,7 @@ echo 'MGE UPS External '; // Environmental monitoring on UPSes etc // FIXME upsmgConfigEnvironmentTable and upsmgEnvironmentSensorTable are used but there are others ... -$mge_env_data = snmpwalk_cache_oid($device, 'upsmgConfigEnvironmentTable', array(), 'MG-SNMP-UPS-MIB'); +$mge_env_data = snmpwalk_cache_oid($device, 'upsmgConfigEnvironmentTable', [], 'MG-SNMP-UPS-MIB'); $mge_env_data = snmpwalk_cache_oid($device, 'upsmgEnvironmentSensorTable', $mge_env_data, 'MG-SNMP-UPS-MIB'); /** diff --git a/includes/discovery/sensors/temperature/netonix.inc.php b/includes/discovery/sensors/temperature/netonix.inc.php index 496430b889..d68e77c01d 100644 --- a/includes/discovery/sensors/temperature/netonix.inc.php +++ b/includes/discovery/sensors/temperature/netonix.inc.php @@ -25,7 +25,7 @@ echo 'Netonix: '; // NETONIX-SWITCH-MIB::tempTable .1.3.6.1.4.1.46242.3 -$oids = snmpwalk_cache_multi_oid($device, 'tempTable', array(), 'NETONIX-SWITCH-MIB', 'netonix'); +$oids = snmpwalk_cache_multi_oid($device, 'tempTable', [], 'NETONIX-SWITCH-MIB', 'netonix'); if (is_array($oids)) { foreach ($oids as $index => $entry) { if (is_numeric($entry['temp']) && is_numeric($index) && $entry['temp'] > '0') { diff --git a/includes/discovery/sensors/temperature/onefs.inc.php b/includes/discovery/sensors/temperature/onefs.inc.php index 84543c393f..92191e99d7 100644 --- a/includes/discovery/sensors/temperature/onefs.inc.php +++ b/includes/discovery/sensors/temperature/onefs.inc.php @@ -24,7 +24,7 @@ */ echo 'OneFS: '; -$oids = snmpwalk_cache_multi_oid($device, 'tempSensorTable', array(), 'ISILON-MIB'); +$oids = snmpwalk_cache_multi_oid($device, 'tempSensorTable', [], 'ISILON-MIB'); foreach ($oids as $index => $entry) { if (is_numeric($entry['tempSensorValue']) && is_numeric($index)) { diff --git a/includes/discovery/sensors/temperature/pbn.inc.php b/includes/discovery/sensors/temperature/pbn.inc.php index 016a9db11c..2a2e5572cd 100644 --- a/includes/discovery/sensors/temperature/pbn.inc.php +++ b/includes/discovery/sensors/temperature/pbn.inc.php @@ -16,7 +16,7 @@ $divisor = 256; foreach ($pre_cache['pbn_oids'] as $index => $entry) { if (is_numeric($entry['temperature']) && ($entry['temperature'] !== '-65535')) { $oid = '.1.3.6.1.4.1.11606.10.9.63.1.7.1.4.'.$index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Temperature'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Temperature'; $limit_low = -256; $warn_limit_low = 10; $limit = 256; diff --git a/includes/discovery/sensors/temperature/pcoweb.inc.php b/includes/discovery/sensors/temperature/pcoweb.inc.php index c978c42b17..e4854da592 100644 --- a/includes/discovery/sensors/temperature/pcoweb.inc.php +++ b/includes/discovery/sensors/temperature/pcoweb.inc.php @@ -2,116 +2,116 @@ echo ' pCOWeb '; -$temperatures = array( - array( +$temperatures = [ + [ 'mib' => 'CAREL-ug40cdz-MIB::roomTemp.0', 'descr' => 'Room Temperature', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.1.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::outdoorTemp.0', 'descr' => 'Ambient Temperature', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.2.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::deliveryTemp.0', 'descr' => 'Delivery Air Temperature', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.3.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::cwTemp.0', 'descr' => 'Chilled Water Temperature', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.4.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::hwTemp.0', 'descr' => 'Hot Water Temperature', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.5.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::cwoTemp.0', 'descr' => 'Chilled Water Outlet Temperature', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.7.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::suctTemp1.0', 'descr' => 'Circuit 1 Suction Temperature', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.10.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::suctTemp2.0', 'descr' => 'Circuit 2 Suction Temperature', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.11.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::evapTemp1.0', 'descr' => 'Circuit 1 Evap. Temperature', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.12.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::evapTemp2.0', 'descr' => 'Circuit 2 Evap. Temperature', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.13.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::ssh1.0', 'descr' => 'Circuit 1 Superheat', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.14.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::ssh2.0', 'descr' => 'Circuit 2 Superheat', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.15.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::coolSetP.0', 'descr' => 'Cooling Set Point', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.20.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::coolDiff.0', 'descr' => 'Cooling Prop. Band', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.21.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::cool2SetP.0', 'descr' => 'Cooling 2nd Set Point', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.22.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::heatSetP.0', 'descr' => 'Heating Set Point', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.23.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::heatDiff.0', 'descr' => 'Heating Prop. Band', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.25.0', 'precision' => '10', - ), - array( + ], + [ 'mib' => 'CAREL-ug40cdz-MIB::heat2SetP.0', 'descr' => 'Heating 2nd Set Point', 'oid' => '.1.3.6.1.4.1.9839.2.1.2.24.0', 'precision' => '10', - ), -); + ], +]; foreach ($temperatures as $temperature) { $current = (snmp_get($device, $temperature['mib'], '-OqvU') / $temperature['precision']); diff --git a/includes/discovery/sensors/temperature/powerconnect.inc.php b/includes/discovery/sensors/temperature/powerconnect.inc.php index 48f433d6d2..38535d26b5 100644 --- a/includes/discovery/sensors/temperature/powerconnect.inc.php +++ b/includes/discovery/sensors/temperature/powerconnect.inc.php @@ -58,7 +58,7 @@ foreach (explode("\n", $temps) as $i => $t) { // F10-S-SERIES-CHASSIS-MIB::chStackUnitModelID.1 = STRING: S25-01-GE-24V echo 'FTOS C-Series '; -$oids = snmpwalk_cache_oid($device, 'chStackUnitTemp', array(), 'F10-S-SERIES-CHASSIS-MIB', 'ftos'); +$oids = snmpwalk_cache_oid($device, 'chStackUnitTemp', [], 'F10-S-SERIES-CHASSIS-MIB', 'ftos'); $oids = snmpwalk_cache_oid($device, 'chStackUnitSysType', $oids, 'F10-S-SERIES-CHASSIS-MIB', 'ftos'); if (is_array($oids)) { diff --git a/includes/discovery/sensors/temperature/procurve.inc.php b/includes/discovery/sensors/temperature/procurve.inc.php index e1ccce4dcd..f08130d6b4 100644 --- a/includes/discovery/sensors/temperature/procurve.inc.php +++ b/includes/discovery/sensors/temperature/procurve.inc.php @@ -1,10 +1,10 @@ $value) { @@ -39,7 +39,7 @@ $divisor_alarm = 1000; foreach ($pre_cache['procurve_hpicfXcvrInfoTable'] as $index => $entry) { if (is_numeric($entry['hpicfXcvrTemp']) && $entry['hpicfXcvrTemp'] != 0) { $oid = '.1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.11.' . $index; - $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array($index,$device['device_id'])); + $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", [$index,$device['device_id']]); $limit_low = $entry['hpicfXcvrTempLoAlarm'] / $divisor_alarm; $warn_limit_low = $entry['hpicfXcvrTempLoWarn'] / $divisor_alarm; $limit = $entry['hpicfXcvrTempHiAlarm'] / $divisor_alarm; diff --git a/includes/discovery/sensors/temperature/qnap.inc.php b/includes/discovery/sensors/temperature/qnap.inc.php index 021756981a..50e58ecd54 100644 --- a/includes/discovery/sensors/temperature/qnap.inc.php +++ b/includes/discovery/sensors/temperature/qnap.inc.php @@ -24,8 +24,8 @@ discover_sensor($valid['sensor'], 'temperature', $device, $system_temperature_oi $disk_temperature_oid = '.1.3.6.1.4.1.24681.1.2.11.1.3'; $disk_serial_oid = '.1.3.6.1.4.1.24681.1.2.11.1.5'; -$hdd_temps = snmpwalk_cache_numerical_oid($device, $disk_temperature_oid, array(), null, null, '-OQUsn'); -$hdd_serials = snmpwalk_cache_numerical_oid($device, $disk_serial_oid, array(), null, null, '-OQUsn'); +$hdd_temps = snmpwalk_cache_numerical_oid($device, $disk_temperature_oid, [], null, null, '-OQUsn'); +$hdd_serials = snmpwalk_cache_numerical_oid($device, $disk_serial_oid, [], null, null, '-OQUsn'); if (is_array($hdd_temps) && !empty($hdd_temps)) { foreach ($hdd_temps as $index => $entry) { diff --git a/includes/discovery/sensors/temperature/quanta.inc.php b/includes/discovery/sensors/temperature/quanta.inc.php index 22e74c5115..ae76e8e725 100644 --- a/includes/discovery/sensors/temperature/quanta.inc.php +++ b/includes/discovery/sensors/temperature/quanta.inc.php @@ -13,7 +13,7 @@ d_echo('Quanta Temperatures'); $sensor_type = 'quanta_temp'; $sensors_id_oid = 'boxServicesTempSensorState'; -$sensors_values = snmpwalk_cache_multi_oid($device, $sensors_id_oid, array(), 'NETGEAR-BOXSERVICES-PRIVATE-MIB'); +$sensors_values = snmpwalk_cache_multi_oid($device, $sensors_id_oid, [], 'NETGEAR-BOXSERVICES-PRIVATE-MIB'); $numeric_oid_base = '.1.3.6.1.4.1.4413.1.1.43.1.8.1.4'; foreach ($sensors_values as $index => $entry) { diff --git a/includes/discovery/sensors/temperature/sentry3.inc.php b/includes/discovery/sensors/temperature/sentry3.inc.php index a75dcc7721..1aa466581b 100644 --- a/includes/discovery/sensors/temperature/sentry3.inc.php +++ b/includes/discovery/sensors/temperature/sentry3.inc.php @@ -1,6 +1,6 @@ */ -$serverscheck_oids = array( +$serverscheck_oids = [ 'sensor1Value.0' => '.1.3.6.1.4.1.17095.3.2.0', 'sensor2Value.0' => '.1.3.6.1.4.1.17095.3.6.0', 'sensor3Value.0' => '.1.3.6.1.4.1.17095.3.10.0', 'sensor4Value.0' => '.1.3.6.1.4.1.17095.3.14.0', 'sensor5Value.0' => '.1.3.6.1.4.1.17095.3.18.0', -); +]; $temp_x = 1; foreach ($pre_cache['serverscheck_control'] as $oid_name => $oid_value) { if (str_contains($oid_name, 'name')) { $tmp_oid = 'sensor' . $temp_x . 'Value.0'; $current = $pre_cache['serverscheck_control'][$tmp_oid]; - if (str_contains($oid_value, array('Temp', 'BR'))) { + if (str_contains($oid_value, ['Temp', 'BR'])) { if (is_numeric($current)) { $index = str_replace('.0', '', $oid_name); $descr = $oid_value; diff --git a/includes/discovery/sensors/temperature/sub10.inc.php b/includes/discovery/sensors/temperature/sub10.inc.php index 68d67d95b5..73a26a8233 100644 --- a/includes/discovery/sensors/temperature/sub10.inc.php +++ b/includes/discovery/sensors/temperature/sub10.inc.php @@ -9,7 +9,7 @@ list($oid, $current) = explode(' ', snmp_get($device, $temp_oid, '-OsqnU', 'SUB1 // Get Alarm Ranges $alarm_oid = 'sub10UnitMgmtAlarmName'; $alarms = snmp_walk($device, $alarm_oid, '-OsqU', 'SUB10SYSTEMS-MIB'); -$indexes = array(); +$indexes = []; foreach (explode("\n", $alarms) as $alarm) { if (preg_match('/^\w+\.(\d) MWU Temperature (.*)$/', $alarm, $matches)) { $indexes[strtolower($matches[2])] = $matches[1]; @@ -18,7 +18,7 @@ foreach (explode("\n", $alarms) as $alarm) { $thresh_oid = 'sub10UnitMgmtAlarmRaiseThresh'; $threshes = snmp_walk($device, $thresh_oid, '-OsqU', 'SUB10SYSTEMS-MIB'); -$thresholds = array(); +$thresholds = []; foreach (explode("\n", $threshes) as $thresh) { preg_match('/^\w+\.(\d) (.*)$/', $thresh, $matches); $thresholds[$matches[1]] = $matches[2]; diff --git a/includes/discovery/sensors/temperature/terra.inc.php b/includes/discovery/sensors/temperature/terra.inc.php index 629be4b6a5..5d3afc8e80 100644 --- a/includes/discovery/sensors/temperature/terra.inc.php +++ b/includes/discovery/sensors/temperature/terra.inc.php @@ -1,10 +1,10 @@ */ -$tpdin_oids = array( - array( +$tpdin_oids = [ + [ 'oid' => '.1.3.6.1.4.1.45621.2.2.13.0', 'index' => 'temperature1', 'descr' => 'External Temp', 'current' => $pre_cache['tpdin_monitor'][0]['temperature1'], - ), - array( + ], + [ 'oid' => '.1.3.6.1.4.1.45621.2.2.14.0', 'index' => 'temperature2', 'descr' => 'Internal Temp', 'current' => $pre_cache['tpdin_monitor'][0]['temperature2'], - ), -); + ], +]; foreach ($tpdin_oids as $data) { if ($data['current'] > 0) { diff --git a/includes/discovery/sensors/temperature/voss.inc.php b/includes/discovery/sensors/temperature/voss.inc.php index f2bb64a963..6de3fae430 100644 --- a/includes/discovery/sensors/temperature/voss.inc.php +++ b/includes/discovery/sensors/temperature/voss.inc.php @@ -13,7 +13,7 @@ * the source code distribution for details. */ -$rcChasFan = snmpwalk_cache_multi_oid($device, 'rcChasFanAmbientTemperature', array(), 'RAPID-CITY'); +$rcChasFan = snmpwalk_cache_multi_oid($device, 'rcChasFanAmbientTemperature', [], 'RAPID-CITY'); if (is_array($rcChasFan)) { foreach (array_keys($rcChasFan) as $index) { $descr = "Fan ".$index." temperature"; diff --git a/includes/discovery/sensors/temperature/websensor.inc.php b/includes/discovery/sensors/temperature/websensor.inc.php index 5a4c8cbbc0..30b4f73d02 100644 --- a/includes/discovery/sensors/temperature/websensor.inc.php +++ b/includes/discovery/sensors/temperature/websensor.inc.php @@ -14,7 +14,7 @@ $regexp = '/ $oids = snmp_walk($device, '.1.3.6.1.4.1.22626.1.5.2', '-OsqnU', ''); if ($oids) { - $out = array(); + $out = []; foreach (explode("\n", $oids) as $line) { preg_match($regexp, $line, $match); if ($match['name']) { diff --git a/includes/discovery/sensors/voltage/adva_fsp150.inc.php b/includes/discovery/sensors/voltage/adva_fsp150.inc.php index d41562277d..961199b64e 100644 --- a/includes/discovery/sensors/voltage/adva_fsp150.inc.php +++ b/includes/discovery/sensors/voltage/adva_fsp150.inc.php @@ -21,32 +21,18 @@ // ****************************************** // Define Sensors - $sensors_adva = array - ( - array( - 'sensor_name' => 'psuOutputVoltage', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.4.1.6'), - array( - 'sensor_name' => 'nemiVoltage', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.7.1.5'), - array( - 'sensor_name' => 'ethernetNTEGE114CardVoltage', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.26.1.5'), - array( - 'sensor_name' => 'ethernetNTEGE114SCardVoltage', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.46.1.5'), - array( - 'sensor_name' => 'ethernetNTEXG210CardVoltage', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.30.1.5'), - array( - 'sensor_name' => 'ethernetGE8SCCCardVoltage', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.41.1.5'), - array( - 'sensor_name' => 'ethernetXG1XCCCardVoltage', - 'sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.31.1.5')); + $sensors_adva = [ + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.4.1.6', 'sensor_name' => 'psuOutputVoltage'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.7.1.5', 'sensor_name' => 'nemiVoltage'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.26.1.5', 'sensor_name' => 'ethernetNTEGE114CardVoltage'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.46.1.5', 'sensor_name' => 'ethernetNTEGE114SCardVoltage'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.30.1.5', 'sensor_name' => 'ethernetNTEXG210CardVoltage'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.41.1.5', 'sensor_name' => 'ethernetGE8SCCCardVoltage'], + ['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.31.1.5', 'sensor_name' => 'ethernetXG1XCCCardVoltage'], + ]; - $multiplier = 1; - $divisor = 1000; + $multiplier = 1; + $divisor = 1000; foreach (array_keys($pre_cache['adva_fsp150']) as $index) { foreach ($sensors_adva as $entry) { diff --git a/includes/discovery/sensors/voltage/comware.inc.php b/includes/discovery/sensors/voltage/comware.inc.php index 2b32ffdd01..8f4c55cfc2 100644 --- a/includes/discovery/sensors/voltage/comware.inc.php +++ b/includes/discovery/sensors/voltage/comware.inc.php @@ -18,10 +18,7 @@ $divisor_alarm = 10000; foreach ($pre_cache['comware_oids'] as $index => $entry) { if (is_numeric($entry['hh3cTransceiverVoltage']) && $entry['hh3cTransceiverVoltage'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { $oid = '.1.3.6.1.4.1.25506.2.70.1.1.1.16.' . $index; - $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array( - $index, - $device['device_id'] - )); + $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", [$index, $device['device_id']]); $limit_low = $entry['hh3cTransceiverVccLoAlarm'] / $divisor_alarm; $warn_limit_low = $entry['hh3cTransceiverVccLoWarn'] / $divisor_alarm; $limit = $entry['hh3cTransceiverVccHiAlarm'] / $divisor_alarm; diff --git a/includes/discovery/sensors/voltage/dell.inc.php b/includes/discovery/sensors/voltage/dell.inc.php index 831c847ea5..a126827856 100644 --- a/includes/discovery/sensors/voltage/dell.inc.php +++ b/includes/discovery/sensors/voltage/dell.inc.php @@ -23,7 +23,7 @@ * @author Neil Lathwood */ -$temp = snmpwalk_cache_multi_oid($device, 'voltageProbeTable', array(), 'MIB-Dell-10892'); +$temp = snmpwalk_cache_multi_oid($device, 'voltageProbeTable', [], 'MIB-Dell-10892'); $cur_oid = '.1.3.6.1.4.1.674.10892.1.600.20.1.6.'; foreach ((array)$temp as $index => $entry) { diff --git a/includes/discovery/sensors/voltage/eaton-ats.inc.php b/includes/discovery/sensors/voltage/eaton-ats.inc.php index 38b115df01..1dc2418657 100644 --- a/includes/discovery/sensors/voltage/eaton-ats.inc.php +++ b/includes/discovery/sensors/voltage/eaton-ats.inc.php @@ -16,7 +16,7 @@ echo 'EATON-ATS'; -$oids = snmpwalk_cache_oid($device, 'ats2InputVoltage', array(), 'EATON-ATS2-MIB'); +$oids = snmpwalk_cache_oid($device, 'ats2InputVoltage', [], 'EATON-ATS2-MIB'); foreach ($oids as $volt_id => $data) { //we need to retrieve the numerical value of oid $source_oid="EATON-ATS2-MIB::ats2InputIndex.".$volt_id; diff --git a/includes/discovery/sensors/voltage/eatonups.inc.php b/includes/discovery/sensors/voltage/eatonups.inc.php index 4239f1089d..cac7aefcc4 100644 --- a/includes/discovery/sensors/voltage/eatonups.inc.php +++ b/includes/discovery/sensors/voltage/eatonups.inc.php @@ -3,7 +3,7 @@ echo 'XUPS-MIB '; // XUPS-MIB::xupsBatVoltage.0 = INTEGER: 51 -$oids = snmpwalk_cache_oid($device, 'xupsBatVoltage', array(), 'XUPS-MIB'); +$oids = snmpwalk_cache_oid($device, 'xupsBatVoltage', [], 'XUPS-MIB'); foreach ($oids as $volt_id => $data) { $volt_oid = ".1.3.6.1.4.1.534.1.2.2.$volt_id"; @@ -17,7 +17,7 @@ foreach ($oids as $volt_id => $data) { } // XUPS-MIB::xupsInputVoltage.1 = INTEGER: 228 -$oids = snmpwalk_cache_oid($device, 'xupsInputVoltage', array(), 'XUPS-MIB'); +$oids = snmpwalk_cache_oid($device, 'xupsInputVoltage', [], 'XUPS-MIB'); foreach ($oids as $volt_id => $data) { $volt_oid = ".1.3.6.1.4.1.534.1.3.4.1.2.$volt_id"; @@ -34,7 +34,7 @@ foreach ($oids as $volt_id => $data) { } // XUPS-MIB::xupsOutputVoltage.1 = INTEGER: 228 -$oids = snmpwalk_cache_oid($device, 'xupsOutputVoltage', array(), 'XUPS-MIB'); +$oids = snmpwalk_cache_oid($device, 'xupsOutputVoltage', [], 'XUPS-MIB'); foreach ($oids as $volt_id => $data) { $volt_oid = ".1.3.6.1.4.1.534.1.4.4.1.2.$volt_id"; @@ -52,7 +52,7 @@ foreach ($oids as $volt_id => $data) { } // XUPS-MIB::xupsBypassNumPhases.0 = INTEGER: 1 -$oids = snmpwalk_cache_oid($device, 'xupsBypassVoltage', array(), 'XUPS-MIB'); +$oids = snmpwalk_cache_oid($device, 'xupsBypassVoltage', [], 'XUPS-MIB'); foreach ($oids as $volt_id => $data) { $volt_oid = ".1.3.6.1.4.1.534.1.5.3.1.2.$volt_id"; diff --git a/includes/discovery/sensors/voltage/ipoman.inc.php b/includes/discovery/sensors/voltage/ipoman.inc.php index 295c20e267..7ced238f13 100644 --- a/includes/discovery/sensors/voltage/ipoman.inc.php +++ b/includes/discovery/sensors/voltage/ipoman.inc.php @@ -2,7 +2,7 @@ echo ' IPOMANII-MIB '; -$oids = array(); +$oids = []; d_echo('inletConfigVoltageHigh '); $oids = snmpwalk_cache_multi_oid($device, 'inletConfigVoltageHigh', $oids, 'IPOMANII-MIB'); diff --git a/includes/discovery/sensors/voltage/netonix.inc.php b/includes/discovery/sensors/voltage/netonix.inc.php index ec10c99e9c..606e95d4ea 100644 --- a/includes/discovery/sensors/voltage/netonix.inc.php +++ b/includes/discovery/sensors/voltage/netonix.inc.php @@ -25,7 +25,7 @@ echo 'Netonix: '; // NETONIX-SWITCH-MIB::voltageTable .1.3.6.1.4.1.46242.4 -$oids = snmpwalk_cache_multi_oid($device, 'voltageTable', array(), 'NETONIX-SWITCH-MIB', 'netonix'); +$oids = snmpwalk_cache_multi_oid($device, 'voltageTable', [], 'NETONIX-SWITCH-MIB', 'netonix'); if (is_array($oids)) { foreach ($oids as $index => $entry) { if (is_numeric($entry['voltage']) && is_numeric($index) && $entry['voltage'] > '0') { diff --git a/includes/discovery/sensors/voltage/onefs.inc.php b/includes/discovery/sensors/voltage/onefs.inc.php index 15238e5f21..db4be519cc 100644 --- a/includes/discovery/sensors/voltage/onefs.inc.php +++ b/includes/discovery/sensors/voltage/onefs.inc.php @@ -24,7 +24,7 @@ */ echo 'OneFS: '; -$oids = snmpwalk_cache_multi_oid($device, 'powerSensorTable', array(), 'ISILON-MIB'); +$oids = snmpwalk_cache_multi_oid($device, 'powerSensorTable', [], 'ISILON-MIB'); foreach ($oids as $index => $entry) { if (is_numeric($entry['powerSensorValue']) && is_numeric($index)) { diff --git a/includes/discovery/sensors/voltage/pbn.inc.php b/includes/discovery/sensors/voltage/pbn.inc.php index ac0ed259db..ab33109556 100644 --- a/includes/discovery/sensors/voltage/pbn.inc.php +++ b/includes/discovery/sensors/voltage/pbn.inc.php @@ -16,7 +16,7 @@ $divisor = 10000; foreach ($pre_cache['pbn_oids'] as $index => $entry) { if (is_numeric($entry['voltage']) && ($entry['voltage'] !== '-65535')) { $oid = '.1.3.6.1.4.1.11606.10.9.63.1.7.1.5.'.$index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Voltage'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', [$index, $device['device_id']]) . ' Voltage'; $limit_low = 30000/$divisor; $warn_limit_low = 32100/$divisor; $limit = 35000/$divisor; diff --git a/includes/discovery/sensors/voltage/procurve.inc.php b/includes/discovery/sensors/voltage/procurve.inc.php index b7e47628e7..de132dbfc4 100644 --- a/includes/discovery/sensors/voltage/procurve.inc.php +++ b/includes/discovery/sensors/voltage/procurve.inc.php @@ -7,10 +7,7 @@ $divisor_alarm = 10000; foreach ($pre_cache['procurve_hpicfXcvrInfoTable'] as $index => $entry) { if (is_numeric($entry['hpicfXcvrVoltage']) && $entry['hpicfXcvrVoltage'] != 0) { $oid = '.1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.12.' . $index; - $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array( - $index, - $device['device_id'] - )); + $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", [$index, $device['device_id']]); $limit_low = $entry['hpicfXcvrVccLoAlarm'] / $divisor_alarm; $warn_limit_low = $entry['hpicfXcvrVccLoWarn'] / $divisor_alarm; $limit = $entry['hpicfXcvrVccHiAlarm'] / $divisor_alarm; diff --git a/includes/discovery/sensors/voltage/sinetica.inc.php b/includes/discovery/sensors/voltage/sinetica.inc.php index ecffb35f55..33b9e0a04e 100644 --- a/includes/discovery/sensors/voltage/sinetica.inc.php +++ b/includes/discovery/sensors/voltage/sinetica.inc.php @@ -36,7 +36,7 @@ if (!empty($battery_current) || $battery_current == 0) { discover_sensor($valid['sensor'], 'voltage', $device, $battery_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); } -$oids = snmpwalk_cache_oid_num($device, '.1.3.6.1.4.1.13891.101.3.3.1.3', array()); +$oids = snmpwalk_cache_oid_num($device, '.1.3.6.1.4.1.13891.101.3.3.1.3', []); foreach ($oids as $oid => $data) { $current_id = substr($oid, strrpos($oid, '.') + 1); @@ -53,7 +53,7 @@ foreach ($oids as $oid => $data) { discover_sensor($valid['sensor'], 'voltage', $device, $current_oid, $index, $type, $descr, 1, 1, null, null, null, null, $current); } -$oids = snmpwalk_cache_oid_num($device, '.1.3.6.1.4.1.13891.101.4.4.1.2', array()); +$oids = snmpwalk_cache_oid_num($device, '.1.3.6.1.4.1.13891.101.4.4.1.2', []); foreach ($oids as $oid => $data) { $current_id = substr($oid, strrpos($oid, '.') + 1); diff --git a/includes/discovery/sensors/voltage/terra.inc.php b/includes/discovery/sensors/voltage/terra.inc.php index 4704ef0897..60da215dd3 100644 --- a/includes/discovery/sensors/voltage/terra.inc.php +++ b/includes/discovery/sensors/voltage/terra.inc.php @@ -1,10 +1,10 @@ */ -$tpdin_oids = array( - array( +$tpdin_oids = [ + [ 'oid' => '.1.3.6.1.4.1.45621.2.2.5.0', 'index' => 'voltage1', 'descr' => 'Voltage 1', 'current' => $pre_cache['tpdin_monitor'][0]['voltage1'], - ), - array( + ], + [ 'oid' => '.1.3.6.1.4.1.45621.2.2.6.0', 'index' => 'voltage2', 'descr' => 'Voltage 2', 'current' => $pre_cache['tpdin_monitor'][0]['voltage2'], - ), - array( + ], + [ 'oid' => '.1.3.6.1.4.1.45621.2.2.7.0', 'index' => 'voltage3', 'descr' => 'Voltage 3', 'current' => $pre_cache['tpdin_monitor'][0]['voltage3'], - ), - array( + ], + [ 'oid' => '.1.3.6.1.4.1.45621.2.2.8.0', 'index' => 'voltage4', 'descr' => 'Voltage 4', 'current' => $pre_cache['tpdin_monitor'][0]['voltage4'], - ), -); + ], +]; foreach ($tpdin_oids as $data) { if ($data['current'] > 0) { diff --git a/tests/data/netagent2.json b/tests/data/netagent2.json index fffd583359..4aa2045a4b 100644 --- a/tests/data/netagent2.json +++ b/tests/data/netagent2.json @@ -1533,6 +1533,13 @@ "state_value": 4, "state_generic_value": 0 }, + { + "state_name": "netagent2upsstate", + "state_descr": "Sleeping", + "state_draw_graph": 0, + "state_value": 5, + "state_generic_value": 1 + }, { "state_name": "netagent2upsstate", "state_descr": "OnBypass",