diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 0f1ef40df0..90ebe4b18c 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -933,6 +933,17 @@ $config['os'][$os]['over'][1]['text'] = 'CPU Usage'; $config['os'][$os]['over'][2]['graph'] = 'device_mempool'; $config['os'][$os]['over'][2]['text'] = 'Memory Usage'; +$os = 'fortiswitch'; +$config['os'][$os]['text'] = 'Fortinet FortiSwitch'; +$config['os'][$os]['type'] = 'network'; +$config['os'][$os]['icon'] = 'fortinet'; +$config['os'][$os]['over'][0]['graph'] = 'device_bits'; +$config['os'][$os]['over'][0]['text'] = 'Device Traffic'; +$config['os'][$os]['over'][1]['graph'] = 'device_processor'; +$config['os'][$os]['over'][1]['text'] = 'CPU Usage'; +$config['os'][$os]['over'][2]['graph'] = 'device_mempool'; +$config['os'][$os]['over'][2]['text'] = 'Memory Usage'; + $os = 'routeros'; $config['os'][$os]['text'] = 'Mikrotik RouterOS'; $config['os'][$os]['type'] = 'network'; diff --git a/includes/discovery/mempools/fortiswitch.inc.php b/includes/discovery/mempools/fortiswitch.inc.php new file mode 100644 index 0000000000..2e1a945cd3 --- /dev/null +++ b/includes/discovery/mempools/fortiswitch.inc.php @@ -0,0 +1,29 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Neil Lathwood + * @author Neil Lathwood + */ + +if ($device['os'] === 'fortiswitch') { + echo 'Fortiswitch Mempool: '; + discover_mempool($valid_mempool, $device, 0, 'fortiswitch', 'Main Memory', '1024', null, null); +} diff --git a/includes/discovery/os/fortiswitch.inc.php b/includes/discovery/os/fortiswitch.inc.php new file mode 100644 index 0000000000..dffb605c56 --- /dev/null +++ b/includes/discovery/os/fortiswitch.inc.php @@ -0,0 +1,29 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Neil Lathwood + * @author Neil Lathwood + */ + +$version = snmp_get($device, 'fsSysVersion.0', '-Oqn', 'FORTINET-FORTISWITCH-MIB'); +if (str_contains($version, 'FortiSwitch')) { + $os = 'fortiswitch'; +} diff --git a/includes/discovery/processors/fortiswitch.inc.php b/includes/discovery/processors/fortiswitch.inc.php new file mode 100644 index 0000000000..83d318ad9f --- /dev/null +++ b/includes/discovery/processors/fortiswitch.inc.php @@ -0,0 +1,36 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Neil Lathwood + * @author Neil Lathwood + */ + +if ($device['os'] === 'fortiswitch') { + echo 'Fortiswitch : '; + $descr = 'Processor'; + $usage = snmp_get($device, 'fsSysCpuUsage.0', '-Ovq', 'FORTINET-FORTISWITCH-MIB'); + + if (is_numeric($usage)) { + discover_processor($valid['processor'], $device, '.1.3.6.1.4.1.12356.106.4.1.2.0', '1', 'fortiswitch', $descr, '1', $usage, null, null); + } +} + +unset($usage); diff --git a/includes/polling/mempools/fortiswitch.inc.php b/includes/polling/mempools/fortiswitch.inc.php new file mode 100644 index 0000000000..118633e8d5 --- /dev/null +++ b/includes/polling/mempools/fortiswitch.inc.php @@ -0,0 +1,33 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Neil Lathwood + * @author Neil Lathwood + */ + +echo 'Fortigate MemPool'; + +$mempool['used'] = snmp_get($device, 'fsSysMemUsage.0', '-OvQ', 'FORTINET-FORTISWITCH-MIB'); +$mempool['total'] = snmp_get($device, 'fsSysMemCapacity.0', '-OvQ', 'FORTINET-FORTISWITCH-MIB'); +$mempool['free'] = ($mempool['total'] - $mempool['used']); +$mempool['perc'] = $mempool['total'] / $mempool['used']; + +echo '(U: '.$mempool['used'].' T: '.$mempool['total'].' F: '.$mempool['free'].') '; diff --git a/includes/polling/os/fortiswitch.inc.php b/includes/polling/os/fortiswitch.inc.php new file mode 100644 index 0000000000..9f25238036 --- /dev/null +++ b/includes/polling/os/fortiswitch.inc.php @@ -0,0 +1,29 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Neil Lathwood + * @author Neil Lathwood + */ + +$temp_data = explode(' ', snmp_get($device, 'fsSysVersion.0', '-Onvq', 'FORTINET-FORTISWITCH-MIB')); +$hardware = $temp_data[0]; +$version = $temp_data[1]; +$serial = preg_replace('/"/', '', snmp_get($device, 'fnSysSerial.0', '-Onvq', 'FORTINET-CORE-MIB')); diff --git a/mibs/FORTINET-FORTISWITCH-MIB b/mibs/FORTINET-FORTISWITCH-MIB new file mode 100644 index 0000000000..4a6851cab4 --- /dev/null +++ b/mibs/FORTINET-FORTISWITCH-MIB @@ -0,0 +1,223 @@ +-- +-- MODULE-IDENTITY +-- OrgName +-- Fortinet Technologies, Inc. +-- ContactInfo +-- Technical Support +-- e-mail: support@fortinet.com +-- http://www.fortinet.com +-- + +FORTINET-FORTISWITCH-MIB DEFINITIONS ::= BEGIN + +IMPORTS + fnSysSerial, fortinet + FROM FORTINET-CORE-MIB + sysName + FROM SNMPv2-MIB + MODULE-COMPLIANCE, NOTIFICATION-GROUP, OBJECT-GROUP + FROM SNMPv2-CONF + Gauge32, MODULE-IDENTITY, + NOTIFICATION-TYPE, OBJECT-TYPE + FROM SNMPv2-SMI + DisplayString + FROM SNMPv2-TC; + +fnFortiSwitchMib MODULE-IDENTITY + LAST-UPDATED "201109280000Z" + ORGANIZATION + "Fortinet Technologies, Inc." + CONTACT-INFO + " + Technical Support + email: support@fortinet.com + http://www.fortinet.com" + DESCRIPTION + "MIB module for Fortinet FortiSwitch devices." + REVISION "201109280000Z" + DESCRIPTION + "Initial version of FORTINET-FORTISWITCH-MIB." + ::= { fortinet 106 } + +-- +-- fortinet.fnFortiSwitchMib.fsModel +-- + +fsModel OBJECT IDENTIFIER + ::= { fnFortiSwitchMib 1 } + +-- +-- fortinet.fnFortiSwitchMib.fsTraps +-- + +fsTraps OBJECT IDENTIFIER + ::= { fnFortiSwitchMib 2 } + +fsTrapPrefix OBJECT IDENTIFIER + ::= { fsTraps 0 } + +-- +-- fortinet.fnFortiSwitchMib.fsTrunkMemPrefix +-- + +fsTrunkMemPrefix OBJECT IDENTIFIER + ::= { fnFortiSwitchMib 3 } + +fsTrunkMember OBJECT-TYPE + SYNTAX DisplayString (SIZE(0..82)) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Trunk members of the device, including this trunk member's corresponding blade's serial number and its slot name" + ::= { fsTrunkMemPrefix 1 } + +fsTrapHBFail NOTIFICATION-TYPE + OBJECTS { fnSysSerial, sysName, fsTrunkMember} + STATUS current + DESCRIPTION + "Indicates no heart beat packets received." + ::= { fsTrapPrefix 701 } + +fsTrapHBReceived NOTIFICATION-TYPE + OBJECTS { fnSysSerial,sysName, fsTrunkMember} + STATUS current + DESCRIPTION + "Indicates heart beat pacekts have been received." + ::= { fsTrapPrefix 702 } + +fsTrapMemberDown NOTIFICATION-TYPE + OBJECTS { fnSysSerial,sysName,fsTrunkMember } + STATUS current + DESCRIPTION + "A trunk member has left this trunk." + ::= { fsTrapPrefix 703 } + +fsTrapMemberUp NOTIFICATION-TYPE + OBJECTS { fnSysSerial,sysName, fsTrunkMember} + STATUS current + DESCRIPTION + "A trunk member has joined this trunk" + ::= { fsTrapPrefix 704 } + +-- +-- fortinet.fnFortiSwitchMib.fsSystem +-- + +fsSystem OBJECT IDENTIFIER + ::= { fnFortiSwitchMib 4 } + +fsSystemInfo OBJECT IDENTIFIER + ::= { fsSystem 1 } + +fsSysVersion OBJECT-TYPE + SYNTAX DisplayString (SIZE(0..128)) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Firmware version of the device" + ::= { fsSystemInfo 1 } + +fsSysCpuUsage OBJECT-TYPE + SYNTAX Gauge32 (0..100) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Current CPU usage (percentage)" + ::= { fsSystemInfo 2 } + +fsSysMemUsage OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Current system memory usage (KB)" + ::= { fsSystemInfo 3 } + +fsSysMemCapacity OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Total physical memory (RAM) installed (KB)" + ::= { fsSystemInfo 4 } + +fsSysDiskUsage OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Current hard disk usage (KB), if disk is present" + ::= { fsSystemInfo 5 } + +fsSysDiskCapacity OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Total hard disk capacity (KB), if disk is present" + ::= { fsSystemInfo 6 } + +fsSoftware OBJECT IDENTIFIER + ::= { fsSystem 2 } + +fsDirverVersion OBJECT-TYPE + SYNTAX DisplayString (SIZE(0..128)) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Current driver version of this device" + ::= { fsSoftware 1 } + +-- +-- fortinet.fnFortiSwitchMib.fsMibConformance +-- + +fsMibConformance OBJECT IDENTIFIER + ::= { fnFortiSwitchMib 100 } + +fsNotificationGroup NOTIFICATION-GROUP + NOTIFICATIONS { fsTrapHBFail, fsTrapHBReceived, fsTrapMemberDown, fsTrapMemberUp } + STATUS current + DESCRIPTION + "Notifications that can be generated from a FortiSwitch device." + ::= { fsMibConformance 1 } + +fsSystemObjectGroup OBJECT-GROUP + OBJECTS { fsSysVersion, fsSysCpuUsage, + fsSysMemUsage, fsSysMemCapacity, + fsSysDiskUsage, fsSysDiskCapacity, + fsDirverVersion } + STATUS current + DESCRIPTION + "Objects pertaining to the system status of the device." + ::= { fsMibConformance 2 } + +fsTrunkObjectGroup OBJECT-GROUP + OBJECTS { fsTrunkMember } + STATUS current + DESCRIPTION + "Objects pertaining to the information of the trunk." + ::= { fsMibConformance 3 } + +fsMIBCompliance MODULE-COMPLIANCE + STATUS current + DESCRIPTION + "The compliance statement for the application MIB." + + MODULE -- this module + + GROUP fsNotificationGroup + DESCRIPTION + "Notifications are feature dependant. See manual for feature information." + + GROUP fsSystemObjectGroup + DESCRIPTION + "Model and feature specific." + + GROUP fsTrunkObjectGroup + DESCRIPTION + "Model and feature specific." + + ::= { fsMibConformance 100 } + +END -- end of module FORTINET-FORTISWITCH-MIB. \ No newline at end of file diff --git a/tests/OSDiscoveryTest.php b/tests/OSDiscoveryTest.php index ab103c931e..ca8f5d57a9 100644 --- a/tests/OSDiscoveryTest.php +++ b/tests/OSDiscoveryTest.php @@ -553,6 +553,11 @@ class DiscoveryTest extends \PHPUnit_Framework_TestCase $this->checkOS('fortios'); } + public function testFortiswitch() + { + $this->checkOS('fortiswitch'); + } + public function testFoundryos() { $this->checkOS('foundryos'); diff --git a/tests/snmpsim/acano.snmprec b/tests/snmpsim/acano.snmprec index 5f9df3d2ba..0ace3a7f93 100644 --- a/tests/snmpsim/acano.snmprec +++ b/tests/snmpsim/acano.snmprec @@ -1,2 +1,2 @@ 1.3.6.1.2.1.1.1.0|4|Acano -1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.8072.3.2.10 +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.8072.3.2.10 \ No newline at end of file diff --git a/tests/snmpsim/fortiswitch.snmprec b/tests/snmpsim/fortiswitch.snmprec new file mode 100644 index 0000000000..092a449d8a --- /dev/null +++ b/tests/snmpsim/fortiswitch.snmprec @@ -0,0 +1,2 @@ +1.3.6.1.4.1.12356.106.4.1.1.0|4|FortiSwitch-248D-FPOE v3.3.3,build4047,160219 (GA) +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.12356.106.1.2482 \ No newline at end of file