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

FS.COM (Fiberstore) 'GBN' and 'SWITCH' devices support #9734

Merged
merged 33 commits into from
Feb 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
36161b3
Basic Support for Fiberstore devices
PipoCanaja Jan 25, 2019
a4a796b
Basic Support for Fiberstore devices
PipoCanaja Jan 25, 2019
ec508be
mib files
PipoCanaja Jan 25, 2019
2a878d0
sysObjectID added
PipoCanaja Jan 25, 2019
cf229c8
mibs added
PipoCanaja Jan 25, 2019
43ed287
MIB corrections + CPU discovery + version and SN
PipoCanaja Jan 27, 2019
aa86768
CodeClimate + mempools
PipoCanaja Jan 27, 2019
98980fc
CodeClimate + mempools
PipoCanaja Jan 27, 2019
ff3eec0
mempools
PipoCanaja Jan 28, 2019
84e5330
5800
PipoCanaja Jan 28, 2019
deba006
testdata
PipoCanaja Jan 28, 2019
6bddd2f
5800
PipoCanaja Jan 28, 2019
eebde3a
tests
PipoCanaja Jan 28, 2019
507ca60
mempools for 5800
PipoCanaja Jan 28, 2019
431ac26
CodeClimate
PipoCanaja Jan 28, 2019
d7341ba
CodeClimate
PipoCanaja Jan 28, 2019
7fd5889
Cleaning and comments
PipoCanaja Jan 28, 2019
dd69055
Tests for 5800
PipoCanaja Jan 28, 2019
e4de649
CodeClimate
PipoCanaja Jan 28, 2019
885d130
Update Fs.php
murrant Jan 29, 2019
85c8b9d
init processors[]
PipoCanaja Jan 29, 2019
4ef7c4c
optimized logo
PipoCanaja Jan 29, 2019
6e8ce36
optimized logo
PipoCanaja Jan 29, 2019
bbad845
optimized logo
PipoCanaja Jan 29, 2019
4fb8fee
optimized logo
PipoCanaja Jan 29, 2019
d6a772e
split FS devices
PipoCanaja Feb 9, 2019
dbbf1ef
split FS devices
PipoCanaja Feb 9, 2019
4af88ea
split FS devices - tests
PipoCanaja Feb 9, 2019
c0bea22
split FS devices - class
PipoCanaja Feb 9, 2019
fa07880
split FS devices - class
PipoCanaja Feb 9, 2019
b661eaa
split FS devices - tests
PipoCanaja Feb 9, 2019
fcd340b
removing un-necessry condition
PipoCanaja Feb 10, 2019
ab4f51e
text and comments
PipoCanaja Feb 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions LibreNMS/OS/FsGbn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/**
* Fs.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 2019 PipoCanaja
* @author PipoCanaja <pipocanaja@gmail.com>
*/

namespace LibreNMS\OS;

use LibreNMS\Device\Processor;
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
use LibreNMS\OS;

class FsGbn extends OS implements ProcessorDiscovery
{
/**
* Discover processors.
* Returns an array of LibreNMS\Device\Processor objects that have been discovered
*
* @return array Processors
*/
public function discoverProcessors()
{
$processors = [];

// Test first pair of OIDs from GBNPlatformOAM-MIB
$processors_data = snmpwalk_cache_oid($this->getDevice(), 'cpuDescription', [], 'GBNPlatformOAM-MIB', 'fs');
$processors_data = snmpwalk_cache_oid($this->getDevice(), 'cpuIdle', $processors_data, 'GBNPlatformOAM-MIB', 'fs');
foreach ($processors_data as $index => $entry) {
$processors[] = Processor::discover(
$this->getName(),
$this->getDeviceId(),
'.1.3.6.1.4.1.13464.1.2.1.1.2.11.'.$index, //GBNPlatformOAM-MIB::cpuIdle.0 = INTEGER: 95
$index,
$entry['cpuDescription'],
-1,
100 - $entry['cpuIdle']
);
}
return $processors;
}
}
60 changes: 60 additions & 0 deletions LibreNMS/OS/FsSwitch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/**
* Fs-switch.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 2019 PipoCanaja
* @author PipoCanaja <pipocanaja@gmail.com>
*/

namespace LibreNMS\OS;

use LibreNMS\Device\Processor;
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
use LibreNMS\OS;

class FsSwitch extends OS implements ProcessorDiscovery
{
/**
* Discover processors.
* Returns an array of LibreNMS\Device\Processor objects that have been discovered
*
* @return array Processors
*/
public function discoverProcessors()
{
$processors = [];

// Tests OID from SWITCH MIB.
$processors_data = snmpwalk_cache_oid($this->getDevice(), 'ssCpuIdle', [], 'SWITCH', 'fs');

foreach ($processors_data as $index => $entry) {
$processors[] = Processor::discover(
"fs-SWITCHMIB",
$this->getDeviceId(),
'.1.3.6.1.4.1.27975.1.2.11.' . $index,
$index,
"CPU",
-1,
100 - $entry['ssCpuIdle']
);
}
return $processors;
}
}
1 change: 1 addition & 0 deletions html/images/os/fs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions includes/definitions/fs-gbn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
os: fs-gbn
text: 'Fiberstore GBN'
type: network
icon: fs
group: fs
over:
- { graph: device_bits, text: 'Device Traffic' }
- { graph: device_processor, text: 'Processor Usage' }
- { graph: device_mempool, text: 'Memory Usage' }
mib_dir:
- fs
discovery:
- sysObjectID:
- .1.3.6.1.4.1.13464
16 changes: 16 additions & 0 deletions includes/definitions/fs-switch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
os: fs-switch
text: 'Fiberstore Switch'
type: network
icon: fs
group: fs
over:
- { graph: device_bits, text: 'Device Traffic' }
- { graph: device_processor, text: 'Processor Usage' }
- { graph: device_mempool, text: 'Memory Usage' }
mib_dir:
- fs
discovery:
- sysObjectID:
- .1.3.6.1.4.1.51134
- .1.3.6.1.4.1.27975
- .1.3.6.1.4.1.12345
34 changes: 34 additions & 0 deletions includes/discovery/mempools/fs-gbn.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
//
// Discovery for FS gbn devices.
//
//

if ($device['os'] == 'fs-gbn') {
echo 'FS : ';
//
// OIDs from GBNPlatformOAM-MIB
//
$mempools_array = snmpwalk_cache_oid($device, 'memorySize', $mempools_array, 'GBNPlatformOAM-MIB', 'fs');
$mempools_array = snmpwalk_cache_oid($device, 'memoryIdle', $mempools_array, 'GBNPlatformOAM-MIB', 'fs');
$mempools_array = snmpwalk_cache_oid($device, 'cpuDescription', $mempools_array, 'GBNPlatformOAM-MIB', 'fs');
d_echo($mempools_array);
foreach ($mempools_array as $index => $entry) {
//
// We keep the foreach in case multiple replies are seen here.
// We could replace it with a condition (if we suppose only 1 reply will ever come) but
// this would not change the complexity.
//
if ($entry['memorySize'] != 0) {
d_echo($index.' '.$entry['memorySize'].' -> '.$entry['memoryIdle'].' ('.$entry['cpuDescription'].")\n");
$descr = $entry['cpuDescription'];
if (empty($descr)) {
$descr = "Chassis CPU";
}
$descr .= " Memory";
$usage = $entry['memoryIdle'];
discover_mempool($valid_mempool, $device, $index, 'fs-gbn', $descr, '1', null, null);
} //end if
} //end foreach
} //end if
unset($mempools_array);
22 changes: 22 additions & 0 deletions includes/discovery/mempools/fs-switch.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
//
// Discovery for FS-switch devices.
//

if ($device['os'] == 'fs-switch') {
echo 'FS : ';
$mempools_array = snmpwalk_cache_oid($device, 'memTotalReal', [], 'SWITCH', 'fs');
$mempools_array = snmpwalk_cache_oid($device, 'memTotalFree', $mempools_array, 'SWITCH', 'fs');
$mempools_array = snmpwalk_cache_oid($device, 'memTotalUsed', $mempools_array, 'SWITCH', 'fs');
d_echo($mempools_array);
foreach ($mempools_array as $index => $entry) {
if ($entry['memTotalReal'] > 0) {
d_echo($index.' '.$entry['memTotalReal'].' -> '.$entry['memTotalFree']."\n");
$descr = "Chassis";
$descr .= " Memory";
$usage = $entry['memTotalFree'];
discover_mempool($valid_mempool, $device, $index, 'fs-switch', $descr, '1', null, null);
} //end if
} //end foreach
} //end if
unset($mempools_array);
38 changes: 38 additions & 0 deletions includes/polling/mempools/fs-gbn.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

//
// Polling for "fs-gbn" mempool_type, which belongs to Fiberstore devices, using
// GBNPlatformOAM-MIB mib
//
//

$oid = $mempool['mempool_index'];

d_echo('FS Mempool');

if (!is_array($mempool_cache['fs'])) {
d_echo('caching'); //only occurs the first time if multiple mempools are polled
$mempool_cache['fs'] = array();
$mempool_cache['fs'] = snmpwalk_cache_oid($device, 'memorySize', $mempool_cache['fs'], 'GBNPlatformOAM-MIB', 'fs');
$mempool_cache['fs'] = snmpwalk_cache_oid($device, 'memoryIdle', $mempool_cache['fs'], 'GBNPlatformOAM-MIB', 'fs');
d_echo($mempool_cache);
}

$entry = $mempool_cache['fs'][$oid];
//
// The mib states that it should be in bytes already, but in real life, it is not so true
// We suppose that any value below 32768 is clearly not bytes and we understand it as MBytes
//
if ($entry['memorySize'] < (32 * 1024)) {
$entry['memorySize'] = ($entry['memorySize'] * 1024 * 1024);
$entry['memoryIdle'] = ($entry['memoryIdle'] * 1024 * 1024);
}
//
// little math for usage in percents, and absolute values.
//
if ($entry['memorySize'] > 0) {
$perc = ($entry['memorySize'] - $entry['memoryIdle']) / $entry['memorySize'] * 100;
$mempool['total'] = $entry['memorySize'];
$mempool['used'] = ($entry['memorySize'] - $entry['memoryIdle']);
$mempool['free'] = ($entry['memoryIdle']);
}
27 changes: 27 additions & 0 deletions includes/polling/mempools/fs-switch.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
//
// Polling for "fs-switch" mempool_type, which belongs to Fiberstore devices, using
// SWITCH mib
//
$oid = $mempool['mempool_index'];

d_echo('FS Mempool (SWITCHMIB)');

if (!is_array($mempool_cache['fs-switchmib'])) {
d_echo('caching');
$mempool_cache['fs-switchmib'] = snmpwalk_cache_oid($device, 'memTotalReal', [], 'SWITCH', 'fs');
$mempool_cache['fs-switchmib'] = snmpwalk_cache_oid($device, 'memTotalFree', $mempool_cache['fs-switchmib'], 'SWITCH', 'fs');
$mempool_cache['fs-switchmib'] = snmpwalk_cache_oid($device, 'memTotalUsed', $mempool_cache['fs-switchmib'], 'SWITCH', 'fs');
d_echo($mempool_cache);
}

$entry = $mempool_cache['fs-switchmib'][$oid];
//
// Let's do some simple calculation
//
if ($entry['memTotalReal'] > 0) {
$perc = ($entry['memTotalUsed']) / $entry['memTotalReal'] * 100;
$mempool['total'] = ($entry['memTotalReal'] * 1024);
$mempool['used'] = ($entry['memTotalUsed'] * 1024);
$mempool['free'] = ($entry['memTotalFree'] * 1024);
}
42 changes: 42 additions & 0 deletions includes/polling/os/fs-gbn.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

if (!empty($matches[2])) {
$version .= " (" . trim($matches[2]) . ")";
}

// List of OIDs for HW recognition, add any potential HW OID here.
$hwOidList = [
'.1.3.6.1.4.1.13464.1.2.1.1.2.15.0', //GBNPlatformOAM-MIB::productName.0
];
foreach ($hwOidList as $oid) {
$hardware_tmp = snmp_get($device, $oid, '-OQv');
if (!empty($hardware_tmp)) {
$hardware = $hardware_tmp;
}
}

// List of OIDs for version, add any potential OID here.
// As the mib is really buggy, let's use numeric OID for now
$verOidList = [
'.1.3.6.1.4.1.13464.1.2.1.1.2.2.0', //GBNPlatformOAM-MIB::softwareVersion.0
];
foreach ($verOidList as $oid) {
$version_tmp = snmp_get($device, $oid, '-OQv');
if (!empty($version_tmp)) {
$version = $version_tmp;
break;
}
}

//List of OIDs for SN, add any potential device SN OID here
$snOidList = [
'.1.3.6.1.4.1.13464.1.2.1.1.2.19.0',
];
foreach ($snOidList as $oid) {
$serial_tmp = snmp_get($device, $oid, '-OQv');

if (!empty($serial_tmp)) {
$serial = $serial_tmp;
break;
}
}
42 changes: 42 additions & 0 deletions includes/polling/os/fs-switch.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

if (!empty($matches[2])) {
$version .= " (" . trim($matches[2]) . ")";
}

// List of OIDs for HW recognition, add any potential HW OID here.
$hwOidList = [
'.1.3.6.1.4.1.27975.37.1.5.1.4.1.1',
];
foreach ($hwOidList as $oid) {
$hardware_tmp = snmp_get($device, $oid, '-OQv');
if (!empty($hardware_tmp)) {
$hardware = $hardware_tmp;
}
}

// List of OIDs for version, add any potential OID here.
// As the mib is really buggy, let's use numeric OID for now
$verOidList = [
'.1.3.6.1.4.1.27975.1.3.5.0', //SWITCH::version.0
];
foreach ($verOidList as $oid) {
$version_tmp = snmp_get($device, $oid, '-OQv');
if (!empty($version_tmp)) {
$version = $version_tmp;
break;
}
}

//List of OIDs for SN, add any potential device SN OID here
$snOidList = [
'.1.3.6.1.4.1.27975.37.1.5.1.10.1.1',
];
foreach ($snOidList as $oid) {
$serial_tmp = snmp_get($device, $oid, '-OQv');

if (!empty($serial_tmp)) {
$serial = $serial_tmp;
break;
}
}
Loading