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

Add MikroTik SNMP profile #273

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions wwwroot/inc/dictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
85 changes: 84 additions & 1 deletion wwwroot/inc/snmp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
(
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
} elseif ($sysObjectID == '14988.1') {
$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
Expand All @@ -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
Expand Down