updates to mac accounting drawing, adding mini-graphs to interface details pages

git-svn-id: http://www.observium.org/svn/observer/trunk@472 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-09-24 14:38:17 +00:00
parent 661d0935a3
commit 29f71ad13d
13 changed files with 1379 additions and 114 deletions

View File

@@ -2,11 +2,13 @@
unset ($mac_table);
echo("ARP Table : ");
$ipNetToMedia_data = shell_exec($config['snmpbulkwalk'] . " -m IP-MIB -Oq -".$device['snmpver']." -c ".$device['community']." ".$device['hostname']." ipNetToMediaPhysAddress");
$ipNetToMedia_data = str_replace("ipNetToMediaPhysAddress.", "", trim($ipNetToMedia_data));
$ipNetToMedia_data = str_replace("IP-MIB::", "", trim($ipNetToMedia_data));
echo("$ipNetToMedia_data\n");
echo("done\n");
#echo("$ipNetToMedia_data\n");
#echo("done\n");
foreach(explode("\n", $ipNetToMedia_data) as $data) {
list($oid, $mac) = explode(" ", $data);
list($if, $first, $second, $third, $fourth) = explode(".", $oid);
@@ -35,15 +37,14 @@
if(mysql_result(mysql_query("SELECT COUNT(*) from ipv4_mac WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'"),0)) {
$sql = "UPDATE `ipv4_mac` SET `mac_address` = '$clean_mac' WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'";
mysql_query($sql);
echo(".");
} else {
echo("+");
#echo("Add MAC $mac\n");
mysql_query("INSERT INTO `ipv4_mac` (interface_id, mac_address, ipv4_address) VALUES ('".$interface['interface_id']."','$clean_mac','$ip')");
}
$interface_id = $interface['interface_id'];
}
print_r($mac_table);
$sql = "SELECT * from ipv4_mac AS M, interfaces as I WHERE M.interface_id = I.interface_id and I.device_id = '".$device['device_id']."'";
$query = mysql_query($sql);
while($entry = mysql_fetch_array($query)) {
@@ -51,15 +52,20 @@
$entry_if = $entry['interface_id'];
if(!$mac_table[$entry_if][$entry_mac]) {
mysql_query("DELETE FROM ipv4_mac WHERE interface_id = '".$entry_if."' AND mac_address = '".$entry_mac."'");
echo("Removing MAC $entry_mac from interface ".$interface['ifName']);
#echo("Removing MAC $entry_mac from interface ".$interface['ifName']);
echo("-");
}
}
echo("\n");
unset($mac);
echo("MAC Accounting : ");
$datas = shell_exec($config['snmpbulkwalk'] . " -m CISCO-IP-STAT-MIB -Oqn -".$device['snmpver']." -c ".$device['community']." ".$device['hostname']." cipMacSwitchedBytes");
echo("$datas\n");
echo("done\n");
#echo("$datas\n");
#echo("done\n");
foreach(explode("\n", $datas) as $data) {
list($oid) = explode(" ", $data);
$oid = str_replace(".1.3.6.1.4.1.9.9.84.1.2.1.1.4.", "", $oid);
@@ -80,18 +86,22 @@
$ip = $mac_table[$if][$mac]['ip'];
if($ip && $interface) {
$new_mac = str_replace(":", "", $mac);
echo($interface['ifDescr'] . " ($if) -> $mac ($oid) -> $ip -> $name");
#echo($interface['ifDescr'] . " ($if) -> $mac ($oid) -> $ip");
if(mysql_result(mysql_query("SELECT COUNT(*) from mac_accounting WHERE interface_id = '".$interface['interface_id']."' AND mac = '$clean_mac'"),0)) {
#$sql = "UPDATE `mac_accounting` SET `mac` = '$clean_mac' WHERE interface_id = '".$interface['interface_id']."' AND `mac` = '$clean_mac'";
#mysql_query($sql);
#if(mysql_affected_rows()) { echo(" UPDATED!"); }
#echo($sql);
echo(".");
} else {
#echo(" Not Exists!");
mysql_query("INSERT INTO `mac_accounting` (interface_id, mac) VALUES ('".$interface['interface_id']."','$clean_mac')");
echo("+");
}
echo("\n");
#echo("\n");
}
}
echo("\n");
?>

View File

@@ -65,7 +65,7 @@
$sensor_data = shell_exec($sensor_cmd);
list($entSensorType,$entSensorScale,$entSensorPrecision,$entSensorValueUpdateRate,$entSensorMeasuredEntity) = explode("\n", $sensor_data);
if($entSensorMeasuredEntity) {
echo("M:$entSensorMeasuredEntity");
#echo("M:$entSensorMeasuredEntity");
}
if($config['allow_entity_sensor'][$entSensorType]) {
$sql = "UPDATE `entPhysical` SET entSensorType = '$entSensorType', entSensorScale = '$entSensorScale', entSensorPrecision = '$entSensorPrecision', ";

View File

@@ -580,6 +580,8 @@ function graph_bits ($rrd, $graph, $from, $to, $width, $height, $title, $vertica
$options .= $config['rrdgraph_def_text'];
if($height < "99") { $options .= " --only-graph"; unset ($legend); }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
global $_GET;
if($_GET['bg']) { $options .= " -c CANVAS#" . $_GET['bg'] . " "; }
if($inverse) {
$in = 'out';
$out = 'in';
@@ -655,6 +657,8 @@ function pktsgraph ($rrd, $graph, $from, $to, $width, $height) {
$options .= $config['rrdgraph_def_text'];
if($height < "99") { $options .= " --only-graph"; unset ($legend); }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
global $_GET;
if($_GET['bg']) { $options .= " -c CANVAS#" . $_GET['bg'] . " "; }
$options .= " DEF:in=$database:INUCASTPKTS:AVERAGE";
$options .= " DEF:out=$database:OUTUCASTPKTS:AVERAGE";
$options .= " CDEF:dout=out,-1,*";
@@ -710,6 +714,8 @@ function errorgraph ($rrd, $graph, $from, $to, $width, $height) {
$options .= $config['rrdgraph_def_text'];
if($height < "99") { $options .= " --only-graph"; unset ($legend); }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
global $_GET;
if($_GET['bg']) { $options .= " -c CANVAS#" . $_GET['bg'] . " "; }
$options .= " DEF:in=$database:INERRORS:AVERAGE";
$options .= " DEF:out=$database:OUTERRORS:AVERAGE";
$options .= " CDEF:dout=out,-1,*";
@@ -736,6 +742,8 @@ function nucastgraph ($rrd, $graph, $from, $to, $width, $height) {
$options .= $config['rrdgraph_def_text'];
if($height < "99") { $options .= " --only-graph"; unset ($legend); }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
global $_GET;
if($_GET['bg']) { $options .= " -c CANVAS#" . $_GET['bg'] . " "; }
$options .= " DEF:in=$database:INNUCASTPKTS:AVERAGE";
$options .= " DEF:out=$database:OUTNUCASTPKTS:AVERAGE";
$options .= " CDEF:dout=out,-1,*";