From 1c22c6861d94a5d3c4f0d835c03fc59aabd723f3 Mon Sep 17 00:00:00 2001 From: Alexandr Patrikeev Date: Sat, 6 Mar 2021 04:26:44 +0300 Subject: [PATCH 1/2] Add MikroTik SNMP profile --- wwwroot/inc/dictionary.php | 1 + wwwroot/inc/snmp.php | 85 +++++++++++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/wwwroot/inc/dictionary.php b/wwwroot/inc/dictionary.php index c15c139c7..7e5f3ce11 100644 --- a/wwwroot/inc/dictionary.php +++ b/wwwroot/inc/dictionary.php @@ -3819,6 +3819,7 @@ function getConfigDefaults() 3756 => array ('chapter_id' => 13, 'dict_value' => 'NetBSD%GSKIP%NetBSD 8.2'), 3757 => array ('chapter_id' => 13, 'dict_value' => 'NetBSD%GSKIP%NetBSD 9.0'), 3758 => array ('chapter_id' => 13, 'dict_value' => 'NetBSD%GSKIP%NetBSD 9.1'), + 3759 => array ('chapter_id' => 12, 'dict_value' => 'MikroTik%GPASS%CRS354-48G-4S+2Q+'), # Any new "default" dictionary records must go above this line (i.e., with # dict_key code less than 50000). This is necessary to keep AUTO_INCREMENT diff --git a/wwwroot/inc/snmp.php b/wwwroot/inc/snmp.php index 40879d08e..7581fb380 100644 --- a/wwwroot/inc/snmp.php +++ b/wwwroot/inc/snmp.php @@ -2394,6 +2394,42 @@ 'try_next_proc' => FALSE, ); +$iftable_processors['mikrotik-ether'] = array +( + 'pattern' => '@^ether(\d+)$@', + 'replacement' => 'eth\1', + 'dict_key' => '1-24', + 'label' => 'eth\1', + 'try_next_proc' => TRUE, +); + +$iftable_processors['mikrotik-combo'] = array +( + 'pattern' => '@^combo(\d+)$@', + 'replacement' => 'combo\1', + 'dict_key' => '4-1077', + 'label' => 'combo\1', + 'try_next_proc' => TRUE, +); + +$iftable_processors['mikrotik-sfpplus'] = array +( + 'pattern' => '@^sfpplus(\d+)$@', + 'replacement' => 'sfpplus\1', + 'dict_key' => '9-1084', + 'label' => 'sfpplus\1', + 'try_next_proc' => TRUE, +); + +$iftable_processors['mikrotik-qsfpplus'] = array +( + 'pattern' => '@^qsfpplus(\d+)-(\d+)$@', + 'replacement' => 'qsfpplus\1-\2', + 'dict_key' => '10-1588', + 'label' => 'qsfpplus\1-\2', + 'try_next_proc' => FALSE, +); + global $known_switches; $known_switches = array // key is system OID w/o "enterprises" prefix ( @@ -4530,6 +4566,19 @@ 'text' => 'HP%GPASS%HP A5120-48G-PoE+ EI (JG237A)', 'processors' => array ('h3c-49-to-52-SFP','h3c-any-Gb','h3c-any-SFP+'), ), + // MikroTik block + 'RouterOS CCR1009-7G-1C-1S+' => array + ( + 'dict_key' => 2704, + 'text' => 'MikroTik%GPASS%CCR1009-7G-1C-1S+', + 'processors' => array ('mikrotik-ether', 'mikrotik-combo', 'mikrotik-sfpplus'), + ), + 'RouterOS CRS354-48G-4S+2Q+' => array + ( + 'dict_key' => 3759, + 'text' => 'MikroTik%GPASS%CRS354-48G-4S+2Q+', + 'processors' => array ('mikrotik-ether', 'mikrotik-sfpplus', 'mikrotik-qsfpplus'), + ), ); global $swtype_pcre; @@ -4638,11 +4687,21 @@ function doSwitchSNMPmining ($objectInfo, $device) return; } $sysObjectID = preg_replace ('/^.*( \.1\.3\.6\.1\.|enterprises\.|joint-iso-ccitt\.)([\.[:digit:]]+)$/', '\\2', $sysObjectID); - if (!isset ($known_switches[$sysObjectID])) + + if (!isset ($known_switches[$sysObjectID]) && $sysObjectID !== '14988.1') { showError ("Unknown OID '{$sysObjectID}'"); return; + } else { + $sysObjectID = substr ($device->snmpget ('sysDescr.0'), strlen ('STRING: ')); + if (!isset ($known_switches[$sysObjectID])) + { + showError ("Unknown Model '{$sysObjectID}'"); + return; + } } + + $sysName = substr ($device->snmpget ('sysName.0'), strlen ('STRING: ')); $sysDescr = substr ($device->snmpget ('sysDescr.0'), strlen ('STRING: ')); $sysDescr = str_replace (array ("\n", "\r"), " ", $sysDescr); // Make it one line @@ -4658,6 +4717,30 @@ function doSwitchSNMPmining ($objectInfo, $device) updateStickerForCell ($objectInfo, 3, $sysName); detectSoftwareType ($objectInfo, $sysDescr); $desiredPorts = array(); + //MikroTik block + switch ($sysObjectID) + { + case "RouterOS CCR1009-7G-1C-1S+": + //AC x2 + checkPIC ('1-16'); + addDesiredPort ($desiredPorts, 'AC-in-1', '1-16', 'AC1', ''); + addDesiredPort ($desiredPorts, 'AC-in-2', '1-16', 'AC2', ''); + //RS-232 + checkPIC ('1-681'); + addDesiredPort ($desiredPorts, 'serial0', '1-681', 'serial0', ''); + break; + + case "RouterOS CRS354-48G-4S+2Q+": + //AC x2 + checkPIC ('1-16'); + addDesiredPort ($desiredPorts, 'AC-in-1', '1-16', 'AC1', ''); + addDesiredPort ($desiredPorts, 'AC-in-2', '1-16', 'AC2', ''); + //RS-232 + checkPIC ('1-29'); + addDesiredPort ($desiredPorts, 'serial0', '1-29', 'serial0', ''); + break; + } + switch (1) { case preg_match ('/^9\.1\./', $sysObjectID): // Catalyst w/one AC port From 681377b164c184f4ddd8fa60cf8d12a5f6181932 Mon Sep 17 00:00:00 2001 From: Alexandr Patrikeev Date: Sat, 6 Mar 2021 23:27:03 +0300 Subject: [PATCH 2/2] fix if --- .DS_Store | Bin 0 -> 6148 bytes wwwroot/inc/snmp.php | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..854a5bd56a803e88b67f63373f3ad71fb2c0cac8 GIT binary patch literal 6148 zcmeHKI|>3p3{6x}u(7n9D|mxJ^aNf&)KXaRgY8zH%cJ@7DU{Vt3*}|WyqQeiEc=Sd zMnrUe-pxcNA~J#-%GHLh*}i$ldKpn59A`9mPP^lFziB$zuLH&%%Eh0aZmjD(E0Bd3! zhzLxB3Jj`di=jbBykuTYYy*QXn$3sin>9NW^|#~v;_0F_kRuhK0?!KcV>z+snmpget ('sysDescr.0'), strlen ('STRING: ')); if (!isset ($known_switches[$sysObjectID])) {