mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Update code in includes to be PSR-2 compliant (#4220)
refactor: Update code in /includes to be psr2 compliant #4220
This commit is contained in:
committed by
Neil Lathwood
parent
3c0fcdd46b
commit
9284bc60ff
@@ -15,38 +15,38 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
function string_to_oid($string) {
|
||||
function string_to_oid($string)
|
||||
{
|
||||
$oid = strlen($string);
|
||||
for ($i = 0; $i != strlen($string); $i++) {
|
||||
$oid .= '.'.ord($string[$i]);
|
||||
}
|
||||
|
||||
return $oid;
|
||||
|
||||
}//end string_to_oid()
|
||||
|
||||
|
||||
function prep_snmp_setting($device, $setting) {
|
||||
function prep_snmp_setting($device, $setting)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (is_numeric($device[$setting]) && $device[$setting] > 0) {
|
||||
return $device[$setting];
|
||||
}
|
||||
else if (isset($config['snmp'][$setting])) {
|
||||
} elseif (isset($config['snmp'][$setting])) {
|
||||
return $config['snmp'][$setting];
|
||||
}
|
||||
|
||||
}//end prep_snmp_setting()
|
||||
|
||||
|
||||
function mibdir($mibdir) {
|
||||
function mibdir($mibdir)
|
||||
{
|
||||
global $config;
|
||||
return ' -M '.($mibdir ? $mibdir : $config['mibdir']);
|
||||
|
||||
}//end mibdir()
|
||||
|
||||
|
||||
function snmp_get_multi($device, $oids, $options='-OQUs', $mib=null, $mibdir=null) {
|
||||
function snmp_get_multi($device, $oids, $options = '-OQUs', $mib = null, $mibdir = null)
|
||||
{
|
||||
global $debug,$config,$runtime_stats,$mibs_loaded;
|
||||
|
||||
// populate timeout & retries values from configuration
|
||||
@@ -97,11 +97,11 @@ function snmp_get_multi($device, $oids, $options='-OQUs', $mib=null, $mibdir=nul
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}//end snmp_get_multi()
|
||||
|
||||
|
||||
function snmp_get($device, $oid, $options=null, $mib=null, $mibdir=null) {
|
||||
function snmp_get($device, $oid, $options = null, $mib = null, $mibdir = null)
|
||||
{
|
||||
global $debug,$config,$runtime_stats,$mibs_loaded;
|
||||
|
||||
$timeout = prep_snmp_setting($device, 'timeout');
|
||||
@@ -144,18 +144,16 @@ function snmp_get($device, $oid, $options=null, $mib=null, $mibdir=null) {
|
||||
|
||||
if (is_string($data) && (preg_match('/(No Such Instance|No Such Object|No more variables left|Authentication failure)/i', $data))) {
|
||||
return false;
|
||||
}
|
||||
elseif ($data || $data === '0') {
|
||||
} elseif ($data || $data === '0') {
|
||||
return $data;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}//end snmp_get()
|
||||
|
||||
|
||||
function snmp_walk($device, $oid, $options=null, $mib=null, $mibdir=null) {
|
||||
function snmp_walk($device, $oid, $options = null, $mib = null, $mibdir = null)
|
||||
{
|
||||
global $debug,$config,$runtime_stats;
|
||||
|
||||
$timeout = prep_snmp_setting($device, 'timeout');
|
||||
@@ -167,8 +165,7 @@ function snmp_walk($device, $oid, $options=null, $mib=null, $mibdir=null) {
|
||||
|
||||
if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) {
|
||||
$snmpcommand = $config['snmpwalk'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$snmpcommand = $config['snmpbulkwalk'];
|
||||
$max_repeaters = $device['snmp_max_repeaters'];
|
||||
if ($max_repeaters > 0) {
|
||||
@@ -205,8 +202,7 @@ function snmp_walk($device, $oid, $options=null, $mib=null, $mibdir=null) {
|
||||
|
||||
if (is_string($data) && (preg_match('/No Such (Object|Instance)/i', $data))) {
|
||||
$data = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (preg_match('/No more variables left in this MIB View \(It is past the end of the MIB tree\)$/', $data)) {
|
||||
// Bit ugly :-(
|
||||
$d_ex = explode("\n", $data);
|
||||
@@ -218,11 +214,11 @@ function snmp_walk($device, $oid, $options=null, $mib=null, $mibdir=null) {
|
||||
$runtime_stats['snmpwalk']++;
|
||||
|
||||
return $data;
|
||||
|
||||
}//end snmp_walk()
|
||||
|
||||
|
||||
function snmpwalk_cache_cip($device, $oid, $array=array(), $mib=0) {
|
||||
function snmpwalk_cache_cip($device, $oid, $array = array(), $mib = 0)
|
||||
{
|
||||
global $config, $debug;
|
||||
|
||||
$timeout = prep_snmp_setting($device, 'timeout');
|
||||
@@ -234,8 +230,7 @@ function snmpwalk_cache_cip($device, $oid, $array=array(), $mib=0) {
|
||||
|
||||
if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) {
|
||||
$snmpcommand = $config['snmpwalk'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$snmpcommand = $config['snmpbulkwalk'];
|
||||
$max_repeaters = $device['snmp_max_repeaters'];
|
||||
if ($max_repeaters > 0) {
|
||||
@@ -281,8 +276,7 @@ function snmpwalk_cache_cip($device, $oid, $array=array(), $mib=0) {
|
||||
|
||||
if ($dir == '1') {
|
||||
$dir = 'input';
|
||||
}
|
||||
else if ($dir == '2') {
|
||||
} elseif ($dir == '2') {
|
||||
$dir = 'output';
|
||||
}
|
||||
|
||||
@@ -292,11 +286,11 @@ function snmpwalk_cache_cip($device, $oid, $array=array(), $mib=0) {
|
||||
}//end foreach
|
||||
|
||||
return $array;
|
||||
|
||||
}//end snmpwalk_cache_cip()
|
||||
|
||||
|
||||
function snmp_cache_ifIndex($device) {
|
||||
function snmp_cache_ifIndex($device)
|
||||
{
|
||||
// FIXME: this is not yet using our own snmp_*
|
||||
global $config, $debug;
|
||||
|
||||
@@ -309,8 +303,7 @@ function snmp_cache_ifIndex($device) {
|
||||
|
||||
if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) {
|
||||
$snmpcommand = $config['snmpwalk'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$snmpcommand = $config['snmpbulkwalk'];
|
||||
$max_repeaters = $device['snmp_max_repeaters'];
|
||||
if ($max_repeaters > 0) {
|
||||
@@ -347,11 +340,11 @@ function snmp_cache_ifIndex($device) {
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}//end snmp_cache_ifIndex()
|
||||
|
||||
|
||||
function snmpwalk_cache_oid($device, $oid, $array, $mib=null, $mibdir=null, $snmpflags='-OQUs') {
|
||||
function snmpwalk_cache_oid($device, $oid, $array, $mib = null, $mibdir = null, $snmpflags = '-OQUs')
|
||||
{
|
||||
$data = snmp_walk($device, $oid, $snmpflags, $mib, $mibdir);
|
||||
foreach (explode("\n", $data) as $entry) {
|
||||
list($oid,$value) = explode('=', $entry, 2);
|
||||
@@ -364,10 +357,10 @@ function snmpwalk_cache_oid($device, $oid, $array, $mib=null, $mibdir=null, $snm
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}//end snmpwalk_cache_oid()
|
||||
|
||||
function snmpwalk_cache_long_oid($device, $oid, $noid, $array, $mib=null, $mibdir=null, $snmpflags='-OQnU') {
|
||||
function snmpwalk_cache_long_oid($device, $oid, $noid, $array, $mib = null, $mibdir = null, $snmpflags = '-OQnU')
|
||||
{
|
||||
$data = snmp_walk($device, $oid, $snmpflags, $mib, $mibdir);
|
||||
foreach (explode("\n", $data) as $entry) {
|
||||
list($tmp_oid,$value) = explode('=', $entry, 2);
|
||||
@@ -384,7 +377,6 @@ function snmpwalk_cache_long_oid($device, $oid, $noid, $array, $mib=null, $mibdi
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}//end snmpwalk_cache_oid()
|
||||
|
||||
|
||||
@@ -392,13 +384,14 @@ function snmpwalk_cache_long_oid($device, $oid, $noid, $array, $mib=null, $mibdi
|
||||
// this is useful when the oid is indexed by the mac address and snmpwalk would
|
||||
// return periods (.) for non-printable numbers, thus making many different indexes appear
|
||||
// to be the same.
|
||||
function snmpwalk_cache_oid_num($device, $oid, $array, $mib=null, $mibdir=null) {
|
||||
function snmpwalk_cache_oid_num($device, $oid, $array, $mib = null, $mibdir = null)
|
||||
{
|
||||
return snmpwalk_cache_oid($device, $oid, $array, $mib, $mibdir, $snmpflags = '-OQUn');
|
||||
|
||||
}//end snmpwalk_cache_oid_num()
|
||||
|
||||
|
||||
function snmpwalk_cache_multi_oid($device, $oid, $array, $mib=null, $mibdir=null, $snmpflags='-OQUs') {
|
||||
function snmpwalk_cache_multi_oid($device, $oid, $array, $mib = null, $mibdir = null, $snmpflags = '-OQUs')
|
||||
{
|
||||
global $cache;
|
||||
|
||||
if (!(is_array($cache['snmp'][$device['device_id']]) && array_key_exists($oid, $cache['snmp'][$device['device_id']]))) {
|
||||
@@ -423,11 +416,11 @@ function snmpwalk_cache_multi_oid($device, $oid, $array, $mib=null, $mibdir=null
|
||||
}//end if
|
||||
|
||||
return $cache['snmp'][$device['device_id']][$oid];
|
||||
|
||||
}//end snmpwalk_cache_multi_oid()
|
||||
|
||||
|
||||
function snmpwalk_cache_double_oid($device, $oid, $array, $mib=null, $mibdir=null) {
|
||||
function snmpwalk_cache_double_oid($device, $oid, $array, $mib = null, $mibdir = null)
|
||||
{
|
||||
$data = snmp_walk($device, $oid, '-OQUs', $mib, $mibdir);
|
||||
|
||||
foreach (explode("\n", $data) as $entry) {
|
||||
@@ -442,11 +435,11 @@ function snmpwalk_cache_double_oid($device, $oid, $array, $mib=null, $mibdir=nul
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}//end snmpwalk_cache_double_oid()
|
||||
|
||||
|
||||
function snmpwalk_cache_triple_oid($device, $oid, $array, $mib=null, $mibdir=null) {
|
||||
function snmpwalk_cache_triple_oid($device, $oid, $array, $mib = null, $mibdir = null)
|
||||
{
|
||||
$data = snmp_walk($device, $oid, '-OQUs', $mib, $mibdir);
|
||||
|
||||
foreach (explode("\n", $data) as $entry) {
|
||||
@@ -461,11 +454,11 @@ function snmpwalk_cache_triple_oid($device, $oid, $array, $mib=null, $mibdir=nul
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}//end snmpwalk_cache_triple_oid()
|
||||
|
||||
|
||||
function snmpwalk_cache_twopart_oid($device, $oid, $array, $mib=0) {
|
||||
function snmpwalk_cache_twopart_oid($device, $oid, $array, $mib = 0)
|
||||
{
|
||||
global $config, $debug;
|
||||
|
||||
$timeout = prep_snmp_setting($device, 'timeout');
|
||||
@@ -477,8 +470,7 @@ function snmpwalk_cache_twopart_oid($device, $oid, $array, $mib=0) {
|
||||
|
||||
if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) {
|
||||
$snmpcommand = $config['snmpwalk'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$snmpcommand = $config['snmpbulkwalk'];
|
||||
$max_repeaters = $device['snmp_max_repeaters'];
|
||||
if ($max_repeaters > 0) {
|
||||
@@ -519,11 +511,11 @@ function snmpwalk_cache_twopart_oid($device, $oid, $array, $mib=0) {
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}//end snmpwalk_cache_twopart_oid()
|
||||
|
||||
|
||||
function snmpwalk_cache_threepart_oid($device, $oid, $array, $mib=0) {
|
||||
function snmpwalk_cache_threepart_oid($device, $oid, $array, $mib = 0)
|
||||
{
|
||||
global $config, $debug;
|
||||
|
||||
$timeout = prep_snmp_setting($device, 'timeout');
|
||||
@@ -535,8 +527,7 @@ function snmpwalk_cache_threepart_oid($device, $oid, $array, $mib=0) {
|
||||
|
||||
if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) {
|
||||
$snmpcommand = $config['snmpwalk'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$snmpcommand = $config['snmpbulkwalk'];
|
||||
$max_repeaters = $device['snmp_max_repeaters'];
|
||||
if ($max_repeaters > 0) {
|
||||
@@ -581,11 +572,11 @@ function snmpwalk_cache_threepart_oid($device, $oid, $array, $mib=0) {
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}//end snmpwalk_cache_threepart_oid()
|
||||
|
||||
|
||||
function snmp_cache_slotport_oid($oid, $device, $array, $mib=0) {
|
||||
function snmp_cache_slotport_oid($oid, $device, $array, $mib = 0)
|
||||
{
|
||||
global $config, $debug;
|
||||
|
||||
$timeout = prep_snmp_setting($device, 'timeout');
|
||||
@@ -597,8 +588,7 @@ function snmp_cache_slotport_oid($oid, $device, $array, $mib=0) {
|
||||
|
||||
if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) {
|
||||
$snmpcommand = $config['snmpwalk'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$snmpcommand = $config['snmpbulkwalk'];
|
||||
$max_repeaters = $device['snmp_max_repeaters'];
|
||||
if ($max_repeaters > 0) {
|
||||
@@ -639,18 +629,18 @@ function snmp_cache_slotport_oid($oid, $device, $array, $mib=0) {
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}//end snmp_cache_slotport_oid()
|
||||
|
||||
|
||||
function snmp_cache_oid($oid, $device, $array, $mib=0) {
|
||||
function snmp_cache_oid($oid, $device, $array, $mib = 0)
|
||||
{
|
||||
$array = snmpwalk_cache_oid($device, $oid, $array, $mib);
|
||||
return $array;
|
||||
|
||||
}//end snmp_cache_oid()
|
||||
|
||||
|
||||
function snmp_cache_port_oids($oids, $port, $device, $array, $mib=0) {
|
||||
function snmp_cache_port_oids($oids, $port, $device, $array, $mib = 0)
|
||||
{
|
||||
global $config, $debug;
|
||||
|
||||
$timeout = prep_snmp_setting($device, 'timeout');
|
||||
@@ -697,11 +687,11 @@ function snmp_cache_port_oids($oids, $port, $device, $array, $mib=0) {
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}//end snmp_cache_port_oids()
|
||||
|
||||
|
||||
function snmp_cache_portIfIndex($device, $array) {
|
||||
function snmp_cache_portIfIndex($device, $array)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$timeout = prep_snmp_setting($device, 'timeout');
|
||||
@@ -733,11 +723,11 @@ function snmp_cache_portIfIndex($device, $array) {
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}//end snmp_cache_portIfIndex()
|
||||
|
||||
|
||||
function snmp_cache_portName($device, $array) {
|
||||
function snmp_cache_portName($device, $array)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$timeout = prep_snmp_setting($device, 'timeout');
|
||||
@@ -772,52 +762,46 @@ function snmp_cache_portName($device, $array) {
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}//end snmp_cache_portName()
|
||||
|
||||
|
||||
function snmp_gen_auth(&$device) {
|
||||
function snmp_gen_auth(&$device)
|
||||
{
|
||||
global $debug, $vdebug;
|
||||
|
||||
$cmd = '';
|
||||
|
||||
if ($device['snmpver'] === 'v3') {
|
||||
|
||||
$cmd = " -v3 -n '' -l '".$device['authlevel']."'";
|
||||
|
||||
//add context if exist context
|
||||
if(key_exists('context_name', $device)){
|
||||
$cmd = " -v3 -n '".$device['context_name']."' -l '".$device['authlevel']."'";
|
||||
}
|
||||
|
||||
|
||||
//add context if exist context
|
||||
if (key_exists('context_name', $device)) {
|
||||
$cmd = " -v3 -n '".$device['context_name']."' -l '".$device['authlevel']."'";
|
||||
}
|
||||
|
||||
if ($device['authlevel'] === 'noAuthNoPriv') {
|
||||
// We have to provide a username anyway (see Net-SNMP doc)
|
||||
// FIXME: There are two other places this is set - why are they ignored here?
|
||||
$cmd .= ' -u root';
|
||||
}
|
||||
else if ($device['authlevel'] === 'authNoPriv') {
|
||||
} elseif ($device['authlevel'] === 'authNoPriv') {
|
||||
$cmd .= " -a '".$device['authalgo']."'";
|
||||
$cmd .= " -A '".$device['authpass']."'";
|
||||
$cmd .= " -u '".$device['authname']."'";
|
||||
}
|
||||
else if ($device['authlevel'] === 'authPriv') {
|
||||
} elseif ($device['authlevel'] === 'authPriv') {
|
||||
$cmd .= " -a '".$device['authalgo']."'";
|
||||
$cmd .= " -A '".$device['authpass']."'";
|
||||
$cmd .= " -u '".$device['authname']."'";
|
||||
$cmd .= " -x '".$device['cryptoalgo']."'";
|
||||
$cmd .= " -X '".$device['cryptopass']."'";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ($debug) {
|
||||
print 'DEBUG: '.$device['snmpver']." : Unsupported SNMPv3 AuthLevel (wtf have you done ?)\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($device['snmpver'] === 'v2c' or $device['snmpver'] === 'v1') {
|
||||
} elseif ($device['snmpver'] === 'v2c' or $device['snmpver'] === 'v1') {
|
||||
$cmd = " -".$device['snmpver'];
|
||||
$cmd .= " -c '".$device['community']."'";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ($debug) {
|
||||
print 'DEBUG: '.$device['snmpver']." : Unsupported SNMP Version (shouldn't be possible to get here)\n";
|
||||
}
|
||||
@@ -828,7 +812,6 @@ function snmp_gen_auth(&$device) {
|
||||
}
|
||||
|
||||
return $cmd;
|
||||
|
||||
}//end snmp_gen_auth()
|
||||
|
||||
|
||||
@@ -847,7 +830,8 @@ function snmp_gen_auth(&$device) {
|
||||
* ::= { iso(1) org(3) dod(6) internet(1) private(4) enterprises(1) ruckusRootMIB(25053) ruckusObjects(1) ruckusZD(2) ruckusZDSystemModule(1) ruckusZDSystemMIB(1) ruckusZDSystemObjects(1)
|
||||
* ruckusZDSystemStats(15) 30 }
|
||||
*/
|
||||
function snmp_mib_parse($oid, $mib, $module, $mibdir=null) {
|
||||
function snmp_mib_parse($oid, $mib, $module, $mibdir = null)
|
||||
{
|
||||
$fulloid = explode('.', $oid);
|
||||
$lastpart = end($fulloid);
|
||||
|
||||
@@ -909,8 +893,7 @@ function snmp_mib_parse($oid, $mib, $module, $mibdir=null) {
|
||||
if (isset($result['syntax']) && isset($result['object_type'])) {
|
||||
$result['mib'] = $mib;
|
||||
return $result;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} // snmp_mib_parse
|
||||
@@ -930,7 +913,7 @@ function snmp_mib_parse($oid, $mib, $module, $mibdir=null) {
|
||||
*/
|
||||
|
||||
|
||||
function snmp_mib_walk($mib, $module, $mibdir=null)
|
||||
function snmp_mib_walk($mib, $module, $mibdir = null)
|
||||
{
|
||||
$cmd = 'snmptranslate -Ts';
|
||||
$cmd .= mibdir($mibdir);
|
||||
@@ -948,7 +931,6 @@ function snmp_mib_walk($mib, $module, $mibdir=null)
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
} // snmp_mib_walk
|
||||
|
||||
|
||||
@@ -1014,7 +996,6 @@ function snmp_mib_load($mib, $module, $included_by, $mibdir = null)
|
||||
$columns = array('module', 'mib', 'object_type', 'oid', 'syntax', 'description', 'max_access', 'status', 'included_by');
|
||||
update_db_table('mibdefs', $columns, 3, $mibs);
|
||||
return count($mibs);
|
||||
|
||||
} // snmp_mib_load
|
||||
|
||||
|
||||
@@ -1053,7 +1034,6 @@ function snmp_translate($oid, $module, $mibdir = null)
|
||||
$matches[1],
|
||||
$matches[2],
|
||||
);
|
||||
|
||||
} // snmp_translate
|
||||
|
||||
|
||||
@@ -1068,26 +1048,25 @@ function oid_rrd_type($oid, $mibdef)
|
||||
}
|
||||
|
||||
switch ($mibdef[$oid]['syntax']) {
|
||||
case 'OCTET':
|
||||
case 'IpAddress':
|
||||
return false;
|
||||
case 'OCTET':
|
||||
case 'IpAddress':
|
||||
return false;
|
||||
|
||||
case 'TimeTicks':
|
||||
// FIXME
|
||||
return false;
|
||||
case 'TimeTicks':
|
||||
// FIXME
|
||||
return false;
|
||||
|
||||
case 'INTEGER':
|
||||
case 'Integer32':
|
||||
return 'GAUGE:600:U:U';
|
||||
case 'INTEGER':
|
||||
case 'Integer32':
|
||||
return 'GAUGE:600:U:U';
|
||||
|
||||
case 'Counter32':
|
||||
case 'Counter64':
|
||||
return 'COUNTER:600:0:U';
|
||||
|
||||
case 'Gauge32':
|
||||
case 'Unsigned32':
|
||||
return 'GAUGE:600:0:U';
|
||||
case 'Counter32':
|
||||
case 'Counter64':
|
||||
return 'COUNTER:600:0:U';
|
||||
|
||||
case 'Gauge32':
|
||||
case 'Unsigned32':
|
||||
return 'GAUGE:600:0:U';
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1108,7 +1087,6 @@ function tag_graphs($mibname, $oids, $mibdef, &$graphs)
|
||||
$graphs[$graphname] = true;
|
||||
}
|
||||
}
|
||||
|
||||
} // tag_graphs
|
||||
|
||||
|
||||
@@ -1219,8 +1197,7 @@ function load_mibdefs($module, $name)
|
||||
foreach ($result as $mib => $m) {
|
||||
if (strlen($prefix) > 2) {
|
||||
$result[$mib]['shortname'] = preg_replace("/^$prefix/", '', $m['object_type'], 1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$result[$mib]['shortname'] = $m['object_type'];
|
||||
}
|
||||
}
|
||||
@@ -1295,18 +1272,15 @@ function register_mibs($device, $mibs, $included_by)
|
||||
'included_by' => $included_by,
|
||||
);
|
||||
update_db_table('device_mibs', $columns, 3, $rows);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
d_echo("MIB: Could not load definition for $mod::$nam\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
d_echo("MIB: Could not find $module::$name\n");
|
||||
}
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
|
||||
} // register_mibs
|
||||
|
||||
/**
|
||||
@@ -1331,11 +1305,12 @@ function register_mibs($device, $mibs, $included_by)
|
||||
* @internal param $string
|
||||
* @return array
|
||||
*/
|
||||
function snmpwalk_array_num($device,$oid,$indexes=1) {
|
||||
function snmpwalk_array_num($device, $oid, $indexes = 1)
|
||||
{
|
||||
$array = array();
|
||||
$string = snmp_walk($device, $oid, '-Osqn');
|
||||
|
||||
if ( $string === false) {
|
||||
if ($string === false) {
|
||||
// False means: No Such Object.
|
||||
return false;
|
||||
}
|
||||
@@ -1348,7 +1323,7 @@ function snmpwalk_array_num($device,$oid,$indexes=1) {
|
||||
foreach (explode("\n", $string) as $line) {
|
||||
if ($line[0] == '.') {
|
||||
// strip the leading . if it exists.
|
||||
$line = substr($line,1);
|
||||
$line = substr($line, 1);
|
||||
}
|
||||
list($key, $value) = explode(' ', $line, 2);
|
||||
$prop_id = explode('.', $key);
|
||||
@@ -1359,17 +1334,17 @@ function snmpwalk_array_num($device,$oid,$indexes=1) {
|
||||
$indexes = count($prop_id)-1;
|
||||
}
|
||||
|
||||
for ($i=0;$i<$indexes;$i++) {
|
||||
for ($i=0; $i<$indexes; $i++) {
|
||||
// Pop the index off.
|
||||
$index = array_pop($prop_id);
|
||||
$value = array($index => $value);
|
||||
}
|
||||
|
||||
// Rebuild our key
|
||||
$key = implode('.',$prop_id);
|
||||
$key = implode('.', $prop_id);
|
||||
|
||||
// Add the entry to the master array
|
||||
$array = array_replace_recursive($array,array($key => $value));
|
||||
$array = array_replace_recursive($array, array($key => $value));
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
Reference in New Issue
Block a user