diff --git a/includes/definitions/ict-pdu.yaml b/includes/definitions/ict-pdu.yaml new file mode 100644 index 0000000000..1d2228499e --- /dev/null +++ b/includes/definitions/ict-pdu.yaml @@ -0,0 +1,13 @@ +os: ict-pdu +text: 'ICT Distribution Series' +type: power +icon: ict +nobulk: 1 +mib_dir: + - ict +over: + - { graph: device_current, text: 'Current' } + - { graph: device_voltage, text: 'Voltage' } +discovery: + - sysObjectId: + - .1.3.6.1.4.1.39145.10 diff --git a/includes/discovery/sensors/current/ict-pdu.inc.php b/includes/discovery/sensors/current/ict-pdu.inc.php new file mode 100644 index 0000000000..129169820b --- /dev/null +++ b/includes/discovery/sensors/current/ict-pdu.inc.php @@ -0,0 +1,56 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2017 Lorenzo Zafra + * @author Lorenzo Zafra + */ + +// Output Current +$oids = snmpwalk_cache_oid($device, 'outputEntry', array(), 'ICT-MIB'); + +foreach ($oids as $index => $entry) { + $output_number = (int)$entry['outputNumber'] + 1; + + $descr = 'Output Current #' . $output_number; + if ($entry['outputName'] && $entry['outputName'] != '00') { + $descr .= ' ' . $entry['outputName']; + } + + $divisor = 1; + $oid = '.1.3.6.1.4.1.39145.10.8.1.3.'.$index; + $type = 'ict-pdu'; + $current = (float)$entry['outputCurrent'] / $divisor; + + discover_sensor($valid['sensor'], 'current', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); +} + +// System Current +$systemCurrent = trim(snmp_get($device, 'systemCurrent.0', '-Oqv', 'ICT-MIB'), '" '); +if (!empty($systemCurrent)) { + $divisor = 1; + $index = '7.0'; + $descr = 'System Current'; + $type = 'ict-pdu'; + $oid = '.1.3.6.1.4.1.39145.10.7.0'; + $current = $systemCurrent / $divisor; + + discover_sensor($valid['sensor'], 'current', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); +} diff --git a/includes/discovery/sensors/state/ict-pdu.inc.php b/includes/discovery/sensors/state/ict-pdu.inc.php new file mode 100644 index 0000000000..436bb054bf --- /dev/null +++ b/includes/discovery/sensors/state/ict-pdu.inc.php @@ -0,0 +1,65 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2017 Lorenzo Zafra + * @author Lorenzo Zafra + */ + +$oids = snmpwalk_cache_oid($device, 'outputEntry', array(), 'ICT-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'); + } + } + + foreach ($oids as $index => $entry) { + $fuse_state_oid = '.1.3.6.1.4.1.39145.10.8.1.4.' . $index; + $fuse_number = (int)$index + 1; + $descr = "Fuse #" . $fuse_number; + + $current_value_string = $entry[$state_name]; + if ($current_value_string == 'OK') { + $current_value = 1; + } else if ($current_value_string == 'OPEN') { + $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); + + create_sensor_to_state_index($device, $state_name, $index); + } +} diff --git a/includes/discovery/sensors/voltage/ict-pdu.inc.php b/includes/discovery/sensors/voltage/ict-pdu.inc.php new file mode 100644 index 0000000000..7f783e6e94 --- /dev/null +++ b/includes/discovery/sensors/voltage/ict-pdu.inc.php @@ -0,0 +1,38 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2017 Lorenzo Zafra + * @author Lorenzo Zafra + */ + +// System Voltage +$systemVoltage = trim(snmp_get($device, 'systemVoltage.0', '-Oqv', 'ICT-MIB'), '" '); + +if (!empty($systemVoltage)) { + $divisor = 1; + $oid = '.1.3.6.1.4.1.39145.10.6.0'; + $index = 0; + $descr = 'System Voltage'; + $type = 'ict-pdu'; + $current_value = $systemVoltage / $divisor; + + discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current_value); +} diff --git a/includes/polling/os/ict-pdu.inc.php b/includes/polling/os/ict-pdu.inc.php new file mode 100644 index 0000000000..a4a5e79829 --- /dev/null +++ b/includes/polling/os/ict-pdu.inc.php @@ -0,0 +1,7 @@ +checkOS('applicationsware'); } - + public function testArdmoreencoder() { $this->checkOS('ardmore-encoder'); @@ -904,6 +904,12 @@ class DiscoveryTest extends \PHPUnit_Framework_TestCase $this->checkOS('ibmtl'); } + + public function testIctpdu() + { + $this->checkOS('ict-pdu'); + } + public function testIes() { $this->checkOS('ies'); diff --git a/tests/snmpsim/ict-pdu.snmprec b/tests/snmpsim/ict-pdu.snmprec new file mode 100644 index 0000000000..986f7f6cf7 --- /dev/null +++ b/tests/snmpsim/ict-pdu.snmprec @@ -0,0 +1,2 @@ +1.3.6.1.2.1.1.1.0|4|ICT Distribution Panel +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.39145.10