git-svn-id: http://www.observium.org/svn/observer/trunk@2340 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-05-17 19:21:20 +00:00
parent 0846a7cc60
commit 1b956853ad
23 changed files with 384 additions and 227 deletions

View File

@@ -13,12 +13,18 @@ function get_percentage_colours($percentage)
}
function generate_device_url($device, $linksuffix="")
{
return "device/" . $device['device_id'] . "/" . $linksuffix;
}
function generate_device_link($device, $text=0, $linksuffix="", $start=0, $end=0)
{
global $twoday, $day, $now, $config;
global $config;
if (!$start) { $start = $config['time']['day']; }
if (!$end) { $end = $config['time']['now']; }
if (!$start) { $start = $day; }
if (!$end) { $end = $now; }
$class = devclass($device);
if (!$text) { $text = $device['hostname']; }
@@ -35,7 +41,7 @@ function generate_device_link($device, $text=0, $linksuffix="", $start=0, $end=0
$graphs = $config['os']['default']['over'];
}
$url = "device/" . $device['device_id'] . "/" . $linksuffix;
$url = generate_device_url($device, $linksuffix);
$contents = "<div class=list-large>".$device['hostname'];
if ($device['hardware']) { $contents .= " - ".$device['hardware']; }
$contents .= "</div>";
@@ -55,7 +61,7 @@ function generate_device_link($device, $text=0, $linksuffix="", $start=0, $end=0
$contents .= '<div style="width: 708px">';
$contents .= '<span style="margin-left: 5px; font-size: 12px; font-weight: bold;">'.$graphhead.'</span><br />';
$contents .= "<img src=\"graph.php?id=" . $device['device_id'] . "&amp;from=$start&amp;to=$end&amp;width=275&amp;height=100&amp;type=$graph&amp;legend=no" . '" style="margin: 2px;">';
$contents .= "<img src=\"graph.php?id=" . $device['device_id'] . "&amp;from=".$config['week']."&amp;to=$end&amp;width=275&amp;height=100&amp;type=$graph&amp;legend=no" . '" style="margin: 2px;">';
$contents .= "<img src=\"graph.php?id=" . $device['device_id'] . "&amp;from=".$config['time']['week']."&amp;to=$end&amp;width=275&amp;height=100&amp;type=$graph&amp;legend=no" . '" style="margin: 2px;">';
$contents .= '</div>';
}
@@ -95,13 +101,13 @@ function generate_graph_popup($graph_array)
$graph_array['legend'] = "yes";
$graph_array['height'] = "100";
$graph_array['width'] = "340";
$graph_array['from'] = $config['day'];
$graph_array['from'] = $config['time']['day'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['week'];
$graph_array['from'] = $config['time']['week'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['month'];
$graph_array['from'] = $config['time']['month'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['year'];
$graph_array['from'] = $config['time']['year'];
$content .= generate_graph_tag($graph_array);
$content .= "</div>";
@@ -236,7 +242,7 @@ function print_percentage_bar($width, $height, $percent, $left_text, $left_colou
function generate_port_link($args, $text = NULL, $type = NULL)
{
global $twoday, $now, $config, $day, $month;
global $config;
$args = ifNameDescr($args);
if (!$text) { $text = fixIfName($args['label']); }
@@ -253,19 +259,19 @@ function generate_port_link($args, $text = NULL, $type = NULL)
$graph_array['legend'] = "yes";
$graph_array['height'] = "100";
$graph_array['width'] = "340";
$graph_array['to'] = $config['now'];
$graph_array['from'] = $config['day'];
$graph_array['to'] = $config['time']['now'];
$graph_array['from'] = $config['time']['day'];
$graph_array['id'] = $args['interface_id'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['week'];
$graph_array['from'] = $config['time']['week'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['month'];
$graph_array['from'] = $config['time']['month'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['year'];
$graph_array['from'] = $config['time']['year'];
$content .= generate_graph_tag($graph_array);
$content .= "</div>";
$url = "device/".$args['device_id']."/port/" . $args['interface_id'] . "/";
$url = generate_port_url($args);
if (port_permitted($args['interface_id'])) {
return overlib_link($url, $text, $content, $class);
@@ -274,6 +280,10 @@ function generate_port_link($args, $text = NULL, $type = NULL)
}
}
function generate_port_url($args) {
return $url = "device/".$args['device_id']."/port/" . $args['interface_id'] . "/";
}
function generate_port_thumbnail($args)
{
if (!$args['bg']) { $args['bg'] = "FFFFF"; }

View File

@@ -35,7 +35,7 @@ if ($port_details)
echo("$break <a class=interface-desc href=\"javascript:popUp('netcmd.php?cmd=whois&amp;query=".$ip['ipv4_address']."')\">".$ip['ipv4_address']."/".$ip['ipv4_prefixlen']."</a>");
$break = ",";
}
foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = ?", array($interface['interface_id']) as $ip6);
foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = ?", array($interface['interface_id'])) as $ip6);
{
echo("$break <a class=interface-desc href=\"javascript:popUp('netcmd.php?cmd=whois&amp;query=".$ip6['ipv6_address']."')\">".Net_IPv6::compress($ip6['ipv6_address'])."/".$ip6['ipv6_prefixlen']."</a>");
$break = ",";
@@ -44,48 +44,48 @@ if ($port_details)
echo("</span>");
$width="120"; $height="40"; $from = $day;
$width="120"; $height="40"; $from = $config['time']['day'];
echo("</td><td width=135>");
echo(formatRates($interface['ifInOctets_rate'] * 8)." <img class='optionicon' src='images/icons/arrow_updown.png' /> ".formatRates($interface['ifOutOctets_rate'] * 8));
echo("<br />");
$interface['graph_type'] = "port_bits";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".formatRates($interface['adslAturChanCurrTxRate']) . "/". formatRates($interface['adslAtucChanCurrTxRate']));
echo("<br />");
$interface['graph_type'] = "port_adsl_speed";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".formatRates($interface['adslAturCurrAttainableRate']) . "/". formatRates($interface['adslAtucCurrAttainableRate']));
echo("<br />");
$interface['graph_type'] = "port_adsl_attainable";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".$interface['adslAturCurrAtn'] . "dB/". $interface['adslAtucCurrAtn'] . "dB");
echo("<br />");
$interface['graph_type'] = "port_adsl_attenuation";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".$interface['adslAturCurrSnrMgn'] . "dB/". $interface['adslAtucCurrSnrMgn'] . "dB");
echo("<br />");
$interface['graph_type'] = "port_adsl_snr";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".$interface['adslAturCurrOutputPwr'] . "dBm/". $interface['adslAtucCurrOutputPwr'] . "dBm");
echo("<br />");
$interface['graph_type'] = "port_adsl_power";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
# if ($interface[ifDuplex] != unknown) { echo("<span class=box-desc>Duplex " . $interface['ifDuplex'] . "</span>"); } else { echo("-"); }
@@ -103,41 +103,4 @@ str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td>");
if ($graph_type == "etherlike")
{
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/etherlike-". safename($interface['ifIndex']) . ".rrd";
} else {
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/". safename($interface['ifIndex']) . ".rrd";
}
if ($graph_type && is_file($graph_file))
{
$type = $graph_type;
$daily_traffic = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$from&amp;to=$now&amp;width=210&amp;height=100";
$daily_url = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$from&amp;to=$now&amp;width=500&amp;height=150";
$weekly_traffic = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$week&amp;to=$now&amp;width=210&amp;height=100";
$weekly_url = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$monthly_traffic = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$month&amp;to=$now&amp;width=210&amp;height=100";
$monthly_url = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$month&amp;to=$now&amp;width=500&amp;height=150";
$yearly_traffic = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$year&amp;to=$now&amp;width=210&amp;height=100";
$yearly_url = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$year&amp;to=$now&amp;width=500&amp;height=150";
echo("<tr style='background-color: $bg; padding: 5px;'><td colspan=7>");
echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\"
onmouseout=\"return nd();\"> <img src='$daily_traffic' border=0></a>");
echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT".$config['overlib_defaults'].");\"
onmouseout=\"return nd();\"> <img src='$weekly_traffic' border=0></a>");
echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT, WIDTH, 350".$config['overlib_defaults'].");\"
onmouseout=\"return nd();\"> <img src='$monthly_traffic' border=0></a>");
echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT, WIDTH, 350".$config['overlib_defaults'].");\"
onmouseout=\"return nd();\"> <img src='$yearly_traffic' border=0></a>");
echo("</td></tr>");
}
?>

View File

@@ -4,10 +4,10 @@ global $config;
$graph_array['height'] = "100";
$graph_array['width'] = "215";
$graph_array['to'] = $now;
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $interface['interface_id'];
$graph_array['type'] = $graph_type;
include("includes/print-quadgraphs.inc.php");
?>
?>

View File

@@ -59,11 +59,11 @@ echo("</td><td width=100>");
if ($port_details)
{
$interface['graph_type'] = "port_bits";
echo(generate_port_link($interface, "<img src='graph.php?type=port_bits&amp;id=".$interface['interface_id']."&amp;from=".$day."&amp;to=".$now."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
echo(generate_port_link($interface, "<img src='graph.php?type=port_bits&amp;id=".$interface['interface_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
$interface['graph_type'] = "port_upkts";
echo(generate_port_link($interface, "<img src='graph.php?type=port_upkts&amp;id=".$interface['interface_id']."&amp;from=".$day."&amp;to=".$now."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
echo(generate_port_link($interface, "<img src='graph.php?type=port_upkts&amp;id=".$interface['interface_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
$interface['graph_type'] = "port_errors";
echo(generate_port_link($interface, "<img src='graph.php?type=port_errors&amp;id=".$interface['interface_id']."&amp;from=".$day."&amp;to=".$now."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
echo(generate_port_link($interface, "<img src='graph.php?type=port_errors&amp;id=".$interface['interface_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
}
echo("</td><td width=120>");
@@ -259,31 +259,10 @@ if ($graph_type && is_file($graph_file))
{
$type = $graph_type;
$daily_traffic = "graph.php?id=$if_id&amp;type=" . $graph_type . "&amp;from=$day&amp;to=$now&amp;width=210&amp;height=100";
$daily_url = "graph.php?id=$if_id&amp;type=" . $graph_type . "&amp;from=$day&amp;to=$now&amp;width=500&amp;height=150";
$weekly_traffic = "graph.php?id=$if_id&amp;type=" . $graph_type . "&amp;from=$week&amp;to=$now&amp;width=210&amp;height=100";
$weekly_url = "graph.php?id=$if_id&amp;type=" . $graph_type . "&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$monthly_traffic = "graph.php?id=$if_id&amp;type=" . $graph_type . "&amp;from=$month&amp;to=$now&amp;width=210&amp;height=100";
$monthly_url = "graph.php?id=$if_id&amp;type=" . $graph_type . "&amp;from=$month&amp;to=$now&amp;width=500&amp;height=150";
$yearly_traffic = "graph.php?id=$if_id&amp;type=" . $graph_type . "&amp;from=$year&amp;to=$now&amp;width=210&amp;height=100";
$yearly_url = "graph.php?id=$if_id&amp;type=" . $graph_type . "&amp;from=$year&amp;to=$now&amp;width=500&amp;height=150";
echo("<tr style='background-color: $bg; padding: 5px;'><td colspan=7>");
echo("<tr style='background-color: $row_colour; padding: 0px;'><td colspan=7>");
include("includes/print-interface-graphs.inc.php");
# echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\"
# onmouseout=\"return nd();\"> <img src='$daily_traffic' border=0></a>");
# echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT".$config['overlib_defaults'].");\"
# onmouseout=\"return nd();\"> <img src='$weekly_traffic' border=0></a>");
# echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT, WIDTH, 350".$config['overlib_defaults'].");\"
# onmouseout=\"return nd();\"> <img src='$monthly_traffic' border=0></a>");
# echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT, WIDTH, 350".$config['overlib_defaults'].");\"
# onmouseout=\"return nd();\"> <img src='$yearly_traffic' border=0></a>");
echo("</td></tr>");
}

View File

@@ -1,7 +1,7 @@
<?php
$service_alerts = dbFetchCell("SELECT COUNT(service_id) FROM services WHERE service_status = '0'");
$if_alerts = dbFetchCell("SELECT count(*) FROM `ports` WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND `ignore` = '0'");
$if_alerts = dbFetchCell("SELECT COUNT(interface_id) FROM `ports` WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND `ignore` = '0'");
$device_alerts = "0";
$device_alert_sql = "WHERE 0";
@@ -16,8 +16,11 @@ foreach (dbFetchRows("SELECT * FROM `devices`") as $device)
$this_alert = 0;
if ($device['status'] == 0 && $device['ignore'] == '0') { $this_alert = "1"; } elseif ($device['ignore'] == '0')
{
if (dbFetchCell("SELECT count(service_id) FROM services WHERE service_status = '0' AND device_id = ?", array($device['device_id']))) { $this_alert = "1"; }
if (dbFetchCell("SELECT count(*) FROM ports WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND device_id = ? AND `ignore` = '0'", array($device['device_id']))) { $this_alert = "1"; }
## sluggish. maybe we cache this at poll-time?
# if (dbFetchCell("SELECT count(service_id) FROM services WHERE service_status = '0' AND device_id = ?", array($device['device_id']))) { $this_alert = "1"; }
# if (dbFetchCell("SELECT count(*) FROM ports WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND device_id = ? AND `ignore` = '0'", array($device['device_id']))) { $this_alert = "1"; }
}
if ($this_alert)
{

View File

@@ -5,18 +5,18 @@ global $config;
if(!$graph_array['height']) { $graph_array['height'] = "100"; }
if(!$graph_array['width']) { $graph_array['width'] = "215"; }
$graph_array['to'] = $now;
$graph_array['to'] = $config['time']['now'];
$periods = array('day', 'week', 'month', 'year');
foreach ($periods as $period)
{
$graph_array['from'] = $config[$period];
$graph_array['from'] = $config['time'][$period];
$graph_array_zoom = $graph_array;
$graph_array_zoom['height'] = "150";
$graph_array_zoom['width'] = "400";
$link = "graphs/" . $graph_array['id'] . "/" . $graph_array['type'] . "/" . $graph_array['from'] . "/" . $config['now'] . "/";
$link = "graphs/" . $graph_array['id'] . "/" . $graph_array['type'] . "/" . $graph_array['from'] . "/" . $config['to'] . "/";
echo(overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL));
}

View File

@@ -23,10 +23,10 @@ if ($service['service_checked'])
$checked = formatUptime($checked);
} else { $checked = "Never"; }
$mini_url = "graph.php?id=".$service['service_id']."&amp;type=service_availability&amp;from=".$day."&amp;to=".$now."&amp;width=80&amp;height=20&amp;bg=efefef";
$mini_url = "graph.php?id=".$service['service_id']."&amp;type=service_availability&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=80&amp;height=20&amp;bg=efefef";
$popup = "onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$service['service_type'];
$popup .= "</div><img src=\'graph.php?id=" . $service['service_id'] . "&amp;type=service_availability&amp;from=$day&amp;to=$now&amp;width=400&amp;height=125\'>";
$popup .= "</div><img src=\'graph.php?id=" . $service['service_id'] . "&amp;type=service_availability&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=400&amp;height=125\'>";
$popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"";
echo("
@@ -59,4 +59,4 @@ echo("
$i++;
?>
?>