mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
code and formatting cleanups/small fixes
git-svn-id: http://www.observium.org/svn/observer/trunk@1771 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
if($device['os_group'] == "ios") {
|
||||
|
||||
if ($device['os_group'] == "ios")
|
||||
{
|
||||
echo("Cisco MAC Accounting : ");
|
||||
|
||||
$datas = shell_exec($config['snmpbulkwalk'] . " -M ".$config['mibdir']." -m CISCO-IP-STAT-MIB -Oqn -".$device['snmpver']." -c ".$device['community']." ".$device['hostname']." cipMacSwitchedBytes");
|
||||
@@ -44,10 +43,7 @@ if($device['os_group'] == "ios") {
|
||||
}
|
||||
}
|
||||
echo("\n");
|
||||
|
||||
}
|
||||
} # os_group=ios
|
||||
|
||||
// FIXME - NEEDS TO REMOVE STALE ENTRIES?? :O
|
||||
|
||||
|
||||
?>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
if($config['enable_pseudowires'] && $device['os_group'] == "ios") {
|
||||
|
||||
if($config['enable_pseudowires'] && $device['os_group'] == "ios")
|
||||
{
|
||||
unset( $cpw_count );
|
||||
unset( $cpw_exists );
|
||||
|
||||
@@ -12,21 +12,28 @@ if($config['enable_pseudowires'] && $device['os_group'] == "ios") {
|
||||
$oids = str_replace(".1.3.6.1.4.1.9.10.106.1.2.1.10.", "", $oids);
|
||||
|
||||
$oids = trim($oids);
|
||||
foreach ( explode("\n", $oids) as $oid ) {
|
||||
if($oid) {
|
||||
foreach ( explode("\n", $oids) as $oid )
|
||||
{
|
||||
if($oid)
|
||||
{
|
||||
list($cpwOid, $cpwVcID) = explode(" ", $oid);
|
||||
if($cpwOid) {
|
||||
if($cpwOid)
|
||||
{
|
||||
list($cpw_remote_id) = split(":", shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m CISCO-IETF-PW-MPLS-MIB -Ln -Osqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcMplsPeerLdpID." . $cpwOid));
|
||||
$interface_descr = trim(shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -m CISCO-IETF-PW-MIB -Oqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcName." . $cpwOid));
|
||||
$cpw_remote_device = @mysql_result(mysql_query("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '".$cpw_remote_id."' AND A.interface_id = I.interface_id"),0);
|
||||
$if_id = @mysql_result(mysql_query("SELECT `interface_id` FROM `ports` WHERE `ifDescr` = '$interface_descr' AND `device_id` = '".$device['device_id']."'"),0);
|
||||
if($cpw_remote_device && $if_id) {
|
||||
if($cpw_remote_device && $if_id)
|
||||
{
|
||||
$hostname = gethostbyid($cpw_remote_device);
|
||||
#echo("\nOid: " . $cpwOid . " cpwVcID: " . $cpwVcID . " Remote Id: " . $cpw_remote_id . "($hostname(".$cpw_remote_device.") -> $interface_descr($if_id))");
|
||||
if(mysql_result(mysql_query("SELECT count(*) FROM pseudowires WHERE `interface_id` = '$if_id'
|
||||
AND `cpwVcID`='".$cpwVcID."'"),0)) {
|
||||
AND `cpwVcID`='".$cpwVcID."'"),0))
|
||||
{
|
||||
echo(".");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$insert_query = "INSERT INTO `pseudowires` (`interface_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid`) ";
|
||||
$insert_query .= "VALUES ('$if_id','$cpw_remote_device','$cpw_remote_id','$cpwVcID', '$cpwOid')";
|
||||
mysql_query($insert_query);
|
||||
@@ -42,17 +49,20 @@ if($config['enable_pseudowires'] && $device['os_group'] == "ios") {
|
||||
$sql = "SELECT * FROM pseudowires AS P, ports AS I, devices as D WHERE P.interface_id = I.interface_id AND I.device_id = D.device_id AND D.device_id = '".$device['device_id']."'";
|
||||
$query = mysql_query($sql);
|
||||
|
||||
while ($cpw = mysql_fetch_array($query)) {
|
||||
while ($cpw = mysql_fetch_array($query))
|
||||
{
|
||||
unset($exists);
|
||||
$i = 0;
|
||||
while ($i < count($cpw_exists) && !$exists) {
|
||||
while ($i < count($cpw_exists) && !$exists)
|
||||
{
|
||||
$this_cpw = $cpw['device_id'] . " " . $cpw['cpwOid'] . " " . $cpw['peer_device_id'] . " " . $cpw['interface_id'] . " " . $cpw['cpwVcID'];
|
||||
if ($cpw_exists[$i] == $this_cpw) { $exists = 1;
|
||||
# echo($cpw_exists[$i]. " || $this_cpw \n");
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
if(!$exists) {
|
||||
if(!$exists)
|
||||
{
|
||||
echo("-");
|
||||
# echo($this_cpw . "\n");
|
||||
mysql_query("DELETE FROM pseudowires WHERE pseudowire_id = '" . $cpw['pseudowire_id'] . "'");
|
||||
@@ -61,6 +71,6 @@ if($config['enable_pseudowires'] && $device['os_group'] == "ios") {
|
||||
|
||||
echo("\n");
|
||||
|
||||
}
|
||||
} # enable_pseudowires + os_group=ios
|
||||
|
||||
?>
|
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
if($device['os_group'] == "ios") {
|
||||
|
||||
if($device['os_group'] == "ios")
|
||||
{
|
||||
echo("Cisco VLANs : ");
|
||||
|
||||
$vtpversion_cmd = $config['snmpget'] . " -M " . $config['mibdir'] . " -m CISCO-VTP-MIB -Oqv -" . $device['snmpver'] . " -c " . $device['community'] . " ";
|
||||
@@ -60,3 +60,4 @@ if($device['os_group'] == "ios") {
|
||||
echo("\n");
|
||||
|
||||
}
|
||||
?>
|
@@ -17,23 +17,29 @@ if($device['os_group'] == "ios" || $device['os_group'] == "junos" || $device['os
|
||||
$oids = str_replace("\"", "", $oids);
|
||||
|
||||
$oids = trim($oids);
|
||||
foreach ( explode("\n", $oids) as $oid ) {
|
||||
if($oid) {
|
||||
foreach ( explode("\n", $oids) as $oid )
|
||||
{
|
||||
if($oid)
|
||||
{
|
||||
list($vrf['oid'], $vrf['mplsVpnVrfRouteDistinguisher']) = explode("||", $oid);
|
||||
$vrf['name'] = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m MPLS-VPN-MIB -Ln -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfRouteDistinguisher.".$vrf['oid']));
|
||||
list(,$vrf['name'],, $vrf['mplsVpnVrfRouteDistinguisher']) = explode("\"", $vrf['name']);
|
||||
$vrf['mplsVpnVrfDescription'] = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m MPLS-VPN-MIB -Ln -Osqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfDescription.".$vrf['oid']));
|
||||
|
||||
if(@mysql_result(mysql_query("SELECT count(*) FROM vrfs WHERE `device_id` = '".$device['device_id']."'
|
||||
AND `vrf_oid`='".$vrf['oid']."'"),0)) {
|
||||
AND `vrf_oid`='".$vrf['oid']."'"),0))
|
||||
{
|
||||
$update_query = "UPDATE `vrfs` SET `mplsVpnVrfDescription` = '".$vrf['mplsVpnVrfDescription']."', `mplsVpnVrfRouteDistinguisher` = '".$vrf['mplsVpnVrfRouteDistinguisher']."' ";
|
||||
$update_query .= "WHERE device_id = '".$device['device_id']."' AND vrf_oid = '".$vrf['oid']."'";
|
||||
mysql_query($update_query);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$insert_query = "INSERT INTO `vrfs` (`vrf_oid`,`vrf_name`,`mplsVpnVrfRouteDistinguisher`,`mplsVpnVrfDescription`,`device_id`) ";
|
||||
$insert_query .= "VALUES ('".$vrf['oid']."','".$vrf['name']."','".$vrf['mplsVpnVrfRouteDistinguisher']."','".$vrf['mplsVpnVrfDescription']."','".$device['device_id']."')";
|
||||
mysql_query($insert_query);
|
||||
}
|
||||
|
||||
$vrf_id = @mysql_result(mysql_query("SELECT vrf_id FROM vrfs WHERE `device_id` = '".$device['device_id']."' AND `vrf_oid`='".$vrf['oid']."'"),0);
|
||||
$valid_vrf[$vrf_id] = 1;
|
||||
echo("\nRD:".$vrf['mplsVpnVrfRouteDistinguisher']." ".$vrf['name']." ".$vrf['mplsVpnVrfDescription']." ");
|
||||
@@ -42,7 +48,8 @@ if($device['os_group'] == "ios" || $device['os_group'] == "junos" || $device['os
|
||||
$ports = trim(str_replace($ports_oid . ".", "", $ports));
|
||||
# list($ports) = explode(" ", $ports);
|
||||
echo(" ( ");
|
||||
foreach (explode("\n", $ports) as $if_id) {
|
||||
foreach (explode("\n", $ports) as $if_id)
|
||||
{
|
||||
$interface = mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE ifIndex = '$if_id' AND device_id = '" . $device['device_id'] . "'"));
|
||||
echo(makeshortif($interface['ifDescr']) . " ");
|
||||
mysql_query("UPDATE ports SET ifVrf = '".$vrf_id."' WHERE interface_id = '".$interface['interface_id']."'");
|
||||
@@ -55,23 +62,34 @@ if($device['os_group'] == "ios" || $device['os_group'] == "junos" || $device['os
|
||||
|
||||
$sql = "SELECT * FROM ports WHERE device_id = '" . $device['device_id'] . "'";
|
||||
$data = mysql_query($sql);
|
||||
while($row = mysql_fetch_array($data)) {
|
||||
while($row = mysql_fetch_array($data))
|
||||
{
|
||||
$if = $row['interface_id'];
|
||||
$vrf_id = $row['ifVrf'];
|
||||
if($row['ifVrf']){ if(!$valid_vrf_if[$vrf_id][$if]) {
|
||||
if($row['ifVrf'])
|
||||
{
|
||||
if(!$valid_vrf_if[$vrf_id][$if])
|
||||
{
|
||||
echo("-");
|
||||
$query = @mysql_query("UPDATE ports SET `ifVrf` = NULL WHERE interface_id = '$if'");
|
||||
} else {echo(".");} }
|
||||
}
|
||||
else
|
||||
{
|
||||
echo(".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM vrfs WHERE device_id = '" . $device['device_id'] . "'";
|
||||
$data = mysql_query($sql);
|
||||
while($row = mysql_fetch_array($data)) {
|
||||
while($row = mysql_fetch_array($data))
|
||||
{
|
||||
$vrf_id = $row['vrf_id'];
|
||||
if(!$valid_vrf[$vrf_id]) {
|
||||
if(!$valid_vrf[$vrf_id])
|
||||
{
|
||||
echo("-");
|
||||
$query = @mysql_query("DELETE FROM vrfs WHERE vrf_id = '$vrf_id'");
|
||||
} else {echo(".");}
|
||||
} else { echo(".");}
|
||||
}
|
||||
|
||||
unset($valid_vrf_if);
|
||||
@@ -79,6 +97,6 @@ if($device['os_group'] == "ios" || $device['os_group'] == "junos" || $device['os
|
||||
|
||||
echo("\n");
|
||||
|
||||
}
|
||||
} # ios/junos/ironware
|
||||
|
||||
?>
|
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
if($config['discover_services']){
|
||||
|
||||
if ($config['discover_services'])
|
||||
{
|
||||
$id = $device['device_id'];
|
||||
$hostname = $device['hostname'];
|
||||
$community = $device['community'];
|
||||
|
@@ -60,4 +60,3 @@ if ($config['enable_printers'])
|
||||
|
||||
} # if ($config['enable_printers'])
|
||||
?>
|
||||
|
@@ -1,14 +1,16 @@
|
||||
<?php
|
||||
|
||||
echo("UCD Disk IO : ");
|
||||
$diskio_array = snmpwalk_cache_oid($device, "diskIOEntry", array(), "UCD-DISKIO-MIB" , "+".$config['install_dir']."/mibs/");
|
||||
$valid_diskio = array();
|
||||
echo("UCD Disk IO : ");
|
||||
$diskio_array = snmpwalk_cache_oid($device, "diskIOEntry", array(), "UCD-DISKIO-MIB" , "+".$config['install_dir']."/mibs/");
|
||||
$valid_diskio = array();
|
||||
# if($debug) { print_r($diskio_array); }
|
||||
|
||||
if(is_array($diskio_array)) {
|
||||
foreach($diskio_array as $index => $entry) {
|
||||
|
||||
if($entry['diskIONRead'] > "0" || $entry['diskIONWritten'] > "0") {
|
||||
if (is_array($diskio_array))
|
||||
{
|
||||
foreach ($diskio_array as $index => $entry)
|
||||
{
|
||||
if($entry['diskIONRead'] > "0" || $entry['diskIONWritten'] > "0")
|
||||
{
|
||||
if ($debug) { echo("$index ".$entry['diskIODevice']."\n"); }
|
||||
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ucd_diskio` WHERE `device_id` = '".$device['device_id']."' AND `diskio_index` = '".$index."'"),0) == "0")
|
||||
@@ -27,26 +29,24 @@
|
||||
|
||||
} ## end validity check
|
||||
} ## end array foreach
|
||||
} ## End array if
|
||||
|
||||
} ## End array if
|
||||
|
||||
### Remove diskio entries which weren't redetected here
|
||||
|
||||
$sql = "SELECT * FROM `ucd_diskio` where `device_id` = '".$device['device_id']."'";
|
||||
$query = mysql_query($sql);
|
||||
$sql = "SELECT * FROM `ucd_diskio` where `device_id` = '".$device['device_id']."'";
|
||||
$query = mysql_query($sql);
|
||||
|
||||
if($debug) { print_r ($valid_vp); }
|
||||
if($debug) { print_r ($valid_diskio); }
|
||||
|
||||
while ($test = mysql_fetch_array($query)) {
|
||||
while ($test = mysql_fetch_array($query)) {
|
||||
if($debug) { echo($test['diskio_index'] . " -> " . $test['diskio_descr'] . "\n"); }
|
||||
if(!$valid_diskio[$test['diskio_index']]) {
|
||||
echo("-");
|
||||
mysql_query("DELETE FROM `ucd_diskio` WHERE `diskio_id` = '" . $test['diskio_id'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
unset($valid_diskio);
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
unset($valid_diskio);
|
||||
echo("\n");
|
||||
|
||||
?>
|
||||
|
@@ -701,7 +701,7 @@ function isHexString($str)
|
||||
# Include all .inc.php files in $dir
|
||||
function include_dir($dir, $regex = "")
|
||||
{
|
||||
global $device, $config;
|
||||
global $device, $config, $debug;
|
||||
if ( $regex == "")
|
||||
{
|
||||
$regex = "/\.inc\.php$/";
|
||||
@@ -713,6 +713,7 @@ function include_dir($dir, $regex = "")
|
||||
{
|
||||
if (filetype($config['install_dir'] . '/' . $dir . '/' . $file) == 'file' && preg_match($regex, $file))
|
||||
{
|
||||
if ($debug) { echo("Including: " . $config['install_dir'] . '/' . $dir . '/' . $file . "\n"); }
|
||||
include($config['install_dir'] . '/' . $dir . '/' . $file);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user