cleanups to how graphing works. start using device= for device graphs.

git-svn-id: http://www.observium.org/svn/observer/trunk@3167 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2012-05-11 13:26:14 +00:00
parent 62c302b960
commit d52042ba47
75 changed files with 226 additions and 194 deletions

View File

@@ -38,25 +38,24 @@ echo('
$graphs = $config['os']['default']['over']; $graphs = $config['os']['default']['over'];
} }
$graph_array = array();
$graph_array['height'] = "100"; $graph_array['height'] = "100";
$graph_array['width'] = "310"; $graph_array['width'] = "310";
$graph_array['to'] = $config['time']['now']; $graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $device['device_id']; $graph_array['device'] = $device['device_id'];
$graph_array['type'] = "device_bits"; $graph_array['type'] = "device_bits";
$graph_array['from'] = $config['time']['day']; $graph_array['from'] = $config['time']['day'];
$graph_array['legend'] = "no"; $graph_array['legend'] = "no";
$graph_array['popup_title'] = $descr; $graph_array['popup_title'] = $descr;
# $graph_array['link'] = generate_device_link($device_id);
# print_graph_popup($graph_array);
$graph_array['height'] = "45"; $graph_array['height'] = "45";
$graph_array['width'] = "150"; $graph_array['width'] = "150";
$graph_array['bg'] = "FFFFFF00"; $graph_array['bg'] = "FFFFFF00";
foreach ($graphs as $entry) foreach ($graphs as $entry)
{ {
$graph_array['type'] = $entry['graph']; $graph_array['type'] = $entry['graph'];
$graphhead = $entry['text'];
echo("<div style='float: right; text-align: center; padding: 1px 5px; margin: 0 1px; background: #f5f5f5;' class='rounded-5px'>"); echo("<div style='float: right; text-align: center; padding: 1px 5px; margin: 0 1px; background: #f5f5f5;' class='rounded-5px'>");
print_graph_popup($graph_array); print_graph_popup($graph_array);

View File

@@ -117,8 +117,8 @@ function generate_device_link($device, $text=NULL, $vars=array(), $start=0, $end
$graphhead = $entry['text']; $graphhead = $entry['text'];
$contents .= '<div style="width: 708px">'; $contents .= '<div style="width: 708px">';
$contents .= '<span style="margin-left: 5px; font-size: 12px; font-weight: bold;">'.$graphhead.'</span><br />'; $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?device=" . $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['time']['week']."&amp;to=$end&amp;width=275&amp;height=100&amp;type=$graph&amp;legend=no" . '" style="margin: 2px;">'; $contents .= "<img src=\"graph.php?device=" . $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>'; $contents .= '</div>';
} }
@@ -169,7 +169,9 @@ function generate_graph_popup($graph_array)
$content .= generate_graph_tag($graph_array); $content .= generate_graph_tag($graph_array);
$content .= "</div>"; $content .= "</div>";
$graph_array['link'] = "graphs/type=" . $graph_array['type'] . "/id=" . $graph_array['id']; $graph_array['link'] = generate_url($graph_array, array('page' => 'graphs', 'height' => NULL, 'width' => NULL, 'bg' => NULL));
# $graph_array['link'] = "graphs/type=" . $graph_array['type'] . "/id=" . $graph_array['id'];
return overlib_link($graph_array['link'], $graph, $content, NULL); return overlib_link($graph_array['link'], $graph, $content, NULL);
} }

View File

@@ -1,12 +1,12 @@
<?php <?php
if (is_numeric($id) && ($config['allow_unauth_graphs'] || application_permitted($id))) if (is_numeric($vars['id']) && ($config['allow_unauth_graphs'] || application_permitted($vars['id'])))
{ {
$app = get_application_by_id($id); $app = get_application_by_id($vars['id']);
$device = device_by_id_cache($app['device_id']); $device = device_by_id_cache($app['device_id']);
$title = generate_device_link($device); $title = generate_device_link($device);
$title .= $graph_subtype; $title .= $graph_subtype;
$auth = TRUE; $auth = TRUE;
} }
?> ?>

View File

@@ -1,9 +1,8 @@
<?php <?php
include("memcached.inc.php"); include("memcached.inc.php");
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id); $device = device_by_id_cache($vars['id']);
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");

View File

@@ -5,7 +5,7 @@ $scale_min = "0";
include("memcached.inc.php"); include("memcached.inc.php");
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id); $device = device_by_id_cache($vars['id']);
$rrd_options .= " DEF:uptime=".$rrd_filename.":uptime:AVERAGE"; $rrd_options .= " DEF:uptime=".$rrd_filename.":uptime:AVERAGE";
$rrd_options .= " CDEF:cuptime=uptime,86400,/"; $rrd_options .= " CDEF:cuptime=uptime,86400,/";

View File

@@ -1,5 +1,7 @@
<?php <?php
$device = device_by_id_cache($vars['id']);
$units = "b"; $units = "b";
$total_units = "B"; $total_units = "B";
$colours_in = "greens"; $colours_in = "greens";

View File

@@ -1,5 +1,7 @@
<?php <?php
$device = device_by_id_cache($vars['id']);
//$colour = "random"; //$colour = "random";
$unit_text = "ShoutCast Server"; $unit_text = "ShoutCast Server";
$total_text = "Total of all ShoutCast Servers"; $total_text = "Total of all ShoutCast Servers";

View File

@@ -1,9 +1,9 @@
<?php <?php
if (is_numeric($id)) if (is_numeric($vars['id']))
{ {
$data = dbFetchRow("SELECT * FROM bgpPeers WHERE bgpPeer_id = ?", array($id)); $data = dbFetchRow("SELECT * FROM bgpPeers WHERE bgpPeer_id = ?", array($vars['id']));
if (is_numeric($data['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($data['device_id']))) if (is_numeric($data['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($data['device_id'])))
{ {

View File

@@ -1,8 +1,8 @@
<?php <?php
if (is_numeric($id)) if (is_numeric($vars['id']))
{ {
$cef = dbFetchRow("SELECT * FROM `cef_switching` AS C, `devices` AS D WHERE C.cef_switching_id = ? AND C.device_id = D.device_id", array($id)); $cef = dbFetchRow("SELECT * FROM `cef_switching` AS C, `devices` AS D WHERE C.cef_switching_id = ? AND C.device_id = D.device_id", array($vars['id']));
if (is_numeric($cef['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($cef['device_id']))) if (is_numeric($cef['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($cef['device_id'])))
{ {

View File

@@ -1,10 +1,12 @@
<?php <?php
## FIXME - wtfbbq
if ($_SESSION['userlevel'] >= "5" || $config['allow_unauth_graphs']) if ($_SESSION['userlevel'] >= "5" || $config['allow_unauth_graphs'])
{ {
$id = mres($_GET['id']); $id = mres($vars['id']);
$title = generate_device_link($device); $title = generate_device_link($device);
$auth = TRUE; $auth = TRUE;
} }
?> ?>

View File

@@ -2,7 +2,7 @@
## Generate a list of ports and then call the multi_bits grapher to generate from the list ## Generate a list of ports and then call the multi_bits grapher to generate from the list
$i=0; $i=0;
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ? AND D.device_id = I.device_id", array($id)) as $port) foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ? AND D.device_id = I.device_id", array($vars['id'])) as $port)
{ {
if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"))) if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd")))
{ {

View File

@@ -1,8 +1,7 @@
<?php <?php
if (is_numeric($id) && ($config['allow_unauth_graphs'] || device_permitted($id))) if ($config['allow_unauth_graphs'] || device_permitted($device['device_id']))
{ {
$device = device_by_id_cache($id);
$title = generate_device_link($device); $title = generate_device_link($device);
$graph_title = $device['hostname']; $graph_title = $device['hostname'];
$auth = TRUE; $auth = TRUE;

View File

@@ -5,9 +5,7 @@
$ds_in = "INOCTETS"; $ds_in = "INOCTETS";
$ds_out = "OUTOCTETS"; $ds_out = "OUTOCTETS";
$device = device_by_id_cache($id); foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ?", array($device['device_id'])) as $port)
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ?", array($id)) as $port)
{ {
$ignore = 0; $ignore = 0;
if (is_array($config['device_traffic_iftype'])) if (is_array($config['device_traffic_iftype']))

View File

@@ -4,8 +4,6 @@ $scale_min = "0";
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cras_sessions.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cras_sessions.rrd";
$rrd_options .= " DEF:email=$rrd_filename:email:AVERAGE"; $rrd_options .= " DEF:email=$rrd_filename:email:AVERAGE";
@@ -48,4 +46,4 @@ $rrd_options .= " GPRINT:lb:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:lb:AVERAGE:\ %6.2lf%s"; $rrd_options .= " GPRINT:lb:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:lb:MAX:\ %6.2lf%s\\\\n"; $rrd_options .= " GPRINT:lb:MAX:\ %6.2lf%s\\\\n";
?> ?>

View File

@@ -2,7 +2,7 @@
$i = 1; $i = 1;
foreach (dbFetchRows("SELECT * FROM `ucd_diskio` AS U, `devices` AS D WHERE D.device_id = ? AND U.device_id = D.device_id", array($id)) as $disk) foreach (dbFetchRows("SELECT * FROM `ucd_diskio` AS U, `devices` AS D WHERE D.device_id = ? AND U.device_id = D.device_id", array($device['device_id'])) as $disk)
{ {
$rrd_filename = $config['rrd_dir'] . "/" . $disk['hostname'] . "/ucd_diskio-" . safename($disk['diskio_descr'] . ".rrd"); $rrd_filename = $config['rrd_dir'] . "/" . $disk['hostname'] . "/ucd_diskio-" . safename($disk['diskio_descr'] . ".rrd");
if (is_file($rrd_filename)) if (is_file($rrd_filename))

View File

@@ -2,8 +2,6 @@
$scale_min = "0"; $scale_min = "0";
include("includes/graphs/common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_processes.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_processes.rrd";
$ds = "procs"; $ds = "procs";

View File

@@ -2,8 +2,6 @@
$scale_min = "0"; $scale_min = "0";
include("includes/graphs/common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_users.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_users.rrd";
$ds = "users"; $ds = "users";

View File

@@ -2,8 +2,6 @@
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_filename_4 = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv4.rrd"; $rrd_filename_4 = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv4.rrd";
$rrd_filename_6 = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv6.rrd"; $rrd_filename_6 = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv6.rrd";

View File

@@ -2,8 +2,6 @@
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv4.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv4.rrd";
$rrd_options .= " DEF:InForwDatagrams=$rrd_filename:InForwDatagrams:AVERAGE"; $rrd_options .= " DEF:InForwDatagrams=$rrd_filename:InForwDatagrams:AVERAGE";
@@ -50,4 +48,4 @@ $rrd_options .= " GPRINT:OutForwDatagrams:MAX:%6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:InReceives#9DaB6B:"; $rrd_options .= " LINE1.25:InReceives#9DaB6B:";
$rrd_options .= " LINE1.25:OutRequests_n#93a6eF:"; $rrd_options .= " LINE1.25:OutRequests_n#93a6eF:";
?> ?>

View File

@@ -2,8 +2,6 @@
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv4.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv4.rrd";
$rrd_options .= " DEF:ipInDelivers=$rrd_filename:InDelivers:AVERAGE"; $rrd_options .= " DEF:ipInDelivers=$rrd_filename:InDelivers:AVERAGE";

View File

@@ -2,8 +2,6 @@
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv6.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv6.rrd";
$rrd_options .= " DEF:InForwDatagrams=$rrd_filename:InForwDatagrams:AVERAGE"; $rrd_options .= " DEF:InForwDatagrams=$rrd_filename:InForwDatagrams:AVERAGE";
@@ -50,4 +48,4 @@ $rrd_options .= " GPRINT:OutForwDatagrams:MAX:%6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:InReceives#9DaB6B:"; $rrd_options .= " LINE1.25:InReceives#9DaB6B:";
$rrd_options .= " LINE1.25:OutRequests_n#93a6eF:"; $rrd_options .= " LINE1.25:OutRequests_n#93a6eF:";
?> ?>

View File

@@ -2,8 +2,6 @@
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv6.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv6.rrd";
$rrd_options .= " DEF:ipInDelivers=$rrd_filename:InDelivers:AVERAGE"; $rrd_options .= " DEF:ipInDelivers=$rrd_filename:InDelivers:AVERAGE";
@@ -62,4 +60,4 @@ $rrd_options .= " GPRINT:ReasmReqds:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:ReasmReqds:AVERAGE:%6.2lf%s"; $rrd_options .= " GPRINT:ReasmReqds:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:MReasmReqds:MAX:%6.2lf%s\\\\n"; $rrd_options .= " GPRINT:MReasmReqds:MAX:%6.2lf%s\\\\n";
?> ?>

View File

@@ -1,7 +1,5 @@
<?php <?php
$device = device_by_id_cache($id);
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$rrd_options .= " -u 100 -l 0 -E -b 1024 "; $rrd_options .= " -u 100 -l 0 -E -b 1024 ";
@@ -9,7 +7,7 @@ $rrd_options .= " -u 100 -l 0 -E -b 1024 ";
$iter = "1"; $i=1; $iter = "1"; $i=1;
$rrd_options .= " COMMENT:' Min Cur Max\\n'"; $rrd_options .= " COMMENT:' Min Cur Max\\n'";
foreach (dbFetchRows("SELECT * FROM `mempools` where `device_id` = ?", array($id)) as $mempool) foreach (dbFetchRows("SELECT * FROM `mempools` where `device_id` = ?", array($device['device_id'])) as $mempool)
{ {
# FIXME generic colour function # FIXME generic colour function
if ($iter=="1") { $colour="CC0000"; } elseif ($iter=="2") { $colour="008C00"; } elseif ($iter=="3") { $colour="4096EE"; } if ($iter=="1") { $colour="CC0000"; } elseif ($iter=="2") { $colour="008C00"; } elseif ($iter=="3") { $colour="4096EE"; }

View File

@@ -1,6 +1,5 @@
<?php <?php
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-icmp.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-icmp.rrd";

View File

@@ -1,6 +1,5 @@
<?php <?php
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-icmp.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-icmp.rrd";

View File

@@ -1,6 +1,5 @@
<?php <?php
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-ip.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-ip.rrd";

View File

@@ -2,7 +2,6 @@
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-ip.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-ip.rrd";

View File

@@ -1,6 +1,5 @@
<?php <?php
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-snmp.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-snmp.rrd";

View File

@@ -1,6 +1,5 @@
<?php <?php
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-tcp.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-tcp.rrd";

View File

@@ -1,6 +1,5 @@
<?php <?php
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-udp.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-udp.rrd";

View File

@@ -1,4 +1,5 @@
<?php <?php
$dsdescr = "Packets/s "; $dsdescr = "Packets/s ";
$dsprefix = "packets_"; $dsprefix = "packets_";

View File

@@ -1,4 +1,5 @@
<?php <?php
$dsdescr = "Byts/s "; $dsdescr = "Byts/s ";
$dsprefix = "traffic_"; $dsprefix = "traffic_";

View File

@@ -2,8 +2,6 @@
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("panos-sessions.rrd"); $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("panos-sessions.rrd");
include("includes/graphs/common.inc.php");
$ds = "sessions"; $ds = "sessions";
$colour_area = "9999cc"; $colour_area = "9999cc";

View File

@@ -1,7 +1,6 @@
<?php <?php
$device = device_by_id_cache($id); $procs = dbFetchRows("SELECT * FROM `processors` where `device_id` = ?", array($device['device_id']));
$procs = dbFetchRows("SELECT * FROM `processors` where `device_id` = ?", array($id));
if($config['os'][$device['os']]['processor_stacked'] == 1) if($config['os'][$device['os']]['processor_stacked'] == 1)
{ {

View File

@@ -1,8 +1,5 @@
<?php <?php
#$device = device_by_id_cache($id);
include("includes/graphs/common.inc.php");
$file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("screenos_sessions.rrd"); $file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("screenos_sessions.rrd");
@@ -27,4 +24,4 @@ $scale_min = "0";
include("includes/graphs/generic_multi_line.inc.php"); include("includes/graphs/generic_multi_line.inc.php");
?> ?>

View File

@@ -2,7 +2,6 @@
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
if ($_GET['width'] > "300") { $descr_len = "40"; } else { $descr_len = "22"; } if ($_GET['width'] > "300") { $descr_len = "40"; } else { $descr_len = "22"; }
@@ -10,7 +9,7 @@ $rrd_options .= " -l 0 -E ";
$iter = "1"; $iter = "1";
$rrd_options .= " COMMENT:'".str_pad($unit_long,$descr_len)." Cur Min Max\\n'"; $rrd_options .= " COMMENT:'".str_pad($unit_long,$descr_len)." Cur Min Max\\n'";
foreach (dbFetchRows("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_index`", array($class, $id)) as $sensor) foreach (dbFetchRows("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_index`", array($class, $device['device_id'])) as $sensor)
{ {
# FIXME generic colour function # FIXME generic colour function
switch ($iter) switch ($iter)

View File

@@ -2,7 +2,9 @@
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$sla = dbFetchRow("SELECT * FROM `slas` WHERE `sla_id` = ?", array($id)); ### FIXME - THIS IS BROKEN
$sla = dbFetchRow("SELECT * FROM `slas` WHERE `sla_id` = ?", array($vars['id']));
$device = device_by_id_cache($sla['device_id']); $device = device_by_id_cache($sla['device_id']);
#if ($_GET['width'] >= "450") { $descr_len = "48"; } else { $descr_len = "21"; } #if ($_GET['width'] >= "450") { $descr_len = "48"; } else { $descr_len = "21"; }

View File

@@ -5,12 +5,10 @@ $scale_max = "100";
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$iter = "1"; $iter = "1";
$rrd_options .= " COMMENT:' Size Used %age\\l'"; $rrd_options .= " COMMENT:' Size Used %age\\l'";
foreach (dbFetchRows("SELECT * FROM storage where device_id = ?", array($id)) as $storage) foreach (dbFetchRows("SELECT * FROM storage where device_id = ?", array($device['device_id'])) as $storage)
{ {
# FIXME generic colour function # FIXME generic colour function
if ($iter=="1") { $colour="CC0000"; } elseif ($iter=="2") { $colour="008C00"; } elseif ($iter=="3") { $colour="4096EE"; } if ($iter=="1") { $colour="CC0000"; } elseif ($iter=="2") { $colour="008C00"; } elseif ($iter=="3") { $colour="4096EE"; }

View File

@@ -2,13 +2,12 @@
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_options .= " -l 0 -E "; $rrd_options .= " -l 0 -E ";
$iter = "1"; $iter = "1";
$rrd_options .= " COMMENT:'Toner level Cur Min Max\\n'"; $rrd_options .= " COMMENT:'Toner level Cur Min Max\\n'";
foreach (dbFetchRows("SELECT * FROM toner where device_id = ?", array($id)) as $toner) foreach (dbFetchRows("SELECT * FROM toner where device_id = ?", array($device['device_id'])) as $toner)
{ {
$colour = toner2colour($toner['toner_descr']); $colour = toner2colour($toner['toner_descr']);

View File

@@ -4,8 +4,6 @@ $scale_min = "0";
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ucd_load.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ucd_load.rrd";
$rrd_options .= " DEF:1min=$rrd_filename:1min:AVERAGE"; $rrd_options .= " DEF:1min=$rrd_filename:1min:AVERAGE";

View File

@@ -2,8 +2,6 @@
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ucd_mem.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ucd_mem.rrd";
$rrd_options .= " '-b 1024'"; $rrd_options .= " '-b 1024'";
@@ -38,7 +36,6 @@ $rrd_options .= " 'CDEF:shared_perc=shared,totalreal,/,100,*'";
$rrd_options .= " 'CDEF:buffered_perc=buffered,totalreal,/,100,*'"; $rrd_options .= " 'CDEF:buffered_perc=buffered,totalreal,/,100,*'";
$rrd_options .= " 'CDEF:cached_perc=cached,totalreal,/,100,*'"; $rrd_options .= " 'CDEF:cached_perc=cached,totalreal,/,100,*'";
$rrd_options .= " 'CDEF:cusedswap=usedswap,-1,*'"; $rrd_options .= " 'CDEF:cusedswap=usedswap,-1,*'";
$rrd_options .= " 'CDEF:cdeftot=availreal,shared,buffered,usedreal,cached,usedswap,+,+,+,+,+'"; $rrd_options .= " 'CDEF:cdeftot=availreal,shared,buffered,usedreal,cached,usedswap,+,+,+,+,+'";
$rrd_options .= " 'COMMENT:Bytes Current Average Maximum\\n'"; $rrd_options .= " 'COMMENT:Bytes Current Average Maximum\\n'";

View File

@@ -4,7 +4,6 @@ $scale_min = "0";
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/uptime.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/uptime.rrd";

View File

@@ -2,7 +2,6 @@
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/vpdn-l2tp.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/vpdn-l2tp.rrd";

View File

@@ -2,7 +2,6 @@
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/vpdn-l2tp.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/vpdn-l2tp.rrd";

View File

@@ -2,7 +2,6 @@
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");
$device = device_by_id_cache($id);
$rrd_options .= " -l 0 -E "; $rrd_options .= " -l 0 -E ";

View File

@@ -1,8 +1,8 @@
<?php <?php
if (is_numeric($id)) if (is_numeric($vars['id']))
{ {
$disk = dbFetchRow("SELECT * FROM `ucd_diskio` AS U, `devices` AS D WHERE U.diskio_id = ? AND U.device_id = D.device_id", array($id)); $disk = dbFetchRow("SELECT * FROM `ucd_diskio` AS U, `devices` AS D WHERE U.diskio_id = ? AND U.device_id = D.device_id", array($vars['id']));
if (is_numeric($disk['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($disk['device_id']))) if (is_numeric($disk['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($disk['device_id'])))
{ {

View File

@@ -2,20 +2,37 @@
function data_uri($file, $mime) function data_uri($file, $mime)
{ {
$contents = file_get_contents($file); $contents = filevars_contents($file);
$base64 = base64_encode($contents); $base64 = base64_encode($contents);
return ('data:' . $mime . ';base64,' . $base64); return ('data:' . $mime . ';base64,' . $base64);
} }
$width = $_GET['width']; // Push $_GET into $vars to be compatible with web interface naming
$height = $_GET['height'];
$title = $_GET['title'];
$vertical = $_GET['vertical'];
$legend = $_GET['legend'];
$id = $_GET['id'];
$from = (isset($_GET['from']) ? $_GET['from'] : time() - 60*60*24); foreach ($_GET as $name => $value)
$to = (isset($_GET['to']) ? $_GET['to'] : time()); {
$vars[$name] = $value;
}
preg_match('/^(?P<type>[A-Za-z0-9]+)_(?P<subtype>.+)/', $vars['type'], $graphtype);
if(is_numeric($vars['device']))
{
$device = device_by_id_cache($vars['device']);
} elseif(!empty($vars['device'])) {
$device = device_by_name($vars['device']);
}
## FIXME -- remove these
$width = $vars['width'];
$height = $vars['height'];
$title = $vars['title'];
$vertical = $vars['vertical'];
$legend = $vars['legend'];
$from = (isset($vars['from']) ? $vars['from'] : time() - 60*60*24);
$to = (isset($vars['to']) ? $vars['to'] : time());
if ($from < 0) { $from = $to + $from; } if ($from < 0) { $from = $to + $from; }
@@ -25,8 +42,6 @@ $prev_from = $from - $period;
$graphfile = $config['temp_dir'] . "/" . strgen() . ".png"; $graphfile = $config['temp_dir'] . "/" . strgen() . ".png";
preg_match('/^(?P<type>[A-Za-z0-9]+)_(?P<subtype>.+)/', $_GET['type'], $graphtype);
$type = $graphtype['type']; $type = $graphtype['type'];
$subtype = $graphtype['subtype']; $subtype = $graphtype['subtype'];
@@ -58,9 +73,9 @@ else
function graph_error($string) function graph_error($string)
{ {
global $_GET, $config, $debug, $graphfile; global $vars, $config, $debug, $graphfile;
$_GET['bg'] = "FFBBBB"; $vars['bg'] = "FFBBBB";
include("includes/graphs/common.inc.php"); include("includes/graphs/common.inc.php");

View File

@@ -1,9 +1,8 @@
<?php <?php
if (is_numeric($id)) if (is_numeric($vars['id']))
{ {
$tunnel = dbFetchRow("SELECT * FROM `ipsec_tunnels` AS I, `devices` AS D WHERE I.tunnel_id = ? AND I.device_id = D.device_id", array($vars['id']));
$tunnel = dbFetchRow("SELECT * FROM `ipsec_tunnels` AS I, `devices` AS D WHERE I.tunnel_id = ? AND I.device_id = D.device_id", array($id));
if (is_numeric($tunnel['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($tunnel['device_id']))) if (is_numeric($tunnel['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($tunnel['device_id'])))
{ {

View File

@@ -1,11 +1,11 @@
<?php <?php
foreach (dbFetchRows("SELECT * FROM `devices` WHERE `location` = ?", array($id)) as $device) foreach (dbFetchRows("SELECT * FROM `devices` WHERE `location` = ?", array($vars['id'])) as $device)
{ {
if ($config['allow_unauth_graphs'] || device_permitted($device_id)) if ($config['allow_unauth_graphs'] || device_permitted($device_id))
{ {
$devices[] = $device; $devices[] = $device;
$title = $id; $title = $vars['id'];
$auth = TRUE; $auth = TRUE;
} }
} }

View File

@@ -1,9 +1,9 @@
<?php <?php
if (is_numeric($id)) if (is_numeric($vars['id']))
{ {
$acc = dbFetchRow("SELECT * FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.ma_id = ? AND I.interface_id = M.interface_id AND I.device_id = D.device_id", array($id)); $acc = dbFetchRow("SELECT * FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.ma_id = ? AND I.interface_id = M.interface_id AND I.device_id = D.device_id", array($vars['id']));
if ($debug) { if ($debug) {
echo("<pre>"); echo("<pre>");

View File

@@ -1,8 +1,8 @@
<?php <?php
if (is_numeric($id)) if (is_numeric($vars['id']))
{ {
$mempool = dbFetchRow("SELECT * FROM `mempools` AS C, `devices` AS D where C.`mempool_id` = ? AND C.device_id = D.device_id", array($id)); $mempool = dbFetchRow("SELECT * FROM `mempools` AS C, `devices` AS D where C.`mempool_id` = ? AND C.device_id = D.device_id", array($vars['id']));
if (is_numeric($mempool['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($mempool['device_id']))) if (is_numeric($mempool['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($mempool['device_id'])))
{ {

View File

@@ -2,14 +2,14 @@
$auth = TRUE; $auth = TRUE;
foreach (explode(",", $id) as $ifid) foreach (explode(",", $vars['id']) as $ifid)
{ {
if (!$config['allow_unauth_graphs'] && !port_permitted($ifid)) if (!$config['allow_unauth_graphs'] && !port_permitted($ifid))
$auth = FALSE; $auth = FALSE;
} }
#if (is_numeric($id)) { #if (is_numeric($vars['id'])) {
# $port = get_port_by_id($id); # $port = get_port_by_id($vars['id']);
# $device = device_by_id_cache($port['device_id']); # $device = device_by_id_cache($port['device_id']);
#} #}
@@ -18,4 +18,4 @@ foreach (explode(",", $id) as $ifid)
$title = "Multi Port :: "; $title = "Multi Port :: ";
?> ?>

View File

@@ -2,7 +2,7 @@
$i = 1; $i = 1;
foreach (explode(",", $id) as $ifid) foreach (explode(",", $vars['id']) as $ifid)
{ {
if (strstr($ifid, "!")) if (strstr($ifid, "!"))
{ {

View File

@@ -2,7 +2,7 @@
$i = 0; $i = 0;
foreach (explode(",", $id) as $ifid) foreach (explode(",", $vars['id']) as $ifid)
{ {
$port = dbFetchRow("SELECT * FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid)); $port = dbFetchRow("SELECT * FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid));
if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"))) if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd")))

View File

@@ -1,23 +1,20 @@
<?php <?php
if (is_numeric($id)) if(is_numeric($vars['plugin']))
{ {
$mplug = dbFetchRow("SELECT * FROM `munin_plugins` WHERE `mplug_id` = ?", array($id)); $mplug = dbFetchRow("SELECT * FROM `munin_plugins` AS M, `devices` AS D WHERE `mplug_id` = ? AND D.device_id = M.device_id ", array($vars['plugin']));
} else {
$mplug = dbFetchRow("SELECT * FROM `munin_plugins` AS M, `devices` AS D WHERE M.`device_id` = ? AND `mplug_type` = ? AND D.device_id = M.device_id", array($device['device_id'], $vars['plugin']));
}
if (is_numeric($mplug['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($mplug['device_id']))) if (is_numeric($mplug['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($mplug['device_id'])))
{ {
$device = device_by_id_cache($mplug['device_id']); $device = &$mplug;
$title = generate_device_link($device); $title = generate_device_link($device);
# if (!empty($mplug['mplug_instance'])) $plugfile = $config['rrd_dir']."/".$device['hostname']."/munin/".$mplug['mplug_type'];
# { $title .= " :: Plugin :: " . $mplug['mplug_type'] . " - " . $mplug['mplug_title'];
# $plugfile = $config['rrd_dir']."/".$device['hostname']."/munin/".$mplug['mplug_type']."_".$mplug['mplug_instance'];
# $title .= " :: Plugin :: " . $mplug['mplug_type'] . " :: " . $mplug['mplug_title'];
# } else {
$plugfile = $config['rrd_dir']."/".$device['hostname']."/munin/".$mplug['mplug_type'];
$title .= " :: Plugin :: " . $mplug['mplug_type'] . " - " . $mplug['mplug_title'];
# }
$auth = TRUE; $auth = TRUE;
} }
}
?> ?>

View File

@@ -1,9 +1,9 @@
<?php <?php
if (is_numeric($id)) if (is_numeric($vars['id']))
{ {
$vsvr = dbFetchRow("SELECT * FROM `netscaler_vservers` AS I, `devices` AS D WHERE I.vsvr_id = ? AND I.device_id = D.device_id", array($id)); $vsvr = dbFetchRow("SELECT * FROM `netscaler_vservers` AS I, `devices` AS D WHERE I.vsvr_id = ? AND I.device_id = D.device_id", array($vars['id']));
if (is_numeric($vsvr['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($vsvr['device_id']))) if (is_numeric($vsvr['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($vsvr['device_id'])))
{ {

View File

@@ -1,8 +1,8 @@
<?php <?php
if (is_numeric($id) && ($config['allow_unauth_graphs'] || port_permitted($id))) if (is_numeric($vars['id']) && ($config['allow_unauth_graphs'] || port_permitted($vars['id'])))
{ {
$port = get_port_by_id($id); $port = get_port_by_id($vars['id']);
$device = device_by_id_cache($port['device_id']); $device = device_by_id_cache($port['device_id']);
$title = generate_device_link($device); $title = generate_device_link($device);
$title .= " :: Port ".generate_port_link($port); $title .= " :: Port ".generate_port_link($port);

View File

@@ -1,6 +1,6 @@
<?php <?php
$proc = dbFetchRow("SELECT * FROM `processors` where `processor_id` = ?", array($id)); $proc = dbFetchRow("SELECT * FROM `processors` where `processor_id` = ?", array($vars['id']));
if (is_numeric($proc['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($proc['device_id']))) if (is_numeric($proc['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($proc['device_id'])))
{ {

View File

@@ -1,9 +1,9 @@
<?php <?php
if (is_numeric($id)) if (is_numeric($vars['id']))
{ {
# $auth= TRUE; # $auth= TRUE;
$rserver = dbFetchRow("SELECT * FROM `loadbalancer_rservers` AS I, `devices` AS D WHERE I.rserver_id = ? AND I.device_id = D.device_id", array($id)); $rserver = dbFetchRow("SELECT * FROM `loadbalancer_rservers` AS I, `devices` AS D WHERE I.rserver_id = ? AND I.device_id = D.device_id", array($vars['id']));
if (is_numeric($rserver['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($rserver['device_id']))) if (is_numeric($rserver['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($rserver['device_id'])))
{ {

View File

@@ -1,8 +1,8 @@
<?php <?php
if (is_numeric($id)) if (is_numeric($vars['id']))
{ {
$sensor = dbFetchRow("SELECT * FROM sensors WHERE sensor_id = ?", array($id)); $sensor = dbFetchRow("SELECT * FROM sensors WHERE sensor_id = ?", array($vars['id']));
if (is_numeric($sensor['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($sensor['device_id']))) if (is_numeric($sensor['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($sensor['device_id'])))
{ {

View File

@@ -1,8 +1,8 @@
<?php <?php
if (is_numeric($id)) if (is_numeric($vars['id']))
{ {
$service = dbFetchRow("SELECT * FROM services WHERE service_id = ?", array($id)); $service = dbFetchRow("SELECT * FROM services WHERE service_id = ?", array($vars['id']));
if (is_numeric($service['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($service['device_id']))) if (is_numeric($service['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($service['device_id'])))
{ {

View File

@@ -1,8 +1,8 @@
<?php <?php
if (is_numeric($id) && ($config['allow_unauth_graphs'] || device_permitted($id))) if (is_numeric($vars['id']) && ($config['allow_unauth_graphs'] || device_permitted($vars['id'])))
{ {
$device = device_by_id_cache($id); $device = device_by_id_cache($vars['id']);
$title = generate_device_link($device); $title = generate_device_link($device);
$graph_title = $device['hostname']; $graph_title = $device['hostname'];
$auth = TRUE; $auth = TRUE;

View File

@@ -1,8 +1,8 @@
<?php <?php
if (is_numeric($id)) if (is_numeric($vars['id']))
{ {
$storage = dbFetchRow("SELECT * FROM `storage` WHERE `storage_id` = ?", array($id)); $storage = dbFetchRow("SELECT * FROM `storage` WHERE `storage_id` = ?", array($vars['id']));
if (is_numeric($storage['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($storage['device_id']))) if (is_numeric($storage['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($storage['device_id'])))
{ {

View File

@@ -1,8 +1,8 @@
<?php <?php
if (is_numeric($id)) if (is_numeric($vars['id']))
{ {
$toner = dbFetchRow("SELECT * FROM `toner` WHERE `toner_id` = ?", array($id)); $toner = dbFetchRow("SELECT * FROM `toner` WHERE `toner_id` = ?", array($vars['id']));
if (is_numeric($toner['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($toner['device_id']))) if (is_numeric($toner['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($toner['device_id'])))
{ {

View File

@@ -1,9 +1,9 @@
<?php <?php
if (is_numeric($id)) if (is_numeric($vars['id']))
{ {
# $auth= TRUE; # $auth= TRUE;
$vserver = dbFetchRow("SELECT * FROM `loadbalancer_vservers` AS I, `devices` AS D WHERE I.classmap_id = ? AND I.device_id = D.device_id", array($id)); $vserver = dbFetchRow("SELECT * FROM `loadbalancer_vservers` AS I, `devices` AS D WHERE I.classmap_id = ? AND I.device_id = D.device_id", array($vars['id']));
if (is_numeric($vserver['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($vserver['device_id']))) if (is_numeric($vserver['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($vserver['device_id'])))
{ {

View File

@@ -1,7 +1,8 @@
<?php <?php
if(empty($graph_array['type'])) { $graph_array['type'] = $graph_type; } if(empty($graph_array['type'])) { $graph_array['type'] = $graph_type; }
if(empty($graph_array['id'])) { $graph_array['id'] = $device['device_id']; } if(empty($graph_array['device'])) { $graph_array['device'] = $device['device_id']; }
# FIXME not css alternating yet # FIXME not css alternating yet
if (!is_integer($g_i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } if (!is_integer($g_i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }

View File

@@ -61,33 +61,6 @@ foreach ($segments as $pos => $segment)
{ {
$vars['page'] = $segment; $vars['page'] = $segment;
} else { } else {
if (TRUE) // do this to keep everything working whilst we fiddle --AS
{ // also, who wrote this? Please check php.net/switch ;) --TL
if ($pos == "1")
{
$_GET['opta'] = $segment;
}
if ($pos == "2")
{
$_GET['optb'] = $segment;
}
if ($pos == "3")
{
$_GET['optc'] = $segment;
}
if ($pos == "4")
{
$_GET['optd'] = $segment;
}
if ($pos == "5")
{
$_GET['opte'] = $segment;
}
if ($pos == "6")
{
$_GET['optf'] = $segment;
}
}
list($name, $value) = explode("=", $segment); list($name, $value) = explode("=", $segment);
if ($value == "" || !isset($value)) if ($value == "" || !isset($value))
{ {

View File

@@ -91,6 +91,16 @@ if (device_permitted($vars['device']) || $check_device == $vars['device'])
</li>'); </li>');
} }
if (@dbFetchCell("SELECT COUNT(mplug_id) FROM munin_plugins WHERE device_id = '" . $device['device_id'] . "'") > '0')
{
echo('<li class="' . $select['munin'] . '">
<a href="'.generate_device_url($device, array('tab' => 'munin')). '">
<img src="images/16/chart_line.png" align="absmiddle" border="0" /> Munin
</a>
</li>');
}
if (@dbFetchCell("SELECT COUNT(interface_id) FROM ports WHERE device_id = '" . $device['device_id'] . "'") > '0') if (@dbFetchCell("SELECT COUNT(interface_id) FROM ports WHERE device_id = '" . $device['device_id'] . "'") > '0')
{ {
echo('<li class="' . $select['ports'] . $select['port'] . '"> echo('<li class="' . $select['ports'] . $select['port'] . '">

View File

@@ -17,13 +17,6 @@ echo("<span style='font-weight: bold;'>Graphs</span> &#187; ");
$sep = ""; $sep = "";
foreach (dbFetchRows("SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type", array($device['device_id'])) as $mplug)
{
# if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { }
$graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id'];
$graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title'];
}
foreach (dbFetchRows("SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph", array($device['device_id'])) as $graph) foreach (dbFetchRows("SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph", array($device['device_id'])) as $graph)
{ {
$section = $config['graph_types']['device'][$graph['graph']]['section']; $section = $config['graph_types']['device'][$graph['graph']]['section'];
@@ -59,18 +52,11 @@ $graph_enable = $graph_enable[$vars['group']];
#foreach ($config['graph_types']['device'] as $graph => $entry) #foreach ($config['graph_types']['device'] as $graph => $entry)
foreach ($graph_enable as $graph => $entry) foreach ($graph_enable as $graph => $entry)
{ {
$graph_array = array();
if ($graph_enable[$graph]) if ($graph_enable[$graph])
{ {
if (is_numeric($entry['id'])) $graph_title = $config['graph_types']['device'][$graph]['descr'];
{ $graph_array['type'] = "device_" . $graph;
$graph_title = $entry['title'];
$graph_array['type'] = "munin_graph";
$graph_array['id'] = $entry['id'];
} else {
$graph_title = $config['graph_types']['device'][$graph]['descr'];
$graph_array['type'] = "device_" . $graph;
}
include("includes/print-device-graph.php"); include("includes/print-device-graph.php");
} }
} }

View File

@@ -8,4 +8,4 @@ if (is_file($config['rrd_dir'] . "/" . $device['hostname'] ."/netstats-icmp.rrd"
include("includes/print-device-graph.php"); include("includes/print-device-graph.php");
} }
?> ?>

View File

@@ -0,0 +1,76 @@
<?php
### Sections are printed in the order they exist in $config['graph_sections']
### Graphs are printed in the order they exist in $config['graph_types']
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'munin');
$bg="#ffffff";
echo('<div style="clear: both;">');
print_optionbar_start();
echo("<span style='font-weight: bold;'>Munin</span> &#187; ");
$sep = "";
foreach (dbFetchRows("SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type", array($device['device_id'])) as $mplug)
{
# if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { }
$graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id'];
$graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title'];
$graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type'];
}
foreach ($graph_enable as $section => $nothing)
{
if (isset($graph_enable) && is_array($graph_enable[$section]))
{
$type = strtolower($section);
if (!$vars['group']) { $vars['group'] = $type; }
echo($sep);
if ($vars['group'] == $type)
{
echo('<span class="pagemenu-selected">');
}
echo(generate_link(ucwords($type),$link_array,array('group'=>$type)));
if ($vars['group'] == $type)
{
echo("</span>");
}
$sep = " | ";
}
}
unset ($sep);
print_optionbar_end();
$graph_enable = $graph_enable[$vars['group']];
#foreach ($config['graph_types']['device'] as $graph => $entry)
foreach ($graph_enable as $graph => $entry)
{
$graph_array = array();
if ($graph_enable[$graph])
{
if (!empty($entry['plugin']))
{
$graph_title = $entry['title'];
$graph_array['type'] = "munin_graph";
$graph_array['device'] = $device['device_id'];
$graph_array['plugin'] = $entry['plugin'];
} else {
$graph_title = $config['graph_types']['device'][$graph]['descr'];
$graph_array['type'] = "device_" . $graph;
}
include("includes/print-device-graph.php");
}
}
$pagetitle[] = "Graphs";
?>

View File

@@ -7,7 +7,7 @@ if ($ports['total'])
$graph_array['height'] = "100"; $graph_array['height'] = "100";
$graph_array['width'] = "485"; $graph_array['width'] = "485";
$graph_array['to'] = $config['time']['now']; $graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $device['device_id']; $graph_array['device'] = $device['device_id'];
$graph_array['type'] = "device_bits"; $graph_array['type'] = "device_bits";
$graph_array['from'] = $config['time']['day']; $graph_array['from'] = $config['time']['day'];
$graph_array['legend'] = "no"; $graph_array['legend'] = "no";

View File

@@ -22,6 +22,13 @@ $type = $graphtype['type'];
$subtype = $graphtype['subtype']; $subtype = $graphtype['subtype'];
$id = $vars['id']; $id = $vars['id'];
if(is_numeric($vars['device']))
{
$device = device_by_id_cache($vars['device']);
} elseif(!empty($vars['device'])) {
$device = device_by_name($vars['device']);
}
if (is_file("includes/graphs/".$type."/auth.inc.php")) if (is_file("includes/graphs/".$type."/auth.inc.php"))
{ {
include("includes/graphs/".$type."/auth.inc.php"); include("includes/graphs/".$type."/auth.inc.php");

View File

@@ -7,8 +7,8 @@ foreach ($vars as $var => $value)
switch ($var) switch ($var)
{ {
case 'name': case 'name':
$where .= " AND `$var` LIKE ?"; $where .= " AND `$var` = ?";
$param[] = "%".$value."%"; $param[] = $value;
break; break;
} }
} }
@@ -45,8 +45,12 @@ foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`",
$content .= "</div>"; $content .= "</div>";
} }
$content .= "</div>"; $content .= "</div>";
if(empty($vars['name']))
echo("<span style='margin:5px;'>".overlib_link("", $version, $content, NULL)."</span>"); {
echo("<span style='margin:5px;'>".overlib_link("", $version, $content, NULL)."</span>");
} else {
echo("$version $content");
}
} }
echo("<td>"); echo("<td>");

View File

@@ -257,6 +257,7 @@ function ifclass($ifOperStatus, $ifAdminStatus)
function device_by_name($name, $refresh = 0) function device_by_name($name, $refresh = 0)
{ {
## FIXME - cache name > id too.
return device_by_id_cache(getidbyname($name), $refresh); return device_by_id_cache(getidbyname($name), $refresh);
} }