split Eltex-mes OS to mes21xx / mes23xx. + few improvements (#13544)

* split Eltex OS to 21xx and 23xx

* styleci & typo

* yaml cleanup

* removed MIBs from first release

* tidy up yaml

* test data
This commit is contained in:
Peca Nesovanovic
2021-11-24 21:34:48 +01:00
committed by GitHub
parent 61eae8fb6a
commit 21edc086ca
45 changed files with 27106 additions and 12171 deletions

View File

@@ -1,6 +1,6 @@
<?php
/*
* LibreNMS discovery module for Eltex-MES Battery charge
* LibreNMS discovery module for Eltex-MES23xx Battery charge
*
* 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
@@ -21,21 +21,18 @@
* @author Peca Nesovanovic <peca.nesovanovic@sattrakt.com>
*/
$oids = snmp_walk($device, '1.3.6.1.4.1.35265.1.23.11.1.1.3', '-Osqn', '');
$oids = snmp_walk($device, 'eltEnvMonBatteryStatusCharge', '-Osqn', 'ELTEX-MES-HWENVIROMENT-MIB');
$oids = trim($oids);
if ($oids) {
echo "Eltex-MES charge:\n";
d_echo('Eltex-MES charge');
foreach (explode("\n", $oids) as $data) {
if ($data) {
print_r($data);
echo "\n";
$oid = trim(explode(' ', $data)[0]);
$value = trim(explode(' ', $data)[1]);
$index = trim(explode('.', $oid)[14]);
$type = 'eltex-mes';
$type = 'eltex-mes23xx';
$limit = 101;
$limitwarn = 100;
$lowlimit = 0;

View File

@@ -1,6 +1,6 @@
<?php
/*
* LibreNMS discovery module for Eltex-MES SFP current
* LibreNMS discovery module for Eltex-MES21xx SFP current
*
* 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
@@ -25,16 +25,11 @@ $low_limit = $low_warn_limit = 15;
$high_warn_limit = $high_limit = 0;
$divisor = 1000000;
$oids = snmp_walk($device, '1.3.6.1.4.1.89.90.1.2.1.3', '-Osqn', '');
$oids = trim($oids);
$oids = $pre_cache['eltex-mes21xx_rlPhyTestGetResult'];
if ($oids) {
echo "Eltex-MES SFP TX Current:\n";
d_echo('Eltex-MES SFP txBias');
foreach (explode("\n", $oids) as $data) {
if ($data) {
print_r($data);
echo "\n";
$split = trim(explode(' ', $data)[0]);
$value = trim(explode(' ', $data)[1]);
$ifIndex = explode('.', $split)[13];
@@ -42,10 +37,12 @@ if ($oids) {
//type 7 = bias
if ($type == 7) {
$descr_oid = '1.0.8802.1.1.2.1.3.7.1.3.' . $ifIndex;
$descr = trim(snmp_get($device, $descr_oid, '-Oqv', ''), '"');
$value = $value / $divisor;
discover_sensor($valid['sensor'], 'current', $device, $split, 'txbias' . $ifIndex, 'eltex-mes', 'SfpTxBias-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value);
$tmp = get_port_by_index_cache($device['device_id'], $ifIndex);
$descr = $tmp['ifName'];
discover_sensor(
$valid['sensor'], 'current', $device, $split, 'txbias' . $ifIndex, 'rlPhyTestTableTxBias', 'SfpTxBias-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value
);
}
}
}

View File

@@ -0,0 +1,49 @@
<?php
/*
* LibreNMS discovery module for Eltex-mes23xx SFP current
*
* 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 <https://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link https://www.librenms.org
*
* @author Peca Nesovanovic <peca.nesovanovic@sattrakt.com>
*/
$low_limit = $low_warn_limit = 15;
$high_warn_limit = $high_limit = 0;
$divisor = 1000000;
$oids = $pre_cache['eltex-mes23xx_rlPhyTestGetResult'];
if ($oids) {
d_echo('Eltex-MES SFP txBias');
foreach (explode("\n", $oids) as $data) {
if ($data) {
$split = trim(explode(' ', $data)[0]);
$value = trim(explode(' ', $data)[1]);
$ifIndex = explode('.', $split)[13];
$type = explode('.', $split)[14];
//type 7 = bias
if ($type == 7) {
$value = $value / $divisor;
$tmp = get_port_by_index_cache($device['device_id'], $ifIndex);
$descr = $tmp['ifName'];
discover_sensor(
$valid['sensor'], 'current', $device, $split, 'txbias' . $ifIndex, 'rlPhyTestTableTxBias', 'SfpTxBias-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value
);
}
}
}
}

View File

@@ -1,6 +1,6 @@
<?php
/*
* LibreNMS discovery module for Eltex-MES SFP Dbm
* LibreNMS discovery module for Eltex-MES21xx SFP Dbm
*
* 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
@@ -25,16 +25,11 @@ $low_limit = $low_warn_limit = -15;
$high_warn_limit = $high_limit = 0;
$divisor = 1000;
$oids = snmp_walk($device, '1.3.6.1.4.1.89.90.1.2.1.3', '-Osqn', '');
$oids = trim($oids);
$oids = $pre_cache['eltex-mes21xx_rlPhyTestGetResult'];
if ($oids) {
echo "Eltex-MES dBm:\n";
d_echo('Eltex-MES SFP dBm');
foreach (explode("\n", $oids) as $data) {
if ($data) {
print_r($data);
echo "\n";
$split = trim(explode(' ', $data)[0]);
$value = trim(explode(' ', $data)[1]);
$ifIndex = explode('.', $split)[13];
@@ -42,18 +37,22 @@ if ($oids) {
//type8 = tx dBm
if ($type == 8) {
$descr_oid = '1.0.8802.1.1.2.1.3.7.1.3.' . $ifIndex;
$descr = trim(snmp_get($device, $descr_oid, '-Oqv', ''), '"');
$value = $value / $divisor;
discover_sensor($valid['sensor'], 'dbm', $device, $split, 'txdbm' . $ifIndex, 'eltex-mes', 'SfpdBmTx-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value);
$tmp = get_port_by_index_cache($device['device_id'], $ifIndex);
$descr = $tmp['ifName'];
discover_sensor(
$valid['sensor'], 'dbm', $device, $split, 'txdbm' . $ifIndex, 'rlPhyTestTableTxOutput', 'SfpTxdBm-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value
);
}
//type9 = rx dBm
if ($type == 9) {
$descr_oid = '1.0.8802.1.1.2.1.3.7.1.3.' . $ifIndex;
$descr = trim(snmp_get($device, $descr_oid, '-Oqv', ''), '"');
$value = $value / $divisor;
discover_sensor($valid['sensor'], 'dbm', $device, $split, 'rxdbm' . $ifIndex, 'eltex-mes', 'SfpdBmRx-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value);
$tmp = get_port_by_index_cache($device['device_id'], $ifIndex);
$descr = $tmp['ifName'];
discover_sensor(
$valid['sensor'], 'dbm', $device, $split, 'rxdbm' . $ifIndex, 'rlPhyTestTableRxOpticalPower', 'SfpRxdBm-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value
);
}
}
}

View File

@@ -0,0 +1,59 @@
<?php
/*
* LibreNMS discovery module for Eltex-mes23xx SFP Dbm
*
* 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 <https://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link https://www.librenms.org
*
* @author Peca Nesovanovic <peca.nesovanovic@sattrakt.com>
*/
$low_limit = $low_warn_limit = -15;
$high_warn_limit = $high_limit = 0;
$divisor = 1000;
$oids = $pre_cache['eltex-mes23xx_rlPhyTestGetResult'];
if ($oids) {
d_echo('Eltex-MES SFP dBm');
foreach (explode("\n", $oids) as $data) {
if ($data) {
$split = trim(explode(' ', $data)[0]);
$value = trim(explode(' ', $data)[1]);
$ifIndex = explode('.', $split)[13];
$type = explode('.', $split)[14];
//type8 = tx dBm
if ($type == 8) {
$value = $value / $divisor;
$tmp = get_port_by_index_cache($device['device_id'], $ifIndex);
$descr = $tmp['ifName'];
discover_sensor(
$valid['sensor'], 'dbm', $device, $split, 'txdbm' . $ifIndex, 'rlPhyTestTableTxOutput', 'SfpTxdBm-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value
);
}
//type9 = rx dBm
if ($type == 9) {
$value = $value / $divisor;
$tmp = get_port_by_index_cache($device['device_id'], $ifIndex);
$descr = $tmp['ifName'];
discover_sensor(
$valid['sensor'], 'dbm', $device, $split, 'rxdbm' . $ifIndex, 'rlPhyTestTableRxOpticalPower', 'SfpRxdBm-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value
);
}
}
}
}

View File

@@ -0,0 +1,25 @@
<?php
/*
* LibreNMS pre-cache module for Eltex-mes21xx OS
*
* 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 <https://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link https://www.librenms.org
*
* @author Peca Nesovanovic <peca.nesovanovic@sattrakt.com>
*/
echo 'rlPhyTestGetResult ';
$pre_cache['eltex-mes21xx_rlPhyTestGetResult'] = snmp_walk($device, 'rlPhyTestGetResult', '-Osqn', 'RADLAN-PHY-MIB');

View File

@@ -0,0 +1,25 @@
<?php
/*
* LibreNMS pre-cache module for Eltex-mes23xx OS
*
* 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 <https://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link https://www.librenms.org
*
* @author Peca Nesovanovic <peca.nesovanovic@sattrakt.com>
*/
echo 'rlPhyTestGetResult ';
$pre_cache['eltex-mes23xx_rlPhyTestGetResult'] = snmp_walk($device, 'rlPhyTestGetResult', '-Osqn', 'RADLAN-PHY-MIB');

View File

@@ -1,6 +1,6 @@
<?php
/*
* LibreNMS discovery module for Eltex-MES SFP Temperature
* LibreNMS discovery module for Eltex-MES21xx SFP Temperature
*
* 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
@@ -25,16 +25,11 @@ $low_limit = $low_warn_limit = 5;
$high_warn_limit = $high_limit = 70;
$divisor = 1;
$oids = snmp_walk($device, '1.3.6.1.4.1.89.90.1.2.1.3', '-Osqn', '');
$oids = trim($oids);
$oids = $pre_cache['eltex-mes21xx_rlPhyTestGetResult'];
if ($oids) {
echo "Eltex-MES SFP Temperature:\n";
d_echo('Eltex-MES SFP temperature');
foreach (explode("\n", $oids) as $data) {
if ($data) {
print_r($data);
echo "\n";
$split = trim(explode(' ', $data)[0]);
$value = trim(explode(' ', $data)[1]);
$ifIndex = explode('.', $split)[13];
@@ -42,10 +37,12 @@ if ($oids) {
//type5 = temperature
if ($type == 5) {
$descr_oid = '1.0.8802.1.1.2.1.3.7.1.3.' . $ifIndex;
$descr = trim(snmp_get($device, $descr_oid, '-Oqv', ''), '"');
$value = $value / $divisor;
discover_sensor($valid['sensor'], 'temperature', $device, $split, 'SfpTemp' . $ifIndex, 'eltex-mes', 'SfpTemp-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value);
$tmp = get_port_by_index_cache($device['device_id'], $ifIndex);
$descr = $tmp['ifName'];
discover_sensor(
$valid['sensor'], 'temperature', $device, $split, 'SfpTemp' . $ifIndex, 'rlPhyTestTableTransceiverTemp', 'SfpTemp-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value
);
}
}
}

View File

@@ -0,0 +1,49 @@
<?php
/*
* LibreNMS discovery module for Eltex-MES23xx SFP Temperature
*
* 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 <https://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link https://www.librenms.org
*
* @author Peca Nesovanovic <peca.nesovanovic@sattrakt.com>
*/
$low_limit = $low_warn_limit = 5;
$high_warn_limit = $high_limit = 70;
$divisor = 1;
$oids = $pre_cache['eltex-mes23xx_rlPhyTestGetResult'];
if ($oids) {
d_echo('Eltex-MES SFP temperature');
foreach (explode("\n", $oids) as $data) {
if ($data) {
$split = trim(explode(' ', $data)[0]);
$value = trim(explode(' ', $data)[1]);
$ifIndex = explode('.', $split)[13];
$type = explode('.', $split)[14];
//type5 = temperature
if ($type == 5) {
$value = $value / $divisor;
$tmp = get_port_by_index_cache($device['device_id'], $ifIndex);
$descr = $tmp['ifName'];
discover_sensor(
$valid['sensor'], 'temperature', $device, $split, 'SfpTemp' . $ifIndex, 'rlPhyTestTableTransceiverTemp', 'SfpTemp-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value
);
}
}
}
}

View File

@@ -1,6 +1,6 @@
<?php
/*
* LibreNMS discovery module for Eltex-MES SFP Voltage
* LibreNMS discovery module for Eltex-MES21xx SFP Voltage
*
* 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
@@ -25,16 +25,11 @@ $low_limit = $low_warn_limit = 3;
$high_warn_limit = $high_limit = 4;
$divisor = 1000000;
$oids = snmp_walk($device, '1.3.6.1.4.1.89.90.1.2.1.3', '-Osqn', '');
$oids = trim($oids);
$oids = $pre_cache['eltex-mes21xx_rlPhyTestGetResult'];
if ($oids) {
echo "Eltex-MES Voltage:\n";
d_echo('Eltex-MES SFP voltage');
foreach (explode("\n", $oids) as $data) {
if ($data) {
print_r($data);
echo "\n";
$split = trim(explode(' ', $data)[0]);
$value = trim(explode(' ', $data)[1]);
$ifIndex = explode('.', $split)[13];
@@ -42,10 +37,12 @@ if ($oids) {
// type6 = voltage
if ($type == 6) {
$descr_oid = '1.0.8802.1.1.2.1.3.7.1.3.' . $ifIndex;
$descr = trim(snmp_get($device, $descr_oid, '-Oqv', ''), '"');
$value = $value / $divisor;
discover_sensor($valid['sensor'], 'voltage', $device, $split, 'SfpVolt' . $ifIndex, 'eltex-mes', 'SfpVolt-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value);
$tmp = get_port_by_index_cache($device['device_id'], $ifIndex);
$descr = $tmp['ifName'];
discover_sensor(
$valid['sensor'], 'voltage', $device, $split, 'SfpVolt' . $ifIndex, 'rlPhyTestTableTransceiverSupply', 'SfpVolt-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value
);
}
}
}

View File

@@ -0,0 +1,49 @@
<?php
/*
* LibreNMS discovery module for Eltex-mes23xx SFP Voltage
*
* 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 <https://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link https://www.librenms.org
*
* @author Peca Nesovanovic <peca.nesovanovic@sattrakt.com>
*/
$low_limit = $low_warn_limit = 3;
$high_warn_limit = $high_limit = 4;
$divisor = 1000000;
$oids = $pre_cache['eltex-mes23xx_rlPhyTestGetResult'];
if ($oids) {
d_echo('Eltex-MES SFP voltage');
foreach (explode("\n", $oids) as $data) {
if ($data) {
$split = trim(explode(' ', $data)[0]);
$value = trim(explode(' ', $data)[1]);
$ifIndex = explode('.', $split)[13];
$type = explode('.', $split)[14];
// type6 = voltage
if ($type == 6) {
$value = $value / $divisor;
$tmp = get_port_by_index_cache($device['device_id'], $ifIndex);
$descr = $tmp['ifName'];
discover_sensor(
$valid['sensor'], 'voltage', $device, $split, 'SfpVolt' . $ifIndex, 'rlPhyTestTableTransceiverSupply', 'SfpVolt-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value
);
}
}
}
}

View File

@@ -1,7 +1,7 @@
<?php
/*
*
* LibreNMS storage discovery module for Eltex-MES.
* LibreNMS storage discovery module for Eltex-MES21xx
*
* 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
@@ -22,7 +22,7 @@
* @author Peca Nesovanovic <peca.nesovanovic@sattrakt.com>
*/
if ($device['os'] == 'eltex-mes') {
if ($device['os'] == 'eltex-mes21xx') {
$fstype = 'Flash';
$descr = 'Internal Flash';
$units = 1024;
@@ -32,6 +32,6 @@ if ($device['os'] == 'eltex-mes') {
$used = $total - $free;
if (is_numeric($free) && is_numeric($total)) {
discover_storage($valid_storage, $device, $index, $fstype, 'eltex-mes', $descr, $total, $units, $used);
discover_storage($valid_storage, $device, $index, $fstype, 'eltex-mes21xx', $descr, $total, $units, $used);
}
}

View File

@@ -0,0 +1,37 @@
<?php
/*
*
* LibreNMS storage discovery module for Eltex-MES23xx
*
* 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 <https://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link https://www.librenms.org
*
* @author Peca Nesovanovic <peca.nesovanovic@sattrakt.com>
*/
if ($device['os'] == 'eltex-mes23xx') {
$fstype = 'Flash';
$descr = 'Internal Flash';
$units = 1024;
$index = 0;
$free = snmp_get($device, 'rlFileFreeSizeOfFlash.0', '-Oqv', 'RADLAN-File');
$total = snmp_get($device, 'rlFileTotalSizeOfFlash.0', '-Oqv', 'RADLAN-File');
$used = $total - $free;
if (is_numeric($free) && is_numeric($total)) {
discover_storage($valid_storage, $device, $index, $fstype, 'eltex-mes23xx', $descr, $total, $units, $used);
}
}