From 0bd6a9736ef75ff7db80f2c234765e411d6a53bc Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Tue, 2 Jun 2015 13:55:53 +0200 Subject: [PATCH 1/5] Only unshift first time. --- html/pages/services.inc.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/html/pages/services.inc.php b/html/pages/services.inc.php index baabceef9..8070d5d61 100644 --- a/html/pages/services.inc.php +++ b/html/pages/services.inc.php @@ -56,11 +56,17 @@ if ($_SESSION['userlevel'] >= '5') $host_sql = "SELECT * FROM devices AS D, services AS S, devices_perms AS P WHERE D.device_id = S.device_id AND D.device_id = P.device_id AND P.user_id = ? GROUP BY D.hostname ORDER BY D.hostname"; $host_par = array($_SESSION['user_id']); } + $shift = 1; foreach (dbFetchRows($host_sql, $host_par) as $device) { $device_id = $device['device_id']; $device_hostname = $device['hostname']; - array_unshift($sql_param,$device_id); + if ($shift == 1) { + array_unshift($sql_param, $device_id); + $shift = 0; + } else { + $sql_param[0] = $device_id; + } foreach (dbFetchRows("SELECT * FROM `services` WHERE `device_id` = ? $where", $sql_param) as $service) { include("includes/print-service.inc.php"); From ffce63968fd860dc6e34228523967f096e13d702 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 2 Jun 2015 17:36:10 +0100 Subject: [PATCH 2/5] Fixed negative values for storage: http://munin-monitoring.org/ticket/1371 --- includes/discovery/storage/hrstorage.inc.php | 2 ++ includes/functions.php | 9 +++++++++ includes/polling/storage/hrstorage.inc.php | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/includes/discovery/storage/hrstorage.inc.php b/includes/discovery/storage/hrstorage.inc.php index 6183658f8..397872941 100644 --- a/includes/discovery/storage/hrstorage.inc.php +++ b/includes/discovery/storage/hrstorage.inc.php @@ -9,6 +9,8 @@ if (is_array($hrstorage_array)) { $fstype = $storage['hrStorageType']; $descr = $storage['hrStorageDescr']; + $storage['hrStorageSize'] = fix_integer_value($storage['hrStorageSize']); + $storage['hrStorageUsed'] = fix_integer_value($storage['hrStorageUsed']); $size = $storage['hrStorageSize'] * $storage['hrStorageAllocationUnits']; $used = $storage['hrStorageUsed'] * $storage['hrStorageAllocationUnits']; $units = $storage['hrStorageAllocationUnits']; diff --git a/includes/functions.php b/includes/functions.php index ef3cd98e3..1b995bfdb 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1201,3 +1201,12 @@ function first_oid_match($device, $list) { } } } + +function fix_integer_value($value) { + if ($value < 0) { + $return = 4294967296+$value; + } else { + $return = $value; + } + return $return; +} diff --git a/includes/polling/storage/hrstorage.inc.php b/includes/polling/storage/hrstorage.inc.php index 304e61b7d..5ff95aa7b 100644 --- a/includes/polling/storage/hrstorage.inc.php +++ b/includes/polling/storage/hrstorage.inc.php @@ -11,8 +11,10 @@ if (!is_array($storage_cache['hrstorage'])) $entry = $storage_cache['hrstorage'][$storage[storage_index]]; $storage['units'] = $entry['hrStorageAllocationUnits']; +$entry['hrStorageUsed'] = fix_integer_value($entry['hrStorageUsed']); +$entry['hrStorageSize'] = fix_integer_value($entry['hrStorageSize']); $storage['used'] = $entry['hrStorageUsed'] * $storage['units']; $storage['size'] = $entry['hrStorageSize'] * $storage['units']; $storage['free'] = $storage['size'] - $storage['used']; -?> \ No newline at end of file +?> From bf97bad18499e157eedfaff581d403d7da346c7e Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Tue, 2 Jun 2015 19:06:15 +0200 Subject: [PATCH 3/5] Fixed link for the dBm graphs from other Health-pages --- html/pages/health.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/pages/health.inc.php b/html/pages/health.inc.php index 50e1c1b58..e6f8d5b91 100644 --- a/html/pages/health.inc.php +++ b/html/pages/health.inc.php @@ -9,7 +9,7 @@ if ($used_sensors['voltage']) $datas[] = 'voltage'; if ($used_sensors['frequency']) $datas[] = 'frequency'; if ($used_sensors['current']) $datas[] = 'current'; if ($used_sensors['power']) $datas[] = 'power'; -if ($used_sensors['dBm']) $datas[] = 'dBm'; +if ($used_sensors['dbm']) $datas[] = 'dbm'; // FIXME generalize -> static-config ? $type_text['overview'] = "Overview"; @@ -26,7 +26,7 @@ $type_text['frequency'] = "Frequency"; $type_text['current'] = "Current"; $type_text['power'] = "Power"; $type_text['toner'] = "Toner"; -$type_text['dBm'] = "dBm"; +$type_text['dbm'] = "dBm"; if (!$vars['metric']) { $vars['metric'] = "processor"; } if (!$vars['view']) { $vars['view'] = "detail"; } From 903649dbce76c61acb95ff57d7140712e80b3d2a Mon Sep 17 00:00:00 2001 From: Rosiak Date: Tue, 2 Jun 2015 19:42:08 +0200 Subject: [PATCH 4/5] Minor name changes - Capitalise alert - Change health page menu to match the category --- html/pages/alert-log.inc.php | 2 +- html/pages/health.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/html/pages/alert-log.inc.php b/html/pages/alert-log.inc.php index 44eeb404c..34551e60b 100644 --- a/html/pages/alert-log.inc.php +++ b/html/pages/alert-log.inc.php @@ -24,7 +24,7 @@ $pagetitle[] = "Alert Log"; Time logged   Device - alert + Alert Status diff --git a/html/pages/health.inc.php b/html/pages/health.inc.php index 50e1c1b58..feb6061bb 100644 --- a/html/pages/health.inc.php +++ b/html/pages/health.inc.php @@ -17,7 +17,7 @@ $type_text['temperature'] = "Temperature"; $type_text['charge'] = "Battery Charge"; $type_text['humidity'] = "Humidity"; $type_text['mempool'] = "Memory"; -$type_text['storage'] = "Disk Usage"; +$type_text['storage'] = "Storage"; $type_text['diskio'] = "Disk I/O"; $type_text['processor'] = "Processor"; $type_text['voltage'] = "Voltage"; From 054bf3ae209f34a2c3bc8968300722004903df1b Mon Sep 17 00:00:00 2001 From: Rosiak Date: Tue, 2 Jun 2015 22:15:36 +0200 Subject: [PATCH 5/5] Convert processors page to use bootgrid - Based on @laf code from the storage page --- html/includes/table/processor.inc.php | 67 +++++++++++++++ html/pages/health/processor.inc.php | 118 ++++++++------------------ 2 files changed, 103 insertions(+), 82 deletions(-) create mode 100644 html/includes/table/processor.inc.php diff --git a/html/includes/table/processor.inc.php b/html/includes/table/processor.inc.php new file mode 100644 index 000000000..a7b3d9745 --- /dev/null +++ b/html/includes/table/processor.inc.php @@ -0,0 +1,67 @@ + generate_device_link($processor), + 'processor_descr' => $processor['processor_descr'], + 'graph' => $mini_graph, + 'processor_usage' => $bar_link); + if ($_POST['view'] == "graphs") { + $graph_array['height'] = "100"; + $graph_array['width'] = "216"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $processor['processor_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include("includes/print-graphrow.inc.php"); + unset($return_data); + $response[] = array('hostname' => $graph_data[0], + 'processor_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'processor_usage' => $graph_data[3]); + } # endif graphs +} +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +echo _json_encode($output); diff --git a/html/pages/health/processor.inc.php b/html/pages/health/processor.inc.php index cf2cf461b..f0a39b717 100644 --- a/html/pages/health/processor.inc.php +++ b/html/pages/health/processor.inc.php @@ -1,83 +1,37 @@ - + + + + + + + + + +
DeviceProcessorUsage
+ -$graph_type = "processor_usage"; - -echo("
"); -echo(" "); - -echo(" - - - - - "); - -foreach (dbFetchRows("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.device_id = P.device_id ORDER BY D.hostname") as $proc) -{ - if (device_permitted($proc['device_id'])) - { - $device = $proc; - - // FIXME should that really be done here? :-) - $text_descr = $proc['processor_descr']; - $text_descr = str_replace("Routing Processor", "RP", $text_descr); - $text_descr = str_replace("Switching Processor", "SP", $text_descr); - $text_descr = str_replace("Sub-Module", "Module ", $text_descr); - $text_descr = str_replace("DFC Card", "DFC", $text_descr); - - $proc_url = "device/device=".$device['device_id']."/tab=health/metric=processor/"; - - $mini_url = "graph.php?id=".$proc['processor_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f400"; - - $proc_popup = "onmouseover=\"return overlib('
".$device['hostname']." - ".$text_descr; - $proc_popup .= "
"; - $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; - - $perc = round($proc['processor_usage']); - - $background = get_percentage_colours($perc); - - echo(" - - - - - '); - - if ($vars['view'] == "graphs") - { - echo(' - "); - - } #end graphs if - } -} - -echo("
DeviceProcessorUsage
".generate_device_link($proc)."" . $text_descr . " - ".print_percentage_bar (400, 20, $perc, $perc."%", "ffffff", $background['left'], (100 - $perc)."%" , "ffffff", $background['right'])); - echo('
'); - - $daily_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=211&height=100"; - $daily_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=400&height=150"; - - $weekly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=211&height=100"; - $weekly_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=400&height=150"; - - $monthly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=211&height=100"; - $monthly_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=400&height=150"; - - $yearly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=211&height=100"; - $yearly_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=400&height=150"; - - echo(" ', LEFT);\" onmouseout=\"return nd();\"> - "); - echo(" ', LEFT);\" onmouseout=\"return nd();\"> - "); - echo(" ', LEFT);\" onmouseout=\"return nd();\"> - "); - echo(" ', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("
"); -echo("
"); - -?> +