newdevice: Added support for Megatec NetAgent II

This commit is contained in:
Neil Lathwood 2016-10-23 18:31:36 +01:00 committed by GitHub
commit 81f44bb041
13 changed files with 615 additions and 0 deletions

View File

@ -145,6 +145,7 @@ LibreNMS contributors:
- Joseph Eames <j.eames@outlook.com> (j-ems)
- Eric Conroy <eric@conroy.co> (NetworkNub)
- Timothy Willey <developer@timothywilley.net> (twilley)
- Jon Ward <librenms@yonzb.net> (yon2004)
[1]: http://observium.org/ "Observium web site"
Observium was written by:

View File

@ -1466,6 +1466,13 @@ $config['os'][$os]['type'] = 'power';
$config['os'][$os]['over'][0]['graph'] = 'device_current';
$config['os'][$os]['over'][0]['text'] = 'Current';
$os = 'netagent2';
$config['os'][$os]['text'] = 'NET Agent II UPS';
$config['os'][$os]['group'] = 'ups';
$config['os'][$os]['type'] = 'power';
$config['os'][$os]['over'][0]['graph'] = 'device_load';
$config['os'][$os]['over'][0]['text'] = 'Load';
$os = 'mgepdu';
$config['os'][$os]['text'] = 'MGE PDU';
$config['os'][$os]['type'] = 'power';

View File

@ -0,0 +1,28 @@
<?php
/**
* netagent2.inc.php
*
* LibreNMS os discovery module for Megatec Net Agent II
*
* 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 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/
if (starts_with($sysDescr, 'NET Agent II')) {
$os = 'netagent2';
}

View File

@ -0,0 +1,56 @@
<?php
/**
* netagent2.inc.php
*
* -Description-
*
* 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 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
if ($device['os'] == 'netagent2') {
$charge_oid = '.1.3.6.1.4.1.935.1.1.1.2.2.1.0';
$charge = snmp_get($device, $charge_oid, '-Osqnv');
if (!empty($charge)) {
$type = 'netagent2';
$index = 0;
$limit = 100;
$lowlimit = 0;
$lowwarnlimit = 10;
$divisor = 1;
$descr = 'Battery Charge';
discover_sensor(
$valid['sensor'],
'charge',
$device,
$charge_oid,
$index,
$type,
$descr,
$divisor,
1,
$lowlimit,
$lowwarnlimit,
null,
$limit,
$charge
);
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* netagent2.inc.php
*
* -Description-
*
* 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 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
if ($device['os'] == 'netagent2') {
$battery_current_oid = '.1.3.6.1.4.1.935.1.1.1.2.2.7.0';
$battery_current = snmp_get($device, $battery_current_oid, '-Oqv');
if (!empty($battery_current) || $battery_current == 0) {
$type = 'netagent2';
$index = 0;
$limit = 30;
$warnlimit = null;
$lowlimit = null;
$lowwarnlimit = null;
$divisor = 10;
$current = $battery_current / $divisor;
$descr = 'Battery Current';
discover_sensor(
$valid['sensor'],
'current',
$device,
$battery_current_oid,
$index,
$type,
$descr,
$divisor,
'1',
$lowlimit,
$lowwarnlimit,
$warnlimit,
$limit,
$current
);
}
}//end if

View File

@ -0,0 +1,90 @@
<?php
/**
* netagent2.inc.php
*
* -Description-
*
* 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 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
if ($device['os'] == 'netagent2') {
$in_frequency_oid = '.1.3.6.1.4.1.935.1.1.1.3.2.4.0';
$in_frequency = snmp_get($device, $in_frequency_oid, '-Oqv');
if (!empty($in_frequency) || $in_frequency == 0) {
$type = 'netagent2';
$index = 0;
$limit = 60;
$warnlimit = 51;
$lowlimit = 0;
$lowwarnlimit = 49;
$divisor = 10;
$frequency = $in_frequency / $divisor;
$descr = 'Input frequency';
discover_sensor(
$valid['sensor'],
'frequency',
$device,
$in_frequency_oid,
$index,
$type,
$descr,
$divisor,
'1',
$lowlimit,
$lowwarnlimit,
$warnlimit,
$limit,
$frequency
);
}
$out_frequency_oid = '.1.3.6.1.4.1.935.1.1.1.4.2.2.0';
$out_frequency = snmp_get($device, $frequency_oid, '-Oqv');
if (!empty($out_frequency) || $out_frequency == 0) {
$type = 'netagent2';
$index = 1;
$limit = 60;
$warnlimit = 51;
$lowlimit = 0;
$lowwarnlimit = 49;
$divisor = 10;
$frequency = $out_frequency / $divisor;
$descr = 'Output frequency';
discover_sensor(
$valid['sensor'],
'frequency',
$device,
$out_frequency_oid,
$index,
$type,
$descr,
$divisor,
'1',
$lowlimit,
$lowwarnlimit,
$warnlimit,
$limit,
$frequency
);
}
}//end if

View File

@ -0,0 +1,58 @@
<?php
/**
* netagent2.inc.php
*
* -Description-
*
* 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 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
if ($device['os'] == 'netagent2') {
$load_oid = '.1.3.6.1.4.1.935.1.1.1.4.2.3.0';
$output_load = snmp_get($device, $load_oid, '-Oqv');
if (!empty($output_load) || $output_load == 0) {
$type = 'netagent2';
$index = 0;
$limit = 100;
$warnlimit = 80;
$lowlimit = 0;
$lowwarnlimit = null;
$divisor = 1;
$load = $output_load / $divisor;
$descr = 'Output load';
discover_sensor(
$valid['sensor'],
'load',
$device,
$load_oid,
$index,
$type,
$descr,
$divisor,
'1',
$lowlimit,
$lowwarnlimit,
$warnlimit,
$limit,
$load
);
}
}//end if

View File

@ -0,0 +1,92 @@
<?php
/**
* netagent2.inc.php
*
* -Description-
*
* 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 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
if ($device['os'] == 'netagent2') {
$ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.4.1.1.0';
$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);
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;
$lowlimit = null;
$lowwarnlimit = null;
$divisor = 1;
$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
);
}
}//end if

View File

@ -0,0 +1,58 @@
<?php
/**
* netagent2.inc.php
*
* -Description-
*
* 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 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
if ($device['os'] == 'netagent2') {
$ups_temperature_oid = '.1.3.6.1.4.1.935.1.1.1.2.2.3.0';
$ups_temperature = snmp_get($device, $ups_temperature_oid, '-Oqv');
if (!empty($ups_temperature) || $ups_temperature == 0) {
$type = 'netagent2';
$index = 0;
$limit = 110;
$warnlimit = 50;
$lowlimit = 0;
$lowwarnlimit = 6;
$divisor = 10;
$temperature = $ups_temperature / $divisor;
$descr = 'Temperature';
discover_sensor(
$valid['sensor'],
'temperature',
$device,
$ups_temperature_oid,
$index,
$type,
$descr,
$divisor,
'1',
$lowlimit,
$lowwarnlimit,
$warnlimit,
$limit,
$temperature
);
}
}//end if

View File

@ -0,0 +1,122 @@
<?php
/**
* netagent2.inc.php
*
* -Description-
*
* 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 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
if ($device['os'] == 'netagent2') {
$in_voltage_oid = '.1.3.6.1.4.1.935.1.1.1.3.2.1.0';
$in_voltage = snmp_get($device, $in_voltage_oid, '-Oqv');
if (!empty($in_voltage) || $in_voltage == 0) {
$type = 'netagent2';
$index = 0;
$limit = 300;
$warnlimit = 253;
$lowlimit = 0;
$lowwarnlimit = 216;
$divisor = 10;
$voltage = $in_voltage / $divisor;
$descr = 'Input Voltage';
discover_sensor(
$valid['sensor'],
'voltage',
$device,
$in_voltage_oid,
$index,
$type,
$descr,
$divisor,
'1',
$lowlimit,
$lowwarnlimit,
$warnlimit,
$limit,
$voltage
);
}
$out_voltage_oid = '.1.3.6.1.4.1.935.1.1.1.4.2.1.0';
$out_voltage = snmp_get($device, $out_voltage_oid, '-Oqv');
if (!empty($out_voltage) || $out_voltage == 0) {
$type = 'netagent2';
$index = 1;
$limit = 300;
$warnlimit = 253;
$lowlimit = 0;
$lowwarnlimit = 216;
$divisor = 10;
$voltage = $out_voltage / $divisor;
$descr = 'Output Voltage';
discover_sensor(
$valid['sensor'],
'voltage',
$device,
$out_voltage_oid,
$index,
$type,
$descr,
$divisor,
'1',
$lowlimit,
$lowwarnlimit,
$warnlimit,
$limit,
$voltage
);
}
$battery_voltage_oid = '.1.3.6.1.4.1.935.1.1.1.2.2.2.0';
$battery_voltage = snmp_get($device, $battery_voltage_oid, '-Oqv');
if (!empty($battery_voltage) || $battery_voltage == 0) {
$type = 'netagent2';
$index = 2;
$limit = 100;
$warnlimit = null;
$lowlimit = null;
$lowwarnlimit = null;
$divisor = 10;
$voltage = $battery_voltage / $divisor;
$descr = 'Battery Voltage';
discover_sensor(
$valid['sensor'],
'voltage',
$device,
$battery_voltage_oid,
$index,
$type,
$descr,
$divisor,
'1',
$lowlimit,
$lowwarnlimit,
$warnlimit,
$limit,
$voltage
);
}
}//end if

View File

@ -0,0 +1,29 @@
<?php
/**
* netagent2.inc.php
*
* LibreNMS os polling module for Megatec
*
* 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 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/
// NET Agent II
$version = snmp_get($device, '.1.3.6.1.2.1.33.1.1.4.0', '-OQv');
$hardware = $poll_device['sysDescr'];

View File

@ -1195,6 +1195,11 @@ class DiscoveryTest extends \PHPUnit_Framework_TestCase
$this->checkOS('sinetica');
}
public function testMegatec()
{
$this->checkOS('netagent2');
}
public function testSmartax()
{
$this->checkOS('smartax');

View File

@ -0,0 +1,11 @@
1.3.6.1.2.1.1.1.0|4|NET Agent II
1.3.6.1.2.1.1.2.0|6|.1.3.6.1.4.1.935
1.3.6.1.4.1.935.1.1.1.2.2.1.0|2|100
1.3.6.1.4.1.935.1.1.1.2.2.7.0|2|0
1.3.6.1.4.1.935.1.1.1.3.2.4.0|2|500
1.3.6.1.4.1.935.1.1.1.4.2.2.0|2|500
1.3.6.1.4.1.935.1.1.1.4.2.3.0|2|44
1.3.6.1.4.1.935.1.1.1.2.2.3.0|2|250
1.3.6.1.4.1.935.1.1.1.3.2.1.0|2|2545
1.3.6.1.4.1.935.1.1.1.4.2.1.0|2|2285
1.3.6.1.4.1.935.1.1.1.4.1.1.0|2|9