From 7c5087bacb06fac71f999cdb04d8b7a19c872271 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 16 May 2015 16:30:25 +0100 Subject: [PATCH] Added bootgrid support for storage page --- html/includes/print-graphrow.inc.php | 6 +- html/includes/table/storage.inc.php | 102 ++++++++++++++++++++++ html/pages/health/storage.inc.php | 124 +++++++++------------------ 3 files changed, 146 insertions(+), 86 deletions(-) create mode 100644 html/includes/table/storage.inc.php diff --git a/html/includes/print-graphrow.inc.php b/html/includes/print-graphrow.inc.php index 4ce8661be..240362632 100644 --- a/html/includes/print-graphrow.inc.php +++ b/html/includes/print-graphrow.inc.php @@ -27,7 +27,11 @@ foreach ($periods as $period) unset($link_array['height'], $link_array['width']); $link = generate_url($link_array); - echo(overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL)); + if ($return_data === TRUE) { + $graph_data[] = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); + } else { + echo(overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL)); + } } ?> diff --git a/html/includes/table/storage.inc.php b/html/includes/table/storage.inc.php new file mode 100644 index 000000000..89dd88bd9 --- /dev/null +++ b/html/includes/table/storage.inc.php @@ -0,0 +1,102 @@ +> /tmp/testing"); +foreach (dbFetchRows($sql,$param) as $drive) { + if (device_permitted($drive['device_id'])) { + $skipdrive = 0; + + if ($drive["os"] == "junos") { + foreach ($config['ignore_junos_os_drives'] as $jdrive) { + if (preg_match($jdrive, $drive["storage_descr"])) { + $skipdrive = 1; + } + } + $drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]); + } + + if ($drive['os'] == "freebsd") { + foreach ($config['ignore_bsd_os_drives'] as $jdrive) { + if (preg_match($jdrive, $drive["storage_descr"])) { + $skipdrive = 1; + } + } + } + + if ($skipdrive) { + continue; + } + + $perc = round($drive['storage_perc'], 0); + $total = formatStorage($drive['storage_size']); + $free = formatStorage($drive['storage_free']); + $used = formatStorage($drive['storage_used']); + + $graph_array['type'] = $graph_type; + $graph_array['id'] = $drive['storage_id']; + $graph_array['from'] = $config['time']['day']; + $graph_array['to'] = $config['time']['now']; + $graph_array['height'] = "20"; + $graph_array['width'] = "80"; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = "150"; + $graph_array_zoom['width'] = "400"; + $link = "graphs/id=" . $graph_array['id'] . "/type=" . $graph_array['type'] . "/from=" . $graph_array['from'] . "/to=" . $graph_array['to'] . "/"; + $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); + $bar_link = overlib_link($link, print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $free, "ffffff", $background['right']), generate_graph_tag($graph_array_zoom), NULL); + + $background = get_percentage_colours($perc); + + $response[] = array('device_id' => generate_device_link($drive), + 'storage_descr' => $drive['storage_descr'], + 'graph' => $mini_graph, + 'usage' => $bar_link, + 'storage_used' => $perc . "%"); + if ($_POST['view'] == "graphs") { + system("echo 'test' >> /tmp/testing"); + $graph_array['height'] = "100"; + $graph_array['width'] = "216"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; + + $return_data = true; + include("includes/print-graphrow.inc.php"); + unset($return_data); + $response[] = array('device_id' => $graph_data[0], + 'storage_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'usage' => $graph_data[3], + 'storage_used' => ''); + + } # endif graphs + } +} + +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +echo _json_encode($output); \ No newline at end of file diff --git a/html/pages/health/storage.inc.php b/html/pages/health/storage.inc.php index 5ce03084b..320c566c6 100644 --- a/html/pages/health/storage.inc.php +++ b/html/pages/health/storage.inc.php @@ -2,90 +2,44 @@ $graph_type = "storage_usage"; -echo("
- "); - -echo(" - - - - - - "); - -foreach (dbFetchRows("SELECT * FROM `storage` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY D.hostname, S.storage_descr") as $drive) -{ - if (device_permitted($drive['device_id'])) - { - $skipdrive = 0; - - if ($drive["os"] == "junos") - { - foreach ($config['ignore_junos_os_drives'] as $jdrive) - { - if (preg_match($jdrive, $drive["storage_descr"])) - { - $skipdrive = 1; - } - } - $drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]); - } - - if ($drive['os'] == "freebsd") - { - foreach ($config['ignore_bsd_os_drives'] as $jdrive) - { - if (preg_match($jdrive, $drive["storage_descr"])) - { - $skipdrive = 1; - } - } - } - - if ($skipdrive) { continue; } - - $perc = round($drive['storage_perc'], 0); - $total = formatStorage($drive['storage_size']); - $free = formatStorage($drive['storage_free']); - $used = formatStorage($drive['storage_used']); - - $graph_array['type'] = $graph_type; - $graph_array['id'] = $drive['storage_id']; - $graph_array['from'] = $config['time']['day']; - $graph_array['to'] = $config['time']['now']; - $graph_array['height'] = "20"; - $graph_array['width'] = "80"; - $graph_array_zoom = $graph_array; - $graph_array_zoom['height'] = "150"; - $graph_array_zoom['width'] = "400"; - $link = "graphs/id=" . $graph_array['id'] . "/type=" . $graph_array['type'] . "/from=" . $graph_array['from'] . "/to=" . $graph_array['to'] . "/"; - $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); - $bar_link = overlib_link($link, print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $free, "ffffff", $background['right']), generate_graph_tag($graph_array_zoom), NULL); - - $background = get_percentage_colours($perc); - - echo(" - - "); - - if ($vars['view'] == "graphs") - { - echo(""); - - } # endif graphs - } -} - -echo("
DeviceStorageUsageUsed
" . generate_device_link($drive) . "" . $drive['storage_descr'] . "$mini_graph$bar_link$perc"."%
"); - - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; - - include("includes/print-graphrow.inc.php"); - - echo("
"); +echo $vars['view']; ?> + +
+ + + + + + + + + + +
DeviceStorageUsageUsed
+
+ + \ No newline at end of file