Skip to content
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
32 changes: 32 additions & 0 deletions wwwroot/inc/definitions/ubiquiti.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

# This file is a part of RackTables, a datacenter and server room management
# framework. See accompanying file "COPYING" for the full copyright and
# licensing information.

/*
*
* This file is a definitions file for Ubiquiti devices.
*
*/

$ubiquiti_switches = array(
"EdgeSwitch 16-Port 10G" => array(
'dict_key' => 2625,
'text' => 'Ubiquiti EdgeSwitch ES-16-XG',
'processors' => array ('ubiquiti-chassis-13-to-16-10GBASE-T','ubiquiti-chassis-any-SFP+')
),
"EdgeSwitch 48-Port Lite" => array(
'dict_key' => 2624,
'text' => 'Ubiquiti EdgeSwitch ES-48-LITE',
'processors' => array ('ubiquiti-chassis-51-to-52-1000SFP','ubiquiti-chassis-any-1000T','ubiquiti-chassis-any-SFP+')
));

if (!isset($switch_model_lookup))
{
$switch_model_lookup = array();
}

$switch_model_lookup['ubiquiti'] = $ubiquiti_switches;

?>
1 change: 1 addition & 0 deletions wwwroot/inc/dictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -2513,6 +2513,7 @@ function platform_is_ok ()
2622 => array ('chapter_id' => 13, 'dict_value' => 'Xen Hypervisor%GSKIP%XenServer 7.0'),
2623 => array ('chapter_id' => 18, 'dict_value' => 'HP StorageWorks P6300'),
2624 => array ('chapter_id' => 12, 'dict_value' => 'Ubiquiti EdgeSwitch ES-48-LITE'),
2625 => array ('chapter_id' => 12, 'dict_value' => 'Ubiquiti EdgeSwitch ES-16-XG'),

# 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
27 changes: 27 additions & 0 deletions wwwroot/inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6519,4 +6519,31 @@ function syncObjectPorts ($objectInfo, $desiredPorts)
showSuccess ("Added ports: {$added}, changed: {$changed}, deleted: {$deleted}");
}

// searches array of model descriptions for switches from vendor that share OID
// $manufacturer is defined in the $known_switches array
// $description is from the sysDescr
function multi_model_lookup($manufacturer=false, $description=false)
{
if ($manufacturer === false || $description === false)
{
return false;
}
$filePath = implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__),'definitions',"{$manufacturer}.php"));
if (!file_exists($filePath))
{
return false;
}
include $filePath;

foreach($switch_model_lookup[$manufacturer] as $key=>$array)
{
$pos = strpos($description, $key);
if ($pos !== false)
{
return $array;
}
}
return false;
}

?>
22 changes: 19 additions & 3 deletions wwwroot/inc/snmp.php
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,15 @@
'try_next_proc' => FALSE,
);

$iftable_processors['ubiquiti-chassis-13-to-16-10GBASE-T'] = array
(
'pattern' => '@^Slot: (\d+) Port: (13|14|15|16) 10G - Level$@',
'replacement' => '\\1/\\2',
'dict_key' => '1642',
'label' => '\\2',
'try_next_proc' => FALSE,
);

global $known_switches;
$known_switches = array // key is system OID w/o "enterprises" prefix
(
Expand Down Expand Up @@ -4006,9 +4015,7 @@
),
'4413' => array
(
'dict_key' => 2624,
'text' => 'Ubiquiti EdgeSwitch ES-48-LITE',
'processors' => array ('ubiquiti-chassis-51-to-52-1000SFP','ubiquiti-chassis-any-1000T','ubiquiti-chassis-any-SFP+'),
'model_lookup' => 'ubiquiti',
),
);

Expand Down Expand Up @@ -4126,6 +4133,15 @@ function doSwitchSNMPmining ($objectInfo, $device)
$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
if (array_key_exists("model_lookup", $known_switches[$sysObjectID]))
{
if (FALSE === ($switchObject = multi_model_lookup($known_switches[$sysObjectID]['model_lookup'], $sysDescr)))
{
showError ("Unknown Model for OID '{$sysObjectID}'");
return;
}
$known_switches[$sysObjectID] = $switchObject;
}
$ifDescr_tablename = array_fetch ($known_switches[$sysObjectID], 'ifDescrOID', 'ifDescr');
showSuccess ($known_switches[$sysObjectID]['text']);
foreach (array_keys ($known_switches[$sysObjectID]['processors']) as $pkey)
Expand Down