Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newdevice: Added more detection for IgniteNet FusionSwitch #7384

Merged
merged 4 commits into from Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion html/includes/graphs/sensor/current.inc.php
Expand Up @@ -6,7 +6,7 @@

$rrd_options .= " COMMENT:' Min Last Max\\n'";

$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 18), 0, 18);
$sensor['sensor_descr_fixed'] = rrdtool_escape($sensor['sensor_descr'], 21);

$rrd_options .= " DEF:sensor=$rrd_filename:sensor:AVERAGE";
$rrd_options .= " LINE1.5:sensor#cc0000:'".$sensor['sensor_descr_fixed']."'";
Expand Down
115 changes: 115 additions & 0 deletions includes/definitions/discovery/fusion.yaml
@@ -0,0 +1,115 @@
mib: ES4552BH2-MIB
modules:
sensors:
pre-cache:
data:
- oid:
- portTransceiverThresholdInfoTable
- portTable
voltage:
data:
-
oid: portOpticalMonitoringInfoTable
value: portOpticalMonitoringInfoVcc
num_oid: .1.3.6.1.4.1.259.6.10.120.1.2.11.1.3.
descr: '{{ $portName }}'
index: 'portOpticalMonitoringInfoVcc.{{ $index }}'
low_warn_limit: portTransceiverThresholdInfoVccLowWarn
low_limit: portTransceiverThresholdInfoVccLowAlarm
warn_limit: portTransceiverThresholdInfoVccHighWarn
high_limit: portTransceiverThresholdInfoVccHighAlarm
current:
data:
-
oid: portOpticalMonitoringInfoTable
value: portOpticalMonitoringInfoTxBiasCurrent
num_oid: .1.3.6.1.4.1.259.6.10.120.1.2.11.1.4.
descr: '{{ $portName }} - Tx'
index: 'portOpticalMonitoringInfoTxBiasCurrent.{{ $index }}'
low_warn_limit: portTransceiverThresholdInfoTxBiasCurrentLowWarn
low_limit: portTransceiverThresholdInfoTxBiasCurrentLowAlarm
warn_limit: portTransceiverThresholdInfoTxBiasCurrentHighWarn
high_limit: portTransceiverThresholdInfoTxBiasCurrentHighAlarm
divisor: 1000
dbm:
data:
-
oid: portOpticalMonitoringInfoTable
value: portOpticalMonitoringInfoTxPower
num_oid: .1.3.6.1.4.1.259.6.10.120.1.2.11.1.5.
descr: '{{ $portName }} - Tx'
index: 'portOpticalMonitoringInfoTxPower.{{ $index }}'
low_warn_limit: portTransceiverThresholdInfoTxPowerLowWarn
low_limit: portTransceiverThresholdInfoTxPowerLowAlarm
warn_limit: portTransceiverThresholdInfoTxPowerHighWarn
high_limit: portTransceiverThresholdInfoTxPowerHighAlarm
-
oid: portOpticalMonitoringInfoTable
value: portOpticalMonitoringInfoRxPower
num_oid: .1.3.6.1.4.1.259.6.10.120.1.2.11.1.6.
descr: '{{ $portName }} - Rx'
index: 'portOpticalMonitoringInfoRxPower.{{ $index }}'
low_warn_limit: portTransceiverThresholdInfoRxPowerLowWarn
low_limit: portTransceiverThresholdInfoRxPowerLowAlarm
warn_limit: portTransceiverThresholdInfoRxPowerHighWarn
high_limit: portTransceiverThresholdInfoRxPowerHighAlarm
temperature:
data:
-
oid: portOpticalMonitoringInfoTable
value: portOpticalMonitoringInfoTemperature
num_oid: .1.3.6.1.4.1.259.6.10.120.1.2.11.1.2.
descr: '{{ $portName }}'
index: 'portOpticalMonitoringInfoTemperature.{{ $index }}'
low_warn_limit: portTransceiverThresholdInfoTemperatureLowWarn
low_limit: portTransceiverThresholdInfoTemperatureLowAlarm
warn_limit: portTransceiverThresholdInfoTemperatureHighWarn
high_limit: portTransceiverThresholdInfoTemperatureHighAlarm
-
oid: switchThermalTempTable
value: switchThermalTempValue
num_oid: .1.3.6.1.4.1.259.6.10.120.1.1.11.1.3.
descr: 'Thermal {{ $index }}'
index: 'switchThermalTempValue.{{ $index }}'
fanspeed:
data:
-
oid: switchFanTable
value: switchFanOperSpeed
num_oid: .1.3.6.1.4.1.259.6.10.120.1.1.9.1.6.
descr: 'Fan {{ $index }}'
index: 'switchFanOperSpeed.{{ $index }}'
state:
data:
-
oid: switchFanTable
value: switchFanStatus
num_oid: .1.3.6.1.4.1.259.6.10.120.1.1.9.1.3.
descr: 'Fan {{ $index }}'
index: 'switchFanStatus.{{ $index }}'
state_name: switchFanStatus
states:
- { value: 1, generic: 0, graph: 1, descr: ok }
- { value: 2, generic: 2, graph: 1, descr: failure }
-
oid: switchInfoTable
value: swPowerStatus
num_oid: .1.3.6.1.4.1.259.6.10.120.1.1.3.1.8.
descr: Power state
index: 'swPowerStatus.{{ $index }}'
state_name: swPowerStatus
states:
- { value: 1, generic: 1, graph: 1, descr: internalPower }
- { value: 2, generic: 0, graph: 1, descr: redundantPower }
- { value: 3, generic: 0, graph: 1, descr: internalAndRedundantPower }
-
oid: switchInfoTable
value: swRoleInSystem
num_oid: .1.3.6.1.4.1.259.6.10.120.1.1.3.1.9.
descr: Switch role
index: 'swRoleInSystem.{{ $index }}'
state_name: swRoleInSystem
states:
- { value: 1, generic: 0, graph: 1, descr: master }
- { value: 2, generic: 0, graph: 1, descr: backupMaster }
- { value: 3, generic: 0, graph: 1, descr: slave }
11 changes: 9 additions & 2 deletions includes/discovery/functions.inc.php
Expand Up @@ -1097,8 +1097,15 @@ function discovery_process(&$valid, $device, $sensor_type, $pre_cache)
foreach ($raw_data as $index => $snmp_data) {
// get the value for this sensor, check 'value' and 'oid', if state string, translate to a number
$data_name = isset($data['value']) ? $data['value'] : $data['oid']; // fallback to oid if value is not set
if (is_numeric($snmp_data[$data_name])) {
$value = $snmp_data[$data_name];

$tmp_value = $snmp_data[$data_name];
preg_match('/[\d\.\-]+/', $tmp_value, $temp_response);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing something returns a string containing a value and text?

I'd prefer the is_numeric() test first so we can avoid the preg_match for most things.

Copy link
Member

@murrant murrant Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, perhaps this would be a better regex: -?\d*\.?\d+

It only allows a single - at the start and a single decimal point, possibly at the start.

The current regex can match - or . and if those come before the number, they will be returned.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, pushing an update now.

if (!empty($temp_response[0])) {
$tmp_value = $temp_response[0];
}

if (is_numeric($tmp_value)) {
$value = $tmp_value;
} elseif ($sensor_type === 'state') {
// translate string states to values (poller does this as well)
$states = array_column($data['states'], 'value', 'descr');
Expand Down
31 changes: 31 additions & 0 deletions includes/polling/os/fusion.inc.php
@@ -0,0 +1,31 @@
<?php
/**
* fusion.inc.php
*
* LibreNMS OS poller module for IgniteNet FusionSwitch
*
* 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 Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2017 Neil Lathwood
* @author Neil Lathwood <gh+n@laf.io>
*/

$fusion_tmp = snmp_get_multi_oid($device, 'swSerialNumber.1 swOpCodeVer.1 swModelNumber.1', '-OUQs', 'ES4552BH2-MIB');
$serial = $fusion_tmp['swSerialNumber.1'];
$hardware = $fusion_tmp['swModelNumber.1'];
$version = $fusion_tmp['swOpCodeVer.1'];

unset($fusion_tmp);