From c99c74bd9554ad24654cd690b5b337ed5da8f47c Mon Sep 17 00:00:00 2001 From: Peter TKATCHENKO Date: Thu, 12 May 2016 17:36:08 +0200 Subject: [PATCH 1/4] Improved support for Equallogic storage arrays and DELL servers --- includes/definitions.inc.php | 2 + .../discovery/sensors/states/dell.inc.php | 83 +++++++++- .../sensors/states/equallogic.inc.php | 148 +++++++++++++++--- .../discovery/storage/eql-storage.inc.php | 37 +++++ includes/polling/storage/eql-storage.inc.php | 59 +++++++ 5 files changed, 300 insertions(+), 29 deletions(-) create mode 100644 includes/discovery/storage/eql-storage.inc.php create mode 100644 includes/polling/storage/eql-storage.inc.php diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index fe53e37ed2..a60ae8df0b 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -922,6 +922,8 @@ $config['os'][$os]['text'] = 'Dell EqualLogic'; $config['os'][$os]['icon'] = 'dell'; $config['os'][$os]['over'][0]['graph'] = 'device_bits'; $config['os'][$os]['over'][0]['text'] = 'Device Traffic'; +$config['os'][$os]['over'][1]['graph'] = 'device_storage'; +$config['os'][$os]['over'][1]['text'] = 'Storage Usage'; $os = 'drac'; $config['os'][$os]['text'] = 'Dell DRAC'; diff --git a/includes/discovery/sensors/states/dell.inc.php b/includes/discovery/sensors/states/dell.inc.php index b8dca50df3..73caec3cef 100644 --- a/includes/discovery/sensors/states/dell.inc.php +++ b/includes/discovery/sensors/states/dell.inc.php @@ -4,6 +4,7 @@ * LibreNMS * * Copyright (c) 2014 Neil Lathwood + * Modyfied by Peter TKATCHENKO https://github.com/Peter2121/ 2016 * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -12,19 +13,85 @@ * the source code distribution for details. */ -if ($device['os'] == 'linux') { - $oids = snmp_walk($device, 'virtualDiskNumber', '-Oesqn', 'StorageManagement-MIB'); - $main_oid = '.1.3.6.1.4.1.674.10893.1.20.140.1.1.'; + $oids = snmp_walk($device, 'virtualDiskDeviceName', '-Oesqn', 'StorageManagement-MIB'); + $name_oid = '.1.3.6.1.4.1.674.10893.1.20.140.1.1.3'; + $main_oid = '.1.3.6.1.4.1.674.10893.1.20.140.1.1.4.'; d_echo($oids."\n"); $oids = trim($oids); if ($oids) { echo 'Dell '; + + $state_name = 'dellVirtualDiskState'; + $state_index_id = create_state_index($state_name); +/* +-- 1.3.6.1.4.1.674.10893.1.20.140.1.1.4 +virtualDiskState +INTEGER + { + unknown(0), + ready(1), + failed(2), + online(3), + offline(4), + degraded(6), + verifying(7), + resynching(15), + regenerating(16), + failedRedundancy(18), + rebuilding(24), + formatting(26), + reconstructing(32), + initializing(35), + backgroundInit(36), + permanentlyDegraded(52) + } +*/ + if ($state_index_id) { + $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) + ); + + 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 (explode("\n", $oids) as $data) { - list($oid,) = explode(' ', $data, 2); - $state_oid = '4.1'; - $state_current = snmp_get($device, $main_oid.$state_oid, '-Oevq'); - discover_sensor($valid['sensor'], 'state', $device, $main_oid.$state_oid, "virtualDiskState.$state_oid", 'dell', 'Raid State', '1', '1', null, null, null, null, $state_current); + list($oid,$name) = explode(' ', $data, 2); + $name = trim($name,"\""); + if($oid==$name_oid) continue; // Something goes wrong, we should have $name_oid.$num_index in $oid + $split_oid = explode('.', $oid); + $num_index = $split_oid[(count($split_oid) - 1)]; + $index = (int)$num_index+0; + $oid = $main_oid.$num_index; + $low_limit = 0.5; + $high_limit = 1.5; + + $state_current = snmp_get($device, $oid, '-Oevq'); + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $name, '1', '1', $low_limit, $low_limit, $high_limit, $high_limit, $state_current,'snmp',$index); + create_sensor_to_state_index($device, $state_name, $index); } } -} diff --git a/includes/discovery/sensors/states/equallogic.inc.php b/includes/discovery/sensors/states/equallogic.inc.php index 2aec66a9cb..cc249d7141 100644 --- a/includes/discovery/sensors/states/equallogic.inc.php +++ b/includes/discovery/sensors/states/equallogic.inc.php @@ -1,40 +1,146 @@ $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 (explode("\n", $oids) as $data) { + $data = trim($data); + if (!empty($data)) { + list($oid,$current) = explode(' = ', $data, 2); + $split_oid = explode('.', $oid); + $num_index = $split_oid[(count($split_oid) - 1)]; + $index = (int)$num_index+0; + $low_limit = 0.5; + $high_limit = 2.5; + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, $low_limit, $low_limit, $high_limit, $high_limit, $current, 'snmp', $index); + create_sensor_to_state_index($device, $state_name, $index); + } + } + } + + $oids1 = snmp_walk($device, 'eqlMemberHealthDetailsPowerSupplyName', '-OQn', 'EQLMEMBER-MIB', $config['install_dir'].'/mibs/equallogic'); + + d_echo('PowerSupplyName oids:'); + d_echo($oids1."\n"); /* .1.3.6.1.4.1.12740.2.1.8.1.2.1.329840783.1 = Power Cooling Module 0 .1.3.6.1.4.1.12740.2.1.8.1.2.1.329840783.2 = Power Cooling Module 1 **/ - d_echo($oids."\n"); - if (!empty($oids)) { - echo 'EQLCONTROLLER-MIB '; - foreach (explode("\n", $oids) as $data) { + $base_oid = '.1.3.6.1.4.1.12740.2.1.8.1.3.1.'; // eqlMemberHealthDetailsPowerSupplyCurrentState + + if (!empty($oids1)) { +/* +eqlMemberHealthDetailsPowerSupplyCurrentState + INTEGER { + on-and-operating (1), + no-ac-power (2), + 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'); + } + } + + foreach (explode("\n", $oids1) as $data) { $data = trim($data); if (!empty($data)) { list($oid,$descr) = explode(' = ', $data, 2); $split_oid = explode('.', $oid); $num_index = $split_oid[(count($split_oid) - 1)]; - $index = $num_index; - $part_oid = $split_oid[(count($split_oid) - 2)]; - $num_index = $part_oid.'.'.$num_index; - $base_oid = '.1.3.6.1.4.1.12740.2.1.8.1.3.1.'; + $index = (int)$num_index+0; + $member_id = $split_oid[(count($split_oid) - 2)]; + $num_index = $member_id.'.'.$num_index; $oid = $base_oid.$num_index; - $extra = snmp_get_multi($device, "eqlMemberHealthDetailsPowerSupplyCurrentState.3.329840783.$index", '-OQUse', 'EQLMEMBER-MIB', $config['install_dir'].'/mibs/equallogic'); - $keys = array_keys($extra); - $temperature = $extra[$keys[0]]['eqlMemberHealthDetailsPowerSupplyValue']; - $low_limit = $extra[$keys[0]]['eqlMemberHealthDetailsPowerSupplyLowCriticalThreshold']; - $low_warn = $extra[$keys[0]]['eqlMemberHealthDetailsPowerSupplyLowWarningThreshold']; - $high_limit = $extra[$keys[0]]['eqlMemberHealthDetailsPowerSupplyHighCriticalThreshold']; - $high_warn = $extra[$keys[0]]['eqlMemberHealthDetailsPowerSupplyHighWarningThreshold']; - $index = (100 + $index); - - if ($extra[$keys[0]]['eqlMemberHealthDetailsPowerSupplyCurrentState'] != 'unknown') { - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, 'snmp', $descr, 1, 1, $low_limit, $low_warn, $high_limit, $high_warn, $temperature); + $extra = snmp_get_multi($device, $oid, '-OQne', 'EQLMEMBER-MIB', $config['install_dir'].'/mibs/equallogic'); + d_echo($extra); + if(!empty($extra)) { + list($foid,$pstatus) = explode(' = ',$extra,2); + $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); } }//end if }//end foreach - }//end if + }//end if empty oids }//end if diff --git a/includes/discovery/storage/eql-storage.inc.php b/includes/discovery/storage/eql-storage.inc.php new file mode 100644 index 0000000000..cbd0e957b0 --- /dev/null +++ b/includes/discovery/storage/eql-storage.inc.php @@ -0,0 +1,37 @@ + $storage) { + $fstype = $storage['eqliscsiVolumeAdminStatus']; + $descr = $storage['eqliscsiVolumeName']; + $units = 1; + $size = $storage['eqliscsiVolumeSize'] * $units; + $used = $storage['eqliscsiVolumeStatusAllocatedSpace'] * $units; + if (is_int($index)) { + discover_storage($valid_storage, $device, $index, $fstype, 'eql-storage', $descr, $size, $units, $used); + } else { + // Trying to search the last '.' and take something after it as index + $arrindex = explode(".", $index); + $newindex = (int)(end($arrindex))+0; + if (is_int($newindex)) { + discover_storage($valid_storage, $device, $newindex, $fstype, 'eql-storage', $descr, $size, $units, $used); + } + } + unset($deny, $fstype, $descr, $size, $used, $units, $storage_rrd, $old_storage_rrd, $hrstorage_array); + } +} diff --git a/includes/polling/storage/eql-storage.inc.php b/includes/polling/storage/eql-storage.inc.php new file mode 100644 index 0000000000..77d05e8b55 --- /dev/null +++ b/includes/polling/storage/eql-storage.inc.php @@ -0,0 +1,59 @@ + $ventry) { + if (!array_key_exists('eqliscsiVolumeName', $ventry)) continue; + if (is_int($index)) $iind = $index; + else { + $arrindex = explode(".", $index); + $iind = (int)(end($arrindex))+0; + } + if (is_int($iind)) $storage_cache10[$iind] = $ventry; +} +d_echo($storage_cache10); + +foreach ($storage_cache2['eql-storage'] as $index => $vsentry) { + if (!array_key_exists('eqliscsiVolumeStatusAvailable', $vsentry)) continue; + if (is_int($index)) $iind = $index; + else { + $arrindex = explode(".", $index); + $iind = (int)(end($arrindex))+0; + } + if (is_int($iind)) $storage_cache20[$iind] = $vsentry; +} +d_echo($storage_cache20); + +$entry1 = $storage_cache10[$storage[storage_index]]; +$entry2 = $storage_cache20[$storage[storage_index]]; + +$storage['units'] = 1; +$storage['size'] = ($entry1['eqliscsiVolumeSize'] * $storage['units']); +$storage['used'] = ($entry2['eqliscsiVolumeStatusAllocatedSpace'] * $storage['units']); +$storage['free'] = ($storage['size'] - $storage['used']); From 7f4a05f30a524df9545b2d97dfbb076745ff849e Mon Sep 17 00:00:00 2001 From: Peter TKATCHENKO Date: Wed, 18 May 2016 14:55:35 +0200 Subject: [PATCH 2/4] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 63f0456d10..3fe57e5685 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -102,6 +102,7 @@ LibreNMS contributors: - Jussi Sorjonen (mieleton) - Jens Langhammer (BeryJu) - Robert Verspuy (exarv) +- Peter Tkatchenko (Peter2121) [1]: http://observium.org/ "Observium web site" Observium was written by: From 38d28ec9b1985dc1516e6c5e9f18dac52291bc31 Mon Sep 17 00:00:00 2001 From: Peter TKATCHENKO Date: Wed, 18 May 2016 15:14:03 +0200 Subject: [PATCH 3/4] Reformatting if-else --- includes/discovery/storage/eql-storage.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/discovery/storage/eql-storage.inc.php b/includes/discovery/storage/eql-storage.inc.php index cbd0e957b0..2951fcd5af 100644 --- a/includes/discovery/storage/eql-storage.inc.php +++ b/includes/discovery/storage/eql-storage.inc.php @@ -24,7 +24,8 @@ if (is_array($eql_storage)) { $used = $storage['eqliscsiVolumeStatusAllocatedSpace'] * $units; if (is_int($index)) { discover_storage($valid_storage, $device, $index, $fstype, 'eql-storage', $descr, $size, $units, $used); - } else { + } + else { // Trying to search the last '.' and take something after it as index $arrindex = explode(".", $index); $newindex = (int)(end($arrindex))+0; From 4920c39dfd65181524caedc108fdb165cbb0008a Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Thu, 19 May 2016 14:20:42 -0500 Subject: [PATCH 4/4] List service plugins alphabetically. --- html/pages/addsrv.inc.php | 12 ++++-------- html/pages/device/edit/services.inc.php | 11 ++++------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/html/pages/addsrv.inc.php b/html/pages/addsrv.inc.php index e75ff24fd9..7a360bfb7d 100644 --- a/html/pages/addsrv.inc.php +++ b/html/pages/addsrv.inc.php @@ -16,15 +16,11 @@ else { } } - if ($handle = opendir($config['nagios_plugins'])) { - while (false !== ($file = readdir($handle))) { - if ($file != '.' && $file != '..' && !strstr($file, '.') && strstr($file, 'check_')) { - list(,$check_name) = explode('_',$file,2); - $servicesform .= ""; - } + foreach (scandir($config['nagios_plugins']) as $file) { + if (substr($file, 0, 6) === 'check_') { + $check_name = substr($file, 6); + $servicesform .= ""; } - - closedir($handle); } foreach (dbFetchRows('SELECT * FROM `devices` ORDER BY `hostname`') as $device) { diff --git a/html/pages/device/edit/services.inc.php b/html/pages/device/edit/services.inc.php index e480f88edb..8a7f5ac4ee 100644 --- a/html/pages/device/edit/services.inc.php +++ b/html/pages/device/edit/services.inc.php @@ -14,14 +14,11 @@ if (is_admin() === true || is_read() === true) { } // Build the types list. - if ($handle = opendir($config['nagios_plugins'])) { - while (false !== ($file = readdir($handle))) { - if ($file != '.' && $file != '..' && !strstr($file, '.') && strstr($file, 'check_')) { - list(,$check_name) = explode('_',$file,2); - $servicesform .= ""; - } + foreach (scandir($config['nagios_plugins']) as $file) { + if (substr($file, 0, 6) === 'check_') { + $check_name = substr($file, 6); + $servicesform .= ""; } - closedir($handle); } $dev = device_by_id_cache($device['device_id']);