diff --git a/html/includes/device-header.inc.php b/html/includes/device-header.inc.php index 2c8131318..70784fd53 100644 --- a/html/includes/device-header.inc.php +++ b/html/includes/device-header.inc.php @@ -38,25 +38,24 @@ echo(' $graphs = $config['os']['default']['over']; } + $graph_array = array(); $graph_array['height'] = "100"; $graph_array['width'] = "310"; $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['from'] = $config['time']['day']; $graph_array['legend'] = "no"; $graph_array['popup_title'] = $descr; -# $graph_array['link'] = generate_device_link($device_id); -# print_graph_popup($graph_array); $graph_array['height'] = "45"; $graph_array['width'] = "150"; $graph_array['bg'] = "FFFFFF00"; + foreach ($graphs as $entry) { $graph_array['type'] = $entry['graph']; - $graphhead = $entry['text']; echo("
"); print_graph_popup($graph_array); diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 8b0688e2a..d035eb13e 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -117,8 +117,8 @@ function generate_device_link($device, $text=NULL, $vars=array(), $start=0, $end $graphhead = $entry['text']; $contents .= '
'; $contents .= ''.$graphhead.'
'; - $contents .= "'; - $contents .= "'; + $contents .= "'; + $contents .= "'; $contents .= '
'; } @@ -169,7 +169,9 @@ function generate_graph_popup($graph_array) $content .= generate_graph_tag($graph_array); $content .= "
"; - $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); } diff --git a/html/includes/graphs/application/auth.inc.php b/html/includes/graphs/application/auth.inc.php index 97ea42a52..703b8bb3a 100644 --- a/html/includes/graphs/application/auth.inc.php +++ b/html/includes/graphs/application/auth.inc.php @@ -1,12 +1,12 @@ \ No newline at end of file +?> diff --git a/html/includes/graphs/application/memcached_threads.inc.php b/html/includes/graphs/application/memcached_threads.inc.php index f1023b0ca..3ebf18ffe 100644 --- a/html/includes/graphs/application/memcached_threads.inc.php +++ b/html/includes/graphs/application/memcached_threads.inc.php @@ -1,9 +1,8 @@ = "5" || $config['allow_unauth_graphs']) { - $id = mres($_GET['id']); + $id = mres($vars['id']); $title = generate_device_link($device); $auth = TRUE; } -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/customer/bits.inc.php b/html/includes/graphs/customer/bits.inc.php index e7529c231..7d958510a 100644 --- a/html/includes/graphs/customer/bits.inc.php +++ b/html/includes/graphs/customer/bits.inc.php @@ -2,7 +2,7 @@ ## Generate a list of ports and then call the multi_bits grapher to generate from the list $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"))) { diff --git a/html/includes/graphs/device/auth.inc.php b/html/includes/graphs/device/auth.inc.php index 6ed30d2e5..8a225c863 100644 --- a/html/includes/graphs/device/auth.inc.php +++ b/html/includes/graphs/device/auth.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file +?> diff --git a/html/includes/graphs/device/diskio_common.inc.php b/html/includes/graphs/device/diskio_common.inc.php index d84aae4fb..36b0b56f2 100644 --- a/html/includes/graphs/device/diskio_common.inc.php +++ b/html/includes/graphs/device/diskio_common.inc.php @@ -2,7 +2,7 @@ $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"); if (is_file($rrd_filename)) diff --git a/html/includes/graphs/device/hr_processes.inc.php b/html/includes/graphs/device/hr_processes.inc.php index 41502dd8a..eacdf9fc3 100644 --- a/html/includes/graphs/device/hr_processes.inc.php +++ b/html/includes/graphs/device/hr_processes.inc.php @@ -2,8 +2,6 @@ $scale_min = "0"; -include("includes/graphs/common.inc.php"); - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_processes.rrd"; $ds = "procs"; diff --git a/html/includes/graphs/device/hr_users.inc.php b/html/includes/graphs/device/hr_users.inc.php index eb75a01cf..644dbdd76 100644 --- a/html/includes/graphs/device/hr_users.inc.php +++ b/html/includes/graphs/device/hr_users.inc.php @@ -2,8 +2,6 @@ $scale_min = "0"; -include("includes/graphs/common.inc.php"); - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_users.rrd"; $ds = "users"; diff --git a/html/includes/graphs/device/ipSystemStats.inc.php b/html/includes/graphs/device/ipSystemStats.inc.php index da2aff92b..0a3048f54 100644 --- a/html/includes/graphs/device/ipSystemStats.inc.php +++ b/html/includes/graphs/device/ipSystemStats.inc.php @@ -2,8 +2,6 @@ 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_6 = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv6.rrd"; diff --git a/html/includes/graphs/device/ipsystemstats_ipv4.inc.php b/html/includes/graphs/device/ipsystemstats_ipv4.inc.php index 723761acf..edda01e76 100644 --- a/html/includes/graphs/device/ipsystemstats_ipv4.inc.php +++ b/html/includes/graphs/device/ipsystemstats_ipv4.inc.php @@ -2,8 +2,6 @@ include("includes/graphs/common.inc.php"); -$device = device_by_id_cache($id); - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv4.rrd"; $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:OutRequests_n#93a6eF:"; -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/device/ipsystemstats_ipv4_frag.inc.php b/html/includes/graphs/device/ipsystemstats_ipv4_frag.inc.php index eb020102a..a4e5344cf 100644 --- a/html/includes/graphs/device/ipsystemstats_ipv4_frag.inc.php +++ b/html/includes/graphs/device/ipsystemstats_ipv4_frag.inc.php @@ -2,8 +2,6 @@ include("includes/graphs/common.inc.php"); -$device = device_by_id_cache($id); - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv4.rrd"; $rrd_options .= " DEF:ipInDelivers=$rrd_filename:InDelivers:AVERAGE"; diff --git a/html/includes/graphs/device/ipsystemstats_ipv6.inc.php b/html/includes/graphs/device/ipsystemstats_ipv6.inc.php index d4927ec3b..57cedb29d 100644 --- a/html/includes/graphs/device/ipsystemstats_ipv6.inc.php +++ b/html/includes/graphs/device/ipsystemstats_ipv6.inc.php @@ -2,8 +2,6 @@ include("includes/graphs/common.inc.php"); -$device = device_by_id_cache($id); - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv6.rrd"; $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:OutRequests_n#93a6eF:"; -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/device/ipsystemstats_ipv6_frag.inc.php b/html/includes/graphs/device/ipsystemstats_ipv6_frag.inc.php index 7ae102b95..2b9912df3 100644 --- a/html/includes/graphs/device/ipsystemstats_ipv6_frag.inc.php +++ b/html/includes/graphs/device/ipsystemstats_ipv6_frag.inc.php @@ -2,8 +2,6 @@ include("includes/graphs/common.inc.php"); -$device = device_by_id_cache($id); - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ipSystemStats-ipv6.rrd"; $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:MReasmReqds:MAX:%6.2lf%s\\\\n"; -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/device/mempool.inc.php b/html/includes/graphs/device/mempool.inc.php index 720791010..b84653a68 100644 --- a/html/includes/graphs/device/mempool.inc.php +++ b/html/includes/graphs/device/mempool.inc.php @@ -1,7 +1,5 @@ \ No newline at end of file +?> diff --git a/html/includes/graphs/device/sensor.inc.php b/html/includes/graphs/device/sensor.inc.php index d6af31e60..a7adf46b9 100644 --- a/html/includes/graphs/device/sensor.inc.php +++ b/html/includes/graphs/device/sensor.inc.php @@ -2,7 +2,6 @@ include("includes/graphs/common.inc.php"); -$device = device_by_id_cache($id); if ($_GET['width'] > "300") { $descr_len = "40"; } else { $descr_len = "22"; } @@ -10,7 +9,7 @@ $rrd_options .= " -l 0 -E "; $iter = "1"; $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 switch ($iter) diff --git a/html/includes/graphs/device/sla.inc.php b/html/includes/graphs/device/sla.inc.php index b52401638..b33a45b42 100644 --- a/html/includes/graphs/device/sla.inc.php +++ b/html/includes/graphs/device/sla.inc.php @@ -2,7 +2,9 @@ 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']); #if ($_GET['width'] >= "450") { $descr_len = "48"; } else { $descr_len = "21"; } diff --git a/html/includes/graphs/device/storage.inc.php b/html/includes/graphs/device/storage.inc.php index 3ddcca5b6..be5c5f6ad 100644 --- a/html/includes/graphs/device/storage.inc.php +++ b/html/includes/graphs/device/storage.inc.php @@ -5,12 +5,10 @@ $scale_max = "100"; include("includes/graphs/common.inc.php"); -$device = device_by_id_cache($id); - $iter = "1"; $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 if ($iter=="1") { $colour="CC0000"; } elseif ($iter=="2") { $colour="008C00"; } elseif ($iter=="3") { $colour="4096EE"; } diff --git a/html/includes/graphs/device/toner.inc.php b/html/includes/graphs/device/toner.inc.php index 9080b058a..002cd98e1 100644 --- a/html/includes/graphs/device/toner.inc.php +++ b/html/includes/graphs/device/toner.inc.php @@ -2,13 +2,12 @@ include("includes/graphs/common.inc.php"); -$device = device_by_id_cache($id); $rrd_options .= " -l 0 -E "; $iter = "1"; $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']); diff --git a/html/includes/graphs/device/ucd_load.inc.php b/html/includes/graphs/device/ucd_load.inc.php index 0de347016..9a0c45cc8 100644 --- a/html/includes/graphs/device/ucd_load.inc.php +++ b/html/includes/graphs/device/ucd_load.inc.php @@ -4,8 +4,6 @@ $scale_min = "0"; include("includes/graphs/common.inc.php"); -$device = device_by_id_cache($id); - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ucd_load.rrd"; $rrd_options .= " DEF:1min=$rrd_filename:1min:AVERAGE"; diff --git a/html/includes/graphs/device/ucd_memory.inc.php b/html/includes/graphs/device/ucd_memory.inc.php index ef8656f22..992714aba 100644 --- a/html/includes/graphs/device/ucd_memory.inc.php +++ b/html/includes/graphs/device/ucd_memory.inc.php @@ -2,8 +2,6 @@ include("includes/graphs/common.inc.php"); -$device = device_by_id_cache($id); - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ucd_mem.rrd"; $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:cached_perc=cached,totalreal,/,100,*'"; - $rrd_options .= " 'CDEF:cusedswap=usedswap,-1,*'"; $rrd_options .= " 'CDEF:cdeftot=availreal,shared,buffered,usedreal,cached,usedswap,+,+,+,+,+'"; $rrd_options .= " 'COMMENT:Bytes Current Average Maximum\\n'"; diff --git a/html/includes/graphs/device/uptime.inc.php b/html/includes/graphs/device/uptime.inc.php index dc2f8513a..254dd8379 100644 --- a/html/includes/graphs/device/uptime.inc.php +++ b/html/includes/graphs/device/uptime.inc.php @@ -4,7 +4,6 @@ $scale_min = "0"; include("includes/graphs/common.inc.php"); -$device = device_by_id_cache($id); $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/uptime.rrd"; diff --git a/html/includes/graphs/device/vpdn_sessions_l2tp.inc.php b/html/includes/graphs/device/vpdn_sessions_l2tp.inc.php index 35d2ba090..49ba67bc6 100644 --- a/html/includes/graphs/device/vpdn_sessions_l2tp.inc.php +++ b/html/includes/graphs/device/vpdn_sessions_l2tp.inc.php @@ -2,7 +2,6 @@ include("includes/graphs/common.inc.php"); -$device = device_by_id_cache($id); $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/vpdn-l2tp.rrd"; diff --git a/html/includes/graphs/device/vpdn_tunnels_l2tp.inc.php b/html/includes/graphs/device/vpdn_tunnels_l2tp.inc.php index 95e3abc76..67f29f0a4 100644 --- a/html/includes/graphs/device/vpdn_tunnels_l2tp.inc.php +++ b/html/includes/graphs/device/vpdn_tunnels_l2tp.inc.php @@ -2,7 +2,6 @@ include("includes/graphs/common.inc.php"); -$device = device_by_id_cache($id); $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/vpdn-l2tp.rrd"; diff --git a/html/includes/graphs/device/wifi_clients.inc.php b/html/includes/graphs/device/wifi_clients.inc.php index a68d29bb2..791af6fd5 100644 --- a/html/includes/graphs/device/wifi_clients.inc.php +++ b/html/includes/graphs/device/wifi_clients.inc.php @@ -2,7 +2,6 @@ include("includes/graphs/common.inc.php"); -$device = device_by_id_cache($id); $rrd_options .= " -l 0 -E "; diff --git a/html/includes/graphs/diskio/auth.inc.php b/html/includes/graphs/diskio/auth.inc.php index 97b5485c9..c8bd80987 100644 --- a/html/includes/graphs/diskio/auth.inc.php +++ b/html/includes/graphs/diskio/auth.inc.php @@ -1,8 +1,8 @@ $value) +{ + $vars[$name] = $value; +} + +preg_match('/^(?P[A-Za-z0-9]+)_(?P.+)/', $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; } @@ -25,8 +42,6 @@ $prev_from = $from - $period; $graphfile = $config['temp_dir'] . "/" . strgen() . ".png"; -preg_match('/^(?P[A-Za-z0-9]+)_(?P.+)/', $_GET['type'], $graphtype); - $type = $graphtype['type']; $subtype = $graphtype['subtype']; @@ -58,9 +73,9 @@ else 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"); diff --git a/html/includes/graphs/ipsectunnel/auth.inc.php b/html/includes/graphs/ipsectunnel/auth.inc.php index 98ca0ffe6..1f5b4f5e8 100644 --- a/html/includes/graphs/ipsectunnel/auth.inc.php +++ b/html/includes/graphs/ipsectunnel/auth.inc.php @@ -1,9 +1,8 @@ "); diff --git a/html/includes/graphs/mempool/auth.inc.php b/html/includes/graphs/mempool/auth.inc.php index 03f35a93b..7482e2b47 100755 --- a/html/includes/graphs/mempool/auth.inc.php +++ b/html/includes/graphs/mempool/auth.inc.php @@ -1,8 +1,8 @@ \ No newline at end of file +?> diff --git a/html/includes/graphs/multiport/bits.inc.php b/html/includes/graphs/multiport/bits.inc.php index abb20a7c7..7d9245039 100644 --- a/html/includes/graphs/multiport/bits.inc.php +++ b/html/includes/graphs/multiport/bits.inc.php @@ -2,7 +2,7 @@ $i = 1; -foreach (explode(",", $id) as $ifid) +foreach (explode(",", $vars['id']) as $ifid) { if (strstr($ifid, "!")) { diff --git a/html/includes/graphs/multiport/bits_separate.inc.php b/html/includes/graphs/multiport/bits_separate.inc.php index 5fe63026e..114e9c722 100644 --- a/html/includes/graphs/multiport/bits_separate.inc.php +++ b/html/includes/graphs/multiport/bits_separate.inc.php @@ -2,7 +2,7 @@ $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)); if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"))) diff --git a/html/includes/graphs/munin/auth.inc.php b/html/includes/graphs/munin/auth.inc.php index 9664f7e78..e8f3dbb52 100755 --- a/html/includes/graphs/munin/auth.inc.php +++ b/html/includes/graphs/munin/auth.inc.php @@ -1,23 +1,20 @@ diff --git a/html/includes/graphs/netscalervsvr/auth.inc.php b/html/includes/graphs/netscalervsvr/auth.inc.php index c5f2457ea..bc53bcc86 100644 --- a/html/includes/graphs/netscalervsvr/auth.inc.php +++ b/html/includes/graphs/netscalervsvr/auth.inc.php @@ -1,9 +1,9 @@ $segment) { $vars['page'] = $segment; } 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); if ($value == "" || !isset($value)) { diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index 2f27ebc04..477127290 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -91,6 +91,16 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) '); } + if (@dbFetchCell("SELECT COUNT(mplug_id) FROM munin_plugins WHERE device_id = '" . $device['device_id'] . "'") > '0') + { + echo('
  • + + Munin + +
  • '); + } + + if (@dbFetchCell("SELECT COUNT(interface_id) FROM ports WHERE device_id = '" . $device['device_id'] . "'") > '0') { echo('
  • diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index cadfeaf0f..72fa6ba1a 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -17,13 +17,6 @@ echo("Graphs » "); $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) { $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 ($graph_enable as $graph => $entry) { + $graph_array = array(); if ($graph_enable[$graph]) { - if (is_numeric($entry['id'])) - { - $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; - } - + $graph_title = $config['graph_types']['device'][$graph]['descr']; + $graph_array['type'] = "device_" . $graph; include("includes/print-device-graph.php"); } } diff --git a/html/pages/device/graphs/netstats_icmp_info.inc.php b/html/pages/device/graphs/netstats_icmp_info.inc.php index a396c940f..9e798d2c7 100644 --- a/html/pages/device/graphs/netstats_icmp_info.inc.php +++ b/html/pages/device/graphs/netstats_icmp_info.inc.php @@ -8,4 +8,4 @@ if (is_file($config['rrd_dir'] . "/" . $device['hostname'] ."/netstats-icmp.rrd" include("includes/print-device-graph.php"); } -?> \ No newline at end of file +?> diff --git a/html/pages/device/munin.inc.php b/html/pages/device/munin.inc.php new file mode 100644 index 000000000..1d0498c34 --- /dev/null +++ b/html/pages/device/munin.inc.php @@ -0,0 +1,76 @@ + 'device', + 'device' => $device['device_id'], + 'tab' => 'munin'); + +$bg="#ffffff"; + +echo('
    '); + +print_optionbar_start(); + +echo("Munin » "); + +$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(''); + } + echo(generate_link(ucwords($type),$link_array,array('group'=>$type))); + if ($vars['group'] == $type) + { + echo(""); + } + $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"; + +?> diff --git a/html/pages/device/overview/ports.inc.php b/html/pages/device/overview/ports.inc.php index 406b6ac6c..2efc94341 100644 --- a/html/pages/device/overview/ports.inc.php +++ b/html/pages/device/overview/ports.inc.php @@ -7,7 +7,7 @@ if ($ports['total']) $graph_array['height'] = "100"; $graph_array['width'] = "485"; $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['from'] = $config['time']['day']; $graph_array['legend'] = "no"; diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 2a6d8fd7f..e51dc6aac 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -22,6 +22,13 @@ $type = $graphtype['type']; $subtype = $graphtype['subtype']; $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")) { include("includes/graphs/".$type."/auth.inc.php"); diff --git a/html/pages/packages.inc.php b/html/pages/packages.inc.php index 52dc6cc89..e505daa39 100644 --- a/html/pages/packages.inc.php +++ b/html/pages/packages.inc.php @@ -7,8 +7,8 @@ foreach ($vars as $var => $value) switch ($var) { case 'name': - $where .= " AND `$var` LIKE ?"; - $param[] = "%".$value."%"; + $where .= " AND `$var` = ?"; + $param[] = $value; break; } } @@ -45,8 +45,12 @@ foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", $content .= "
    "; } $content .= ""; - - echo("".overlib_link("", $version, $content, NULL).""); + if(empty($vars['name'])) + { + echo("".overlib_link("", $version, $content, NULL).""); + } else { + echo("$version $content"); + } } echo(""); diff --git a/includes/common.php b/includes/common.php index acb5895f8..bb039913a 100644 --- a/includes/common.php +++ b/includes/common.php @@ -257,6 +257,7 @@ function ifclass($ifOperStatus, $ifAdminStatus) function device_by_name($name, $refresh = 0) { + ## FIXME - cache name > id too. return device_by_id_cache(getidbyname($name), $refresh); }