mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
clean up MAC change reporting, graph error size
git-svn-id: http://www.observium.org/svn/observer/trunk@1734 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -59,7 +59,7 @@ function graph_error ($string)
|
|||||||
{
|
{
|
||||||
global $width, $height;
|
global $width, $height;
|
||||||
header('Content-type: image/png');
|
header('Content-type: image/png');
|
||||||
if($height > "99") { $width +=76; }
|
if($height > "99") { $width +=75; }
|
||||||
$im = imagecreate($width, $height);
|
$im = imagecreate($width, $height);
|
||||||
$orange = imagecolorallocate($im, 255, 225, 225);
|
$orange = imagecolorallocate($im, 255, 225, 225);
|
||||||
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
|
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
|
||||||
|
|||||||
@@ -33,17 +33,20 @@
|
|||||||
$mac_table[$if][$mac]['cleanmac'] = $clean_mac;
|
$mac_table[$if][$mac]['cleanmac'] = $clean_mac;
|
||||||
$interface_id = $interface['interface_id'];
|
$interface_id = $interface['interface_id'];
|
||||||
$mac_table[$interface_id][$clean_mac] = 1;
|
$mac_table[$interface_id][$clean_mac] = 1;
|
||||||
if(mysql_result(mysql_query("SELECT COUNT(*) from ipv4_mac WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'"),0)) {
|
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'";
|
$sql = "UPDATE `ipv4_mac` SET `mac_address` = '$clean_mac' WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'";
|
||||||
$old_mac = mysql_fetch_row(mysql_query("SELECT mac_address from ipv4_mac WHERE ipv4_address='$ip' AND interface_id = '".$interface['interface_id']."'"));
|
$old_mac = mysql_fetch_row(mysql_query("SELECT mac_address from ipv4_mac WHERE ipv4_address='$ip' AND interface_id = '".$interface['interface_id']."'"));
|
||||||
if($clean_mac != $old_mac[0])
|
if($clean_mac != $old_mac[0] && $clean_mac != '' && $old_mac[0] != '')
|
||||||
{
|
{
|
||||||
if ($debug) { echo("Changed mac address for $ip from $old_mac[0] to $clean_mac\n"); }
|
if ($debug) { echo("Changed mac address for $ip from $old_mac[0] to $clean_mac\n"); }
|
||||||
log_event("MAC change: $ip : " . mac_clean_to_readable($old_mac[0]) . " -> " . mac_clean_to_readable($clean_mac), $device, "interface", $interface['interface_id']);
|
log_event("MAC change: $ip : " . mac_clean_to_readable($old_mac[0]) . " -> " . mac_clean_to_readable($clean_mac), $device, "interface", $interface['interface_id']);
|
||||||
}
|
}
|
||||||
mysql_query($sql);
|
mysql_query($sql);
|
||||||
echo(".");
|
echo(".");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
echo("+");
|
echo("+");
|
||||||
#echo("Add MAC $mac\n");
|
#echo("Add MAC $mac\n");
|
||||||
mysql_query("INSERT INTO `ipv4_mac` (interface_id, mac_address, ipv4_address) VALUES ('".$interface['interface_id']."','$clean_mac','$ip')");
|
mysql_query("INSERT INTO `ipv4_mac` (interface_id, mac_address, ipv4_address) VALUES ('".$interface['interface_id']."','$clean_mac','$ip')");
|
||||||
@@ -52,10 +55,12 @@
|
|||||||
}
|
}
|
||||||
$sql = "SELECT * from ipv4_mac AS M, ports as I WHERE M.interface_id = I.interface_id and I.device_id = '".$device['device_id']."'";
|
$sql = "SELECT * from ipv4_mac AS M, ports as I WHERE M.interface_id = I.interface_id and I.device_id = '".$device['device_id']."'";
|
||||||
$query = mysql_query($sql);
|
$query = mysql_query($sql);
|
||||||
while($entry = mysql_fetch_array($query)) {
|
while($entry = mysql_fetch_array($query))
|
||||||
|
{
|
||||||
$entry_mac = $entry['mac_address'];
|
$entry_mac = $entry['mac_address'];
|
||||||
$entry_if = $entry['interface_id'];
|
$entry_if = $entry['interface_id'];
|
||||||
if(!$mac_table[$entry_if][$entry_mac]) {
|
if(!$mac_table[$entry_if][$entry_mac])
|
||||||
|
{
|
||||||
mysql_query("DELETE FROM ipv4_mac WHERE interface_id = '".$entry_if."' AND mac_address = '".$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("-");
|
||||||
|
|||||||
@@ -90,4 +90,6 @@ unset($cip_array);
|
|||||||
|
|
||||||
if($mac_entries) { echo(" $mac_entries MAC accounting entries\n"); }
|
if($mac_entries) { echo(" $mac_entries MAC accounting entries\n"); }
|
||||||
|
|
||||||
|
echo("\n");
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user