From 3484581dd6ca98be6d106bd6779d1d7fe425142f Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 1 Aug 2015 18:14:55 +0000 Subject: [PATCH 01/21] Updated network to support old style format, docs provided --- doc/Support/Configuration.md | 5 + html/network-map.php | 254 ++++++++++++++++++++++++++++++++++ html/pages/device/map.inc.php | 11 +- html/pages/map.inc.php | 8 +- includes/defaults.inc.php | 3 + 5 files changed, 279 insertions(+), 2 deletions(-) create mode 100644 html/network-map.php diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index e2288aef2..f70b9f3e7 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -169,6 +169,11 @@ $config['enable_footer'] = 1; ``` Disable the footer of the WebUI by setting `enable_footer` to 0. +You can enable the old style network map (only available for individual devices with links discovered via xDP) by setting: +```php +$config['gui']['network-map']['style'] = 'old'; +```` + #### Add host settings The following setting controls how hosts are added. If a host is added as an ip address it is checked to ensure the ip is not already present. If the ip is present the host is not added. If host is added by hostname this check is not performed. If the setting is true hostnames are resovled and the check is also performed. This helps prevents accidental duplicate hosts. diff --git a/html/network-map.php b/html/network-map.php new file mode 100644 index 000000000..7907eee54 --- /dev/null +++ b/html/network-map.php @@ -0,0 +1,254 @@ + + * @copyright (C) 2006 - 2012 Adam Armstrong + * + */ + +ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); +ini_set('log_errors', 1); +ini_set('error_reporting', E_ALL); + +$links = 1; + +include_once '../includes/defaults.inc.php'; +include_once '../config.php'; +include_once '../includes/definitions.inc.php'; +include_once '../includes/functions.php'; +include_once '../includes/dbFacile.php'; +include_once 'includes/functions.inc.php'; +include_once 'includes/authenticate.inc.php'; + +if (strpos($_SERVER['REQUEST_URI'], 'anon')) { + $anon = 1; +} + +if (is_array($config['branding'])) { + if ($config['branding'][$_SERVER['SERVER_NAME']]) { + foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) { + eval("\$config['" . $confitem . "'] = \$confval;"); + } + } + else { + foreach ($config['branding']['default'] as $confitem => $confval) { + eval("\$config['" . $confitem . "'] = \$confval;"); + } + } +} + +if (isset($_GET['device'])) { + $where = 'WHERE device_id = '.mres($_GET['device']); +} +else { + $where = ''; +} + +// FIXME this shit probably needs tidied up. + +if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) { + $map = ' + digraph G { bgcolor=transparent; splines=true; overlap=scale; concentrate=0; epsilon=0.001; rankdir=LR; + node [ fontname="helvetica", fontstyle=bold, style=filled, color=white, fillcolor=lightgrey, overlap=false]; + edge [ bgcolor=white, fontname="helvetica", fontstyle=bold, arrowhead=dot, arrowtail=dot]; + graph [bgcolor=transparent]; +'; + + if (!$_SESSION['authenticated']) { + $map .= "\"Not authenticated\" [fontsize=20 fillcolor=\"lightblue\", URL=\"/\" shape=box3d]\n"; + } + else { + $loc_count = 1; + + foreach (dbFetch("SELECT * from devices ".$where) as $device) { + if ($device) { + $links = dbFetch("SELECT * from ports AS I, links AS L WHERE I.device_id = ? AND L.local_port_id = I.port_id ORDER BY L.remote_hostname", array($device['device_id'])); + if (count($links)) { + if ($anon) { + $device['hostname'] = md5($device['hostname']); + } + if (!isset($locations[$device['location']])) { + $locations[$device['location']] = $loc_count; $loc_count++; + } + $loc_id = $locations[$device['location']]; + + $map .= "\"".$device['hostname']."\" [fontsize=20, fillcolor=\"lightblue\", group=".$loc_id." URL=\"{$config['base_url']}/device/device=".$device['device_id']."/tab=map/\" shape=box3d]\n"; + } + + foreach ($links as $link) { + $local_port_id = $link['local_port_id']; + $remote_port_id = $link['remote_port_id']; + + $i = 0; $done = 0; + if ($linkdone[$remote_port_id][$local_port_id]) { + $done = 1; + } + + if (!$done) { + $linkdone[$local_port_id][$remote_port_id] = TRUE; + + $links++; + + if ($link['ifSpeed'] >= "10000000000") { + $info = "color=red3 style=\"setlinewidth(6)\""; + } + elseif ($link['ifSpeed'] >= "1000000000") { + $info = "color=lightblue style=\"setlinewidth(4)\""; + } + elseif ($link['ifSpeed'] >= "100000000") { + $info = "color=lightgrey style=\"setlinewidth(2)\""; + } + elseif ($link['ifSpeed'] >= "10000000") { + $info = "style=\"setlinewidth(1)\""; + } + else { + $info = "style=\"setlinewidth(1)\""; + } + + $src = $device['hostname']; + if ($anon) { + $src = md5($src); + } + if ($remote_port_id) { + $dst = dbFetchCell("SELECT `hostname` FROM `devices` AS D, `ports` AS I WHERE I.port_id = ? AND D.device_id = I.device_id", array($remote_port_id)); + $dst_host = dbFetchCell("SELECT D.device_id FROM `devices` AS D, `ports` AS I WHERE I.port_id = ? AND D.device_id = I.device_id", array($remote_port_id)); + } + else { + unset($dst_host); + $dst = $link['remote_hostname']; + } + + if ($anon) { + $dst = md5($dst); + $src = md5($src); + } + + $sif = ifNameDescr(dbFetchRow("SELECT * FROM ports WHERE `port_id` = ?", array($link['local_port_id'])),$device); + if ($remote_port_id) { + $dif = ifNameDescr(dbFetchRow("SELECT * FROM ports WHERE `port_id` = ?", array($link['remote_port_id']))); + } + else { + $dif['label'] = $link['remote_port']; + $dif['port_id'] = $link['remote_hostname'] . '/' . $link['remote_port']; + } + + if ($where == "") { + if (!$ifdone[$dst][$dif['port_id']] && !$ifdone[$src][$sif['port_id']]) { + $map .= "\"$src\" -> \"" . $dst . "\" [weight=500000, arrowsize=0, len=0];\n"; + } + $ifdone[$src][$sif['port_id']] = 1; + } + else { + $map .= "\"" . $sif['port_id'] . "\" [label=\"" . $sif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/device=".$device['device_id']."/tab=port/port=$local_port_id/\"]\n"; + if (!$ifdone[$src][$sif['port_id']]) { + $map .= "\"$src\" -> \"" . $sif['port_id'] . "\" [weight=500000, arrowsize=0, len=0];\n"; + $ifdone[$src][$sif['port_id']] = 1; + } + + if ($dst_host) { + $map .= "\"$dst\" [URL=\"{$config['base_url']}/device/device=$dst_host/tab=map/\", fontsize=20, shape=box3d]\n"; + } + else { + $map .= "\"$dst\" [ fontsize=20 shape=box3d]\n"; + } + + if ($dst_host == $device['device_id'] || $where == '') { + $map .= "\"" . $dif['port_id'] . "\" [label=\"" . $dif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/device=$dst_host/tab=port/port=$remote_port_id/\"]\n"; + } + else { + $map .= "\"" . $dif['port_id'] . "\" [label=\"" . $dif['label'] . " \", fontsize=12, fillcolor=lightgray"; + if ($dst_host) { + $map .= ", URL=\"{$config['base_url']}/device/device=$dst_host/tab=port/port=$remote_port_id/\""; + } + $map .= "]\n"; + } + + if (!$ifdone[$dst][$dif['port_id']]) { + $map .= "\"" . $dif['port_id'] . "\" -> \"$dst\" [weight=500000, arrowsize=0, len=0];\n"; + $ifdone[$dst][$dif['port_id']] = 1; + } + $map .= "\"" . $sif['port_id'] . "\" -> \"" . $dif['port_id'] . "\" [weight=1, arrowhead=normal, arrowtail=normal, len=2, $info] \n"; + } + } + } + $done = 0; + } + } + } + + $map .= "\n};"; + + if ($_GET['debug'] == 1) { + echo '
$map
'; + exit(); + } + + switch ($_GET['format']) { + case 'svg': + break; + case 'png': + $_GET['format'] = 'png:gd'; + break; + case 'dot': + echo($map); + exit(); + default: + $_GET['format'] = 'png:gd'; + } + + if ($links > 30) { + // Unflatten if there are more than 10 links. beyond that it gets messy + $maptool = $config['dot']; + } + else { + $maptool = $config['dot']; + } + + if ($where == '') { +# $maptool = $config['unflatten'] . ' -f -l 5 | ' . $config['sfdp'] . ' -Gpack -Goverlap=prism -Gcharset=latin1 | dot'; + $maptool = $config['sfdp'] . ' -Gpack -Goverlap=prism -Gcharset=latin1 -Gsize=20,20'; + $maptool = $config['dot']; + } + + $descriptorspec = array(0 => array("pipe", "r"),1 => array("pipe", "w") ); + + $mapfile = $config['temp_dir'] . "/" . strgen() . ".png"; + + $process = proc_open($maptool.' -T'.$_GET['format'],$descriptorspec,$pipes); + + if (is_resource($process)) { + fwrite($pipes[0], "$map"); + fclose($pipes[0]); + while (! feof($pipes[1])) { + $img .= fgets($pipes[1]); + } + fclose($pipes[1]); + $return_value = proc_close($process); + } + + if ($_GET['format'] == "png:gd") { + header("Content-type: image/png"); + } + elseif ($_GET['format'] == "svg") { + header("Content-type: image/svg+xml"); + $img = str_replace(" + + + '; + } +} + diff --git a/html/pages/device/map.inc.php b/html/pages/device/map.inc.php index 918f62e7f..6d6b56392 100644 --- a/html/pages/device/map.inc.php +++ b/html/pages/device/map.inc.php @@ -14,4 +14,13 @@ $pagetitle[] = 'Map'; -require_once 'includes/print-map.inc.php'; +if ($config['gui']['network-map']['style'] == 'old') { + echo ' +
+ +
+ '; +} +else { + require_once 'includes/print-map.inc.php'; +} diff --git a/html/pages/map.inc.php b/html/pages/map.inc.php index 115c0600c..8abc8fecf 100644 --- a/html/pages/map.inc.php +++ b/html/pages/map.inc.php @@ -11,4 +11,10 @@ * the source code distribution for details. */ $pagetitle[] = 'Map'; -require_once 'includes/print-map.inc.php'; + +if ($config['gui']['network-map']['style'] == 'old') { + print_error('You are using the old style network map, a global map is not available'); +} +else { + require_once 'includes/print-map.inc.php'; +} diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 11d8d9475..577b8730d 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -794,5 +794,8 @@ $config['leaflet']['default_lat'] = '50.898482'; $config['leaflet']['default_lng'] = '-3.401402'; $config['leaflet']['default_zoom'] = 2; +// General GUI options +$config['gui']['network-map']['style'] = 'new';//old is also valid + // Navbar variables $config['navbar']['manage_groups']['hide'] = 0; From 94351d788e7bdf3bba9272c7297d3beadb0c6a0e Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 3 Aug 2015 10:46:40 +0000 Subject: [PATCH 02/21] Initial start of adding edit storage page --- html/css/styles.css | 4 ++ html/forms/storage-update.inc.php | 46 +++++++++++++ html/includes/table/storage-edit.inc.php | 51 ++++++++++++++ html/pages/device/edit.inc.php | 2 + html/pages/device/edit/storage.inc.php | 87 ++++++++++++++++++++++++ 5 files changed, 190 insertions(+) create mode 100644 html/forms/storage-update.inc.php create mode 100644 html/includes/table/storage-edit.inc.php create mode 100644 html/pages/device/edit/storage.inc.php diff --git a/html/css/styles.css b/html/css/styles.css index 455bf51a1..80d53766e 100644 --- a/html/css/styles.css +++ b/html/css/styles.css @@ -1759,3 +1759,7 @@ tr.search:nth-child(odd) { #leaflet-map { height: 600px; } + +.edit-storage-input { + width: 100px; +} diff --git a/html/forms/storage-update.inc.php b/html/forms/storage-update.inc.php new file mode 100644 index 000000000..3be5ea4b4 --- /dev/null +++ b/html/forms/storage-update.inc.php @@ -0,0 +1,46 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +$status = 'error'; +$message = 'Error updating storage information'; + +$device_id = mres($_POST['device_id']); +$storage_id = mres($_POST['storage_id']); +$data = mres($_POST['data']); + +if (!is_numeric($device_id)) { + $message = 'Missing device id'; +} +elseif (!is_numeric($storage_id)) { + $message = 'Missing storage id'; +} +elseif (!is_numeric($data)) { + $message = 'Missing value'; +} +else { + if (dbUpdate(array('storage_perc_warn'=>$data), 'storage', '`storage_id`=? AND `device_id`=?',array($storage_id,$device))) { + $message = 'Storage information updated'; + $status = 'ok'; + } + else { + $message = 'Could not update storage information'; + } +} + +$response = array( + 'status' => $status, + 'message' => $message, + 'extra' => $extra, +); +echo _json_encode($response); diff --git a/html/includes/table/storage-edit.inc.php b/html/includes/table/storage-edit.inc.php new file mode 100644 index 000000000..97d9ecc7e --- /dev/null +++ b/html/includes/table/storage-edit.inc.php @@ -0,0 +1,51 @@ + $sql); +foreach (dbFetchRows($sql,$param) as $drive) { + + $perc = round($drive['storage_perc'], 0); + $perc_warn = round($drive['storage_perc_warn'], 0); + $response[] = array( + 'storage_id' => $drive['storage_id'], + 'hostname' => generate_device_link($drive), + 'storage_descr' => $drive['storage_descr'], + 'storage_perc' => $perc . "%", + 'storage_perc_warn' => $perc_warn); + +} + +$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/device/edit.inc.php b/html/pages/device/edit.inc.php index deaa1b084..d95e047b0 100644 --- a/html/pages/device/edit.inc.php +++ b/html/pages/device/edit.inc.php @@ -34,6 +34,8 @@ else { $panes['health'] = 'Health'; } + $panes['storage'] = 'Storage'; + print_optionbar_start(); unset($sep); diff --git a/html/pages/device/edit/storage.inc.php b/html/pages/device/edit/storage.inc.php new file mode 100644 index 000000000..7ab0337db --- /dev/null +++ b/html/pages/device/edit/storage.inc.php @@ -0,0 +1,87 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +?> + +

Storage settings

+ +
+ + + + + + + + + +
DeviceStorage%% Warn
+
+ + From bffd3c746341c9dd0db4830d91c0c9b4702ee5e6 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 4 Aug 2015 06:54:58 +0000 Subject: [PATCH 03/21] Scrut fixes --- html/includes/api_functions.inc.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/html/includes/api_functions.inc.php b/html/includes/api_functions.inc.php index 83f99e9b1..74762aecf 100644 --- a/html/includes/api_functions.inc.php +++ b/html/includes/api_functions.inc.php @@ -879,32 +879,25 @@ function list_bills() { foreach (dbFetchRows("SELECT `bills`.*,COUNT(port_id) AS `ports_total` FROM `bills` LEFT JOIN `bill_ports` ON `bill_ports`.`bill_id`=`bills`.`bill_id` $sql GROUP BY `bill_name`,`bill_ref` ORDER BY `bill_name`",$param) as $bill) { $day_data = getDates($bill['bill_day']); - $ports_total = $bill['ports_total']; - $datefrom = $day_data['0']; - $dateto = $day_data['1']; $rate_data = $bill; - $rate_95th = $rate_data['rate_95th']; - $dir_95th = $rate_data['dir_95th']; - $total_data = $rate_data['total_data']; - $rate_average = $rate_data['rate_average']; + $allowed = ''; + $used = ''; + $percent = ''; + $overuse = ''; if ($bill['bill_type'] == "cdr") { - $type = "CDR"; $allowed = format_si($bill['bill_cdr'])."bps"; $used = format_si($rate_data['rate_95th'])."bps"; $percent = round(($rate_data['rate_95th'] / $bill['bill_cdr']) * 100,2); - $background = get_percentage_colours($percent); $overuse = $rate_data['rate_95th'] - $bill['bill_cdr']; $overuse = (($overuse <= 0) ? "-" : format_si($overuse)); } elseif ($bill['bill_type'] == "quota") { - $type = "Quota"; $allowed = format_bytes_billing($bill['bill_quota']); $used = format_bytes_billing($rate_data['total_data']); $percent = round(($rate_data['total_data'] / ($bill['bill_quota'])) * 100,2); - $background = get_percentage_colours($percent); $overuse = $rate_data['total_data'] - $bill['bill_quota']; - $overuse = (($overuse <= 0) ? "-" : format_bytes_billing($overus)); + $overuse = (($overuse <= 0) ? "-" : format_bytes_billing($overuse)); } $bill['allowed'] = $allowed; $bill['used'] = $used; @@ -913,7 +906,14 @@ function list_bills() { $bills[] = $bill; } $count = count($bills); - $output = array("status" => $status, "err-msg" => $err_msg, "count" => $count, "bills" => $bills); + $output = array( + 'status' => $status, + 'message' => $message, + 'err-msg' => $err_msg, + 'count' => $count, + 'bills' => $bills + ); + $app->response->setStatus($code); $app->response->headers->set('Content-Type', 'application/json'); echo _json_encode($output); } From 8d39d2045da46e2f0a63f7086620870a273d865d Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 4 Aug 2015 19:51:06 +0000 Subject: [PATCH 04/21] Finished device storage page edit --- html/forms/storage-update.inc.php | 2 +- html/pages/device/edit/storage.inc.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/html/forms/storage-update.inc.php b/html/forms/storage-update.inc.php index 3be5ea4b4..200a8f3d6 100644 --- a/html/forms/storage-update.inc.php +++ b/html/forms/storage-update.inc.php @@ -29,7 +29,7 @@ elseif (!is_numeric($data)) { $message = 'Missing value'; } else { - if (dbUpdate(array('storage_perc_warn'=>$data), 'storage', '`storage_id`=? AND `device_id`=?',array($storage_id,$device))) { + if (dbUpdate(array('storage_perc_warn'=>$data), 'storage', '`storage_id`=? AND `device_id`=?',array($storage_id,$device_id))) { $message = 'Storage information updated'; $status = 'ok'; } diff --git a/html/pages/device/edit/storage.inc.php b/html/pages/device/edit/storage.inc.php index 7ab0337db..e32dd0684 100644 --- a/html/pages/device/edit/storage.inc.php +++ b/html/pages/device/edit/storage.inc.php @@ -55,7 +55,6 @@ var device_id = $(this).data("device_id"); var storage_id = $(this).data("storage_id"); var data = $(this).val(); - alert(device_id + ' ' + storage_id + ' ' + data); var $this = $(this); $.ajax({ type: 'POST', @@ -69,14 +68,14 @@ $this.closest('.form-group').removeClass('has-success'); }, 2000); } else { - $(this).closest('.form-group').addClass('has-error'); + $this.closest('.form-group').addClass('has-error'); setTimeout(function () { $this.closest('.form-group').removeClass('has-error'); }, 2000); } }, error: function () { - $(this).closest('.form-group').addClass('has-error'); + $this.closest('.form-group').addClass('has-error'); setTimeout(function () { $this.closest('.form-group').removeClass('has-error'); }, 2000); From 26174ed8824845e82602fd506ed28c3d7e276730 Mon Sep 17 00:00:00 2001 From: laf Date: Thu, 6 Aug 2015 19:18:11 +0000 Subject: [PATCH 05/21] Two fixes for mysql strict mode --- html/forms/create-alert-item.inc.php | 2 +- html/forms/update-dashboard-config.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/html/forms/create-alert-item.inc.php b/html/forms/create-alert-item.inc.php index 1d3ae7e77..d1461e64c 100644 --- a/html/forms/create-alert-item.inc.php +++ b/html/forms/create-alert-item.inc.php @@ -73,7 +73,7 @@ else if (validate_device_id($_POST['device_id']) || $_POST['device_id'] == '-1' $device_id = ':'.$device_id; } - if (dbInsert(array('device_id' => $device_id, 'rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'name' => $name), 'alert_rules')) { + if (dbInsert(array('device_id' => $device_id, 'rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'disabled' => 0, 'name' => $name), 'alert_rules')) { $update_message = "Added Rule: $name: $rule"; if (is_array($_POST['maps'])) { foreach ($_POST['maps'] as $target) { diff --git a/html/forms/update-dashboard-config.inc.php b/html/forms/update-dashboard-config.inc.php index 127e16475..c2760adb5 100644 --- a/html/forms/update-dashboard-config.inc.php +++ b/html/forms/update-dashboard-config.inc.php @@ -30,7 +30,7 @@ elseif ($sub_type == 'add' && is_numeric($widget_id)) { $widget = dbFetchRow('SELECT * FROM `widgets` WHERE `widget_id`=?', array($widget_id)); if (is_array($widget)) { list($x,$y) = explode(',',$widget['base_dimensions']); - $item_id = dbInsert(array('user_id'=>$_SESSION['user_id'],'widget_id'=>$widget_id,'title'=>$widget['widget_title'],'size_x'=>$x,'size_y'=>$y),'users_widgets'); + $item_id = dbInsert(array('user_id'=>$_SESSION['user_id'],'widget_id'=>$widget_id, 'col'=>1,'row'=>1,'refresh'=>60,'title'=>$widget['widget_title'],'size_x'=>$x,'size_y'=>$y),'users_widgets'); if (is_numeric($item_id)) { $extra = array('widget_id'=>$item_id,'title'=>$widget['widget_title'],'widget'=>$widget['widget'],'size_x'=>$x,'size_y'=>$y); $status = 'ok'; From 75a7f4833e26aae998878fa32c8c68d5c9e8b7d6 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 8 Aug 2015 09:43:28 +0000 Subject: [PATCH 06/21] Updated gridster variables to be custom per widget --- html/includes/common/alerts.inc.php | 8 ++++---- html/includes/common/eventlog.inc.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/html/includes/common/alerts.inc.php b/html/includes/common/alerts.inc.php index 7f347f916..0dabec69d 100644 --- a/html/includes/common/alerts.inc.php +++ b/html/includes/common/alerts.inc.php @@ -22,7 +22,7 @@ $common_output[] = ' From c652cb652e9db5be3bad4978b9cd67369dce0c01 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 11 Aug 2015 12:32:54 +0000 Subject: [PATCH 14/21] Added serial,version, cpu and mem for zywall --- includes/discovery/mempools/zywall.inc.php | 22 +++++++++++++++++++ includes/discovery/processors/zywall.inc.php | 23 ++++++++++++++++++++ includes/polling/os/zywall.inc.php | 3 +++ 3 files changed, 48 insertions(+) create mode 100644 includes/discovery/mempools/zywall.inc.php create mode 100644 includes/discovery/processors/zywall.inc.php diff --git a/includes/discovery/mempools/zywall.inc.php b/includes/discovery/mempools/zywall.inc.php new file mode 100644 index 000000000..ad220d853 --- /dev/null +++ b/includes/discovery/mempools/zywall.inc.php @@ -0,0 +1,22 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($device['os'] == 'zywall') { + echo 'Zywall mempool: '; + $oid = '.1.3.6.1.4.1.890.1.6.22.1.2.0'; + $usage = snmp_get($device,$oid, '-Ovq'); + if (is_numeric($usage)) { + discover_mempool($valid_mempool, $device, 10, 'zywall', 'Memory', '1', null, null); + } +} diff --git a/includes/discovery/processors/zywall.inc.php b/includes/discovery/processors/zywall.inc.php new file mode 100644 index 000000000..045e9f512 --- /dev/null +++ b/includes/discovery/processors/zywall.inc.php @@ -0,0 +1,23 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($device['os'] == 'zywall') { + echo 'Zywall Processors: '; + $descr = 'Processor'; + $oid = '.1.3.6.1.4.1.890.1.6.22.1.1.0'; + $usage = snmp_get($device, $oid, '-OQUvs'); + if (is_numeric($usage)) { + discover_processor($valid['processor'], $device, $oid, '0', 'zywall', $descr, 1, $usage, null, null); + } +} diff --git a/includes/polling/os/zywall.inc.php b/includes/polling/os/zywall.inc.php index 9b67f5f78..ad834f634 100644 --- a/includes/polling/os/zywall.inc.php +++ b/includes/polling/os/zywall.inc.php @@ -1,3 +1,6 @@ Date: Tue, 11 Aug 2015 16:35:29 +0200 Subject: [PATCH 15/21] IOS-XR does not provide dbm values for transceivers so we calculate them from mWatts entries Fix #1641 --- includes/discovery/cisco-entity-sensor.inc.php | 15 ++++++++++++++- includes/polling/functions.inc.php | 7 +++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/includes/discovery/cisco-entity-sensor.inc.php b/includes/discovery/cisco-entity-sensor.inc.php index 881c6dd36..e7053a20d 100644 --- a/includes/discovery/cisco-entity-sensor.inc.php +++ b/includes/discovery/cisco-entity-sensor.inc.php @@ -163,8 +163,21 @@ if ($device['os_group'] == 'cisco') { } //end if if ($ok) { - // echo("\n".$valid['sensor'].", $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current"); discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entry['entSensorMeasuredEntity']); + #Cisco IOS-XR : add a fake sensor to graph as dbm + if ($type == "power" and $device['os'] == "iosxr" and preg_match ("/Transceiver (R|T)x/i", $descr) ) { + // convert Watts to dbm + $type = "dbm"; + $limit_low = 10 * log10($limit_low*1000); + $warn_limit_low = 10 * log10($warn_limit_low*1000); + $warn_limit = 10 * log10($warn_limit*1000); + $limit = 10 * log10($limit*1000); + $current = round(10 * log10($current*1000),3); + $multiplier = 1; + $divisor = 1; + //echo("\n".$valid['sensor'].", $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current"); + discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entry['entSensorMeasuredEntity']); + } } $cisco_entity_temperature = 1; diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index 4eb12609b..d148fa021 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -44,6 +44,13 @@ function poll_sensor($device, $class, $unit) { else if ($class == 'state') { $sensor_value = trim(str_replace('"', '', snmp_walk($device, $sensor['sensor_oid'], '-Oevq', 'SNMPv2-MIB'))); } + else if ($class == 'dbm') { + $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB$mib"))); + //iosxr does not expose dbm values through SNMP so we convert Watts to dbm to have a nice graph to show + if ($device['os'] == "iosxr") { + $sensor_value = round(10*log10($sensor_value/1000),3); + } + } else { if ($sensor['sensor_type'] == 'apc') { $sensor_value = trim(str_replace('"', '', snmp_walk($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB:PowerNet-MIB$mib"))); From efee54043ab8227ca39601cb82b876c3fdc685c8 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 11 Aug 2015 16:05:04 +0000 Subject: [PATCH 16/21] Swapped 2012 Datacenter / Non-DC around --- includes/polling/os/windows.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/polling/os/windows.inc.php b/includes/polling/os/windows.inc.php index 9a9330e61..c31e1741e 100644 --- a/includes/polling/os/windows.inc.php +++ b/includes/polling/os/windows.inc.php @@ -120,7 +120,7 @@ else if ($poll_device['sysObjectID'] == '.1.3.6.1.4.1.311.1.1.3.1.2') { } if (strstr($poll_device['sysDescr'], 'Build 9600')) { - $version = 'Server 2012 R2 (NT 6.3)'; + $version = 'Server 2012 R2 Datacenter (NT 6.3)'; } } @@ -162,7 +162,7 @@ else if ($poll_device['sysObjectID'] == '.1.3.6.1.4.1.311.1.1.3.1.3') { } if (strstr($poll_device['sysDescr'], 'Build 9600')) { - $version = 'Server 2012 R2 Datacenter (NT 6.3)'; + $version = 'Server 2012 R2 (NT 6.3)'; } }//end if From 5b7e09b72996a3ff90a236ec486cbd5a9dcb37e7 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 11 Aug 2015 16:29:59 +0000 Subject: [PATCH 17/21] Updated alerting docs to cross out config.php options to push people towards Webui --- doc/Extensions/Alerting.md | 40 +++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/doc/Extensions/Alerting.md b/doc/Extensions/Alerting.md index 8b0f25675..aec8ee6e5 100644 --- a/doc/Extensions/Alerting.md +++ b/doc/Extensions/Alerting.md @@ -36,6 +36,8 @@ Table of Content: LibreNMS includes a highly customizable alerting system. The system requires a set of user-defined rules to evaluate the situation of each device, port, service or any other entity. +> You can configure all options for alerting and transports via the WebUI, config options in this document are crossed out but left for reference. + This document only covers the usage of it. See the [DEVELOPMENT.md](https://github.com/f0o/glowing-tyrion/blob/master/DEVELOPMENT.md) for code-documentation. #
Rules @@ -125,34 +127,41 @@ Alert sent to: {foreach %contacts}%value <%key> {/foreach} # Transports -Transports are located within `$config['install_dir']/includes/alerts/transports.*.php` and defined as well as configured via `$config['alert']['transports']['Example'] = 'Some Options'`. +Transports are located within `$config['install_dir']/includes/alerts/transports.*.php` and defined as well as configured via ~~`$config['alert']['transports']['Example'] = 'Some Options'`~~. Contacts will be gathered automatically and passed to the configured transports. -By default the Contacts will be only gathered when the alert triggers and will ignore future changes in contacts for the incident. If you want contacts to be re-gathered before each dispatch, please set `$config['alert']['fixed-contacts'] = false;` in your config.php. +By default the Contacts will be only gathered when the alert triggers and will ignore future changes in contacts for the incident. If you want contacts to be re-gathered before each dispatch, please set ~~`$config['alert']['fixed-contacts'] = false;`~~ in your config.php. The contacts will always include the `SysContact` defined in the Device's SNMP configuration and also every LibreNMS-User that has at least `read`-permissions on the entity that is to be alerted. At the moment LibreNMS only supports Port or Device permissions. You can exclude the `SysContact` by setting: +~~ ```php $config['alert']['syscontact'] = false; ``` +~ To include users that have `Global-Read` or `Administrator` permissions it is required to add these additions to the `config.php` respectively: +~ ```php $config['alert']['globals'] = true; //Include Global-Read into alert-contacts $config['alert']['admins'] = true; //Include Adminstrators into alert-contacts ``` +~~ ## E-Mail > You can configure these options within the WebUI now, please avoid setting these options within config.php -E-Mail transport is enabled with adding the following to your `config.php`: +E-Mail transport is enabled with adding the following to your `config.php`: +~ ```php $config['alert']['transports']['mail'] = true; ``` +~~ The E-Mail transports uses the same email-configuration like the rest of LibreNMS. As a small reminder, here is it's configuration directives including defaults: +~~ ```php $config['email_backend'] = 'mail'; // Mail backend. Allowed: "mail" (PHP's built-in), "sendmail", "smtp". $config['email_from'] = NULL; // Mail from. Default: "ProjectName" @@ -169,13 +178,14 @@ $config['email_smtp_password'] = NULL; // Password f $config['alert']['default_only'] = false; //Only issue to default_mail $config['alert']['default_mail'] = ''; //Default email ``` +~~ ## API > You can configure these options within the WebUI now, please avoid setting these options within config.php API transports definitions are a bit more complex than the E-Mail configuration. -The basis for configuration is `$config['alert']['transports']['api'][METHOD]` where `METHOD` can be `get`,`post` or `put`. +The basis for configuration is ~~`$config['alert']['transports']['api'][METHOD]`~~ where `METHOD` can be `get`,`post` or `put`. This basis has to contain an array with URLs of each API to call. The URL can have the same placeholders as defined in the [Template-Syntax](#templates-syntax). If the `METHOD` is `get`, all placeholders will be URL-Encoded. @@ -183,9 +193,11 @@ The API transport uses cURL to call the APIs, therefore you might need to instal __Note__: it is highly recommended to define own [Templates](#templates) when you want to use the API transport. The default template might exceed URL-length for GET requests and therefore cause all sorts of errors. Example: +~~ ```php $config['alert']['transports']['api']['get'][] = "https://api.thirdparti.es/issue?apikey=abcdefg&subject=%title"; ``` +~~ ## Nagios Compatible @@ -193,19 +205,23 @@ $config['alert']['transports']['api']['get'][] = "https://api.thirdparti.es/issu The nagios transport will feed a FIFO at the defined location with the same format that nagios would. This allows you to use other Alerting-Systems to work with LibreNMS, for example [Flapjack](http://flapjack.io). +~~ ```php $config['alert']['transports']['nagios'] = "/path/to/my.fifo"; //Flapjack expects it to be at '/var/cache/nagios3/event_stream.fifo' ``` +~~ ## IRC > You can configure these options within the WebUI now, please avoid setting these options within config.php The IRC transports only works together with the LibreNMS IRC-Bot. -Configuration of the LibreNMS IRC-Bot is described [here](https://github.com/librenms/librenms/blob/master/doc/Extensions/IRC-Bot.md). +Configuration of the LibreNMS IRC-Bot is described [here](https://github.com/librenms/librenms/blob/master/doc/Extensions/IRC-Bot.md). +~~ ```php $config['alert']['transports']['irc'] = true; ``` +~~ ## Slack @@ -213,12 +229,14 @@ $config['alert']['transports']['irc'] = true; The Slack transport will POST the alert message to your Slack Incoming WebHook, you are able to specify multiple webhooks along with the relevant options to go with it. All options are optional, the only required value is for url, without this then no call to Slack will be made. Below is an example of how to send alerts to two channels with different customised options: +~~ ```php $config['alert']['transports']['slack'][] = array('url' => "https://hooks.slack.com/services/A12B34CDE/F56GH78JK/L901LmNopqrSTUVw2w3XYZAB4C", 'channel' => '#Alerting'); $config['alert']['transports']['slack'][] = array('url' => "https://hooks.slack.com/services/A12B34CDE/F56GH78JK/L901LmNopqrSTUVw2w3XYZAB4C", 'channel' => '@john', 'username' => 'LibreNMS', 'icon_emoji' => ':ghost:'); ``` +~~ ## HipChat @@ -249,6 +267,7 @@ for details on acceptable values. Below are two examples of sending messages to a HipChat room. +~~ ```php $config['alert']['transports']['hipchat'][] = array("url" => "https://api.hipchat.com/v1/rooms/message?auth_token=9109jawregoaih", "room_id" => "1234567", @@ -261,6 +280,7 @@ $config['alert']['transports']['hipchat'][] = array("url" => "https://api.hipcha "notify" => 1, "message_format" => "text"); ``` +~~ > Note: The default message format for HipChat messages is HTML. It is > recommended that you specify the `text` message format to prevent unexpected @@ -277,9 +297,11 @@ All you need is to create a Service with type Generic API on your PagerDuty dash Now copy your API-Key from the newly created Service and setup the transport like: +~~ ```php $config['alert']['transports']['pagerduty'] = 'MYAPIKEYGOESHERE'; ``` +~~ That's it! @@ -293,15 +315,18 @@ Firstly you need to create a new Application (called LibreNMS, for example) in y Now copy your API Token/Key from the newly created Application and setup the transport in your config.php like: +~~ ```php $config['alert']['transports']['pushover'][] = array( "appkey" => 'APPLICATIONAPIKEYGOESHERE', "userkey" => 'USERKEYGOESHERE', ); ``` +~~ To modify the Critical alert sound, add the 'sound_critical' parameter, example: +~~ ```php $config['alert']['transports']['pushover'][] = array( "appkey" => 'APPLICATIONAPIKEYGOESHERE', @@ -309,26 +334,31 @@ $config['alert']['transports']['pushover'][] = array( "sound_critical" => 'siren', ); ``` +~~ ## Boxcar Enabling Boxcar support is super easy. Copy your access token from the Boxcar app or from the Boxcar.io website and setup the transport in your config.php like: +~~ ```php $config['alert']['transports']['boxcar'][] = array( "access_token" => 'ACCESSTOKENGOESHERE', ); ``` +~~ To modify the Critical alert sound, add the 'sound_critical' parameter, example: +~~ ```php $config['alert']['transports']['boxcar'][] = array( "access_token" => 'ACCESSTOKENGOESHERE', "sound_critical" => 'detonator-charge', ); ``` +~~ # Entities From f260fccacf1ec6880808cefb18679a51080a137f Mon Sep 17 00:00:00 2001 From: Mickael Marchand Date: Tue, 11 Aug 2015 19:34:34 +0200 Subject: [PATCH 18/21] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md --- AUTHORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index ea14efa06..99b1fb4ab 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -23,7 +23,7 @@ Contributors to LibreNMS: - Stuart Henderson (sthen) - Filippo Giunchedi (filippog) - Lasse Leegaard (lasseleegaard) -- Mickael Marchand (mmarchand) +- Mickael Marchand (mmarchand) - Mohammad Al-Shami (mohshami) - Rudy Hardeman (zarya) - Arjit Chaudhary (arjit.c@gmail.com) (arjitc) From b1fcc3c84bfb537ab54719364e7e76ea2503a5d6 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 11 Aug 2015 20:11:04 +0000 Subject: [PATCH 19/21] updated firmware to version --- includes/polling/os/zywall.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/polling/os/zywall.inc.php b/includes/polling/os/zywall.inc.php index ad834f634..dbf822e6f 100644 --- a/includes/polling/os/zywall.inc.php +++ b/includes/polling/os/zywall.inc.php @@ -2,5 +2,5 @@ $hardware = $poll_device['sysDescr']; -$firmware = snmp_get($device, '.1.3.6.1.4.1.890.1.15.3.1.6.0', '-Osqv'); +$version = snmp_get($device, '.1.3.6.1.4.1.890.1.15.3.1.6.0', '-Osqv'); $serial = snmp_get($device, '1.3.6.1.4.1.890.1.15.3.1.12.0', '-Osqv'); From 936fb32a9ed48e6fc03642ee370c64affe339eb2 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 11 Aug 2015 20:20:02 +0000 Subject: [PATCH 20/21] Used oid instead of static --- includes/discovery/mempools/zywall.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/discovery/mempools/zywall.inc.php b/includes/discovery/mempools/zywall.inc.php index ad220d853..94a506fd8 100644 --- a/includes/discovery/mempools/zywall.inc.php +++ b/includes/discovery/mempools/zywall.inc.php @@ -17,6 +17,6 @@ if ($device['os'] == 'zywall') { $oid = '.1.3.6.1.4.1.890.1.6.22.1.2.0'; $usage = snmp_get($device,$oid, '-Ovq'); if (is_numeric($usage)) { - discover_mempool($valid_mempool, $device, 10, 'zywall', 'Memory', '1', null, null); + discover_mempool($valid_mempool, $device, $oid, 'zywall', 'Memory', '1', null, null); } } From 945ca7f2eafdc4fb35fcf2a5bc5e16546761a356 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Tue, 11 Aug 2015 21:25:23 +0100 Subject: [PATCH 21/21] Revert "changes needed to run under web server subdirectory" --- AUTHORS.md | 2 -- doc/Extensions/Sub-Directory.md | 22 --------------- html/css/styles.css | 2 +- html/includes/authenticate.inc.php | 2 +- html/includes/common/alerts.inc.php | 4 +-- html/includes/common/eventlog.inc.php | 2 +- html/includes/modal/alert_schedule.inc.php | 4 +-- html/includes/modal/alert_template.inc.php | 4 +-- .../modal/attach_alert_template.inc.php | 4 +-- html/includes/modal/delete_alert_map.inc.php | 2 +- html/includes/modal/delete_alert_rule.inc.php | 2 +- .../modal/delete_alert_template.inc.php | 2 +- .../modal/delete_device_group.inc.php | 2 +- html/includes/modal/new_alert_map.inc.php | 4 +-- html/includes/modal/new_alert_rule.inc.php | 4 +-- html/includes/modal/new_device_group.inc.php | 4 +-- html/includes/modal/poller_groups.inc.php | 6 ++-- .../modal/remove_alert_schedule.inc.php | 2 +- html/includes/print-alert-rules.php | 4 +-- html/includes/print-interface.inc.php | 2 +- html/includes/print-menubar.php | 6 ++-- html/includes/vars.inc.php | 2 -- html/index.php | 2 +- html/install.php | 3 +- html/pages/about.inc.php | 4 +-- html/pages/alert-log.inc.php | 2 +- html/pages/alert-schedule.inc.php | 2 +- html/pages/api-access.inc.php | 6 ++-- html/pages/bill.inc.php | 2 +- html/pages/bills.inc.php | 2 +- html/pages/device/edit/device.inc.php | 2 +- html/pages/device/edit/health.inc.php | 8 +++--- html/pages/device/edit/modules.inc.php | 4 +-- html/pages/device/edit/ports.inc.php | 4 +-- html/pages/device/port.inc.php | 10 +++---- html/pages/device/processes.inc.php | 2 +- html/pages/devices.inc.php | 2 +- html/pages/front/tiles.php | 10 +++---- html/pages/health/mempool.inc.php | 2 +- html/pages/health/processor.inc.php | 2 +- html/pages/health/storage.inc.php | 2 +- html/pages/iftype.inc.php | 2 +- html/pages/inventory.inc.php | 2 +- html/pages/poll-log.inc.php | 2 +- html/pages/pollers.inc.php | 2 +- html/pages/ports.inc.php | 2 +- html/pages/preferences.inc.php | 8 +++--- html/pages/search/arp.inc.php | 2 +- html/pages/search/ipv4.inc.php | 2 +- html/pages/search/ipv6.inc.php | 2 +- html/pages/search/mac.inc.php | 2 +- html/pages/search/packages.inc.php | 2 +- html/pages/settings/alerting.inc.php | 28 +++++++++---------- html/pages/syslog.inc.php | 2 +- includes/common.php | 4 +-- 55 files changed, 98 insertions(+), 123 deletions(-) delete mode 100644 doc/Extensions/Sub-Directory.md diff --git a/AUTHORS.md b/AUTHORS.md index ac6443655..99b1fb4ab 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -45,8 +45,6 @@ Contributors to LibreNMS: - Aaron Daniels (adaniels21487) - David M. Syzdek (syzdek) - Gerben Meijer (infernix) -- Michael Newton (miken32) - [1]: http://observium.org/ "Observium web site" diff --git a/doc/Extensions/Sub-Directory.md b/doc/Extensions/Sub-Directory.md deleted file mode 100644 index d79c07a45..000000000 --- a/doc/Extensions/Sub-Directory.md +++ /dev/null @@ -1,22 +0,0 @@ -To run LibreNMS under a subdirectory on your Apache server, the directives for the LibreNMS directory are placed in the base server configuration, or in a virtual host -container of your choosing. If using a virtual host, place the directives in the file where the virtual host is configured. If using the base server on RHEL distributions -(CentOS, Scientific Linux, etc.) the directives can be placed in `/etc/httpd/conf.d/librenms.conf`. For Debian distributions (Ubuntu, etc.) place the directives in -`/etc/apache2/sites-available/default`. - -```apache -#This directive is never put inside a virtual host -AllowEncodedSlashes On - -#These directives can be inside a virtual host or in the base server configuration -Alias /librenms /opt/librenms/html - - - AllowOverride All - Options FollowSymLinks MultiViews - -``` - -The `RewriteBase` directive in `html/.htaccess` must be rewritten to reference the subdirectory name. Assuming LibreNMS is running at http://example.com/librenms/, -you will need to change `RewriteBase /` to `RewriteBase /librenms`. - -Finally, ensure `$config["base_url"]` -- if configured -- is correct as well. diff --git a/html/css/styles.css b/html/css/styles.css index d68b1fa1f..80d53766e 100644 --- a/html/css/styles.css +++ b/html/css/styles.css @@ -63,7 +63,7 @@ ul ul ul { list-style: square outside; } } .submit { - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAATCAIAAAA4QDsKAAAABGdBTUEAALGPC/xhBQAAAEZJREFUeJyVjMEJACEQA2dlSxD7r2/xcdhAfNwJig/PfJIhISaJocQk/9ccwTDAEYAQ4K99sylfXm+gtbFl1p4WNUouUaMDPUI2q6SigUIAAAAASUVORK5CYII='); + background-image: url('/images/submitbg.png'); background-position: 0 100%; border-color: #B2B2B2 #525252 #525252 #B2B2B2; } diff --git a/html/includes/authenticate.inc.php b/html/includes/authenticate.inc.php index f1f5087d2..316fcde5c 100644 --- a/html/includes/authenticate.inc.php +++ b/html/includes/authenticate.inc.php @@ -33,7 +33,7 @@ if ($vars['page'] == 'logout' && $_SESSION['authenticated']) { setcookie('auth', '', (time() - 60 * 60 * 24 * $config['auth_remember']), '/'); session_destroy(); $auth_message = 'Logged Out'; - header('Location: ' . $config['base_url']); + header('Location: /'); exit; } diff --git a/html/includes/common/alerts.inc.php b/html/includes/common/alerts.inc.php index b135ee48f..0dabec69d 100644 --- a/html/includes/common/alerts.inc.php +++ b/html/includes/common/alerts.inc.php @@ -31,7 +31,7 @@ var alerts_grid = $("#alerts").bootgrid({ device_id: \'' . $device['device_id'] .'\' }; }, - url: "ajax_table.php", + url: "/ajax_table.php", formatters: { "status": function(column,row) { return "

" + row.msg + "

"; @@ -70,7 +70,7 @@ var alerts_grid = $("#alerts").bootgrid({ var state = $(this).data("state"); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: { type: "ack-alert", alert_id: alert_id, state: state }, success: function(msg){ $("#message").html(\'
\'+msg+\'
\'); diff --git a/html/includes/common/eventlog.inc.php b/html/includes/common/eventlog.inc.php index 7ce1590c0..8640559e8 100644 --- a/html/includes/common/eventlog.inc.php +++ b/html/includes/common/eventlog.inc.php @@ -24,7 +24,7 @@ var eventlog_grid = $("#eventlog").bootgrid({ type: "' .mres($vars['type']) .'", }; }, - url: "ajax_table.php" + url: "/ajax_table.php" }); diff --git a/html/includes/modal/alert_schedule.inc.php b/html/includes/modal/alert_schedule.inc.php index 01474b7c9..b726a219f 100644 --- a/html/includes/modal/alert_schedule.inc.php +++ b/html/includes/modal/alert_schedule.inc.php @@ -102,7 +102,7 @@ $('#schedule-maintenance').on('show.bs.modal', function (event) { if (schedule_id > 0) { $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: { type: "schedule-maintenance", sub_type: "parse-maintenance", schedule_id: schedule_id }, dataType: "json", success: function(output) { @@ -124,7 +124,7 @@ $('#sched-submit').click('', function(e) { e.preventDefault(); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: $('form.schedule-maintenance-form').serialize(), dataType: "json", success: function(data){ diff --git a/html/includes/modal/alert_template.inc.php b/html/includes/modal/alert_template.inc.php index 71574ba6f..bd034952e 100644 --- a/html/includes/modal/alert_template.inc.php +++ b/html/includes/modal/alert_template.inc.php @@ -107,7 +107,7 @@ $('#alert-template').on('show.bs.modal', function (event) { $('#template_id').val(template_id); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: { type: "parse-alert-template", template_id: template_id }, dataType: "json", success: function(output) { @@ -125,7 +125,7 @@ $('#create-template').click('', function(e) { var name = $("#name").val(); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: { type: "alert-templates", template: template , name: name, template_id: template_id}, dataType: "html", success: function(msg){ diff --git a/html/includes/modal/attach_alert_template.inc.php b/html/includes/modal/attach_alert_template.inc.php index 409c6405c..3e16014cc 100644 --- a/html/includes/modal/attach_alert_template.inc.php +++ b/html/includes/modal/attach_alert_template.inc.php @@ -60,7 +60,7 @@ $('#attach-alert-template').on('show.bs.modal', function(e) { $("#template_id").val(template_id); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: { type: "parse-template-rules", template_id: template_id }, dataType: "json", success: function(output) { @@ -88,7 +88,7 @@ $('#alert-template-attach').click('', function(event) { var rules = items.join(','); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: { type: "attach-alert-template", template_id: template_id, rule_id: rules }, dataType: "html", success: function(msg) { diff --git a/html/includes/modal/delete_alert_map.inc.php b/html/includes/modal/delete_alert_map.inc.php index ee0d0fd13..930e1b7f8 100644 --- a/html/includes/modal/delete_alert_map.inc.php +++ b/html/includes/modal/delete_alert_map.inc.php @@ -50,7 +50,7 @@ $('#alert-map-removal').click('', function(event) { var map_id = $("#map_id").val(); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: { type: "delete-alert-map", map_id: map_id }, dataType: "html", success: function(msg) { diff --git a/html/includes/modal/delete_alert_rule.inc.php b/html/includes/modal/delete_alert_rule.inc.php index fa5951b5b..fdbe70077 100644 --- a/html/includes/modal/delete_alert_rule.inc.php +++ b/html/includes/modal/delete_alert_rule.inc.php @@ -50,7 +50,7 @@ $('#alert-rule-removal').click('', function(event) { var alert_id = $("#alert_id").val(); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: { type: "delete-alert-rule", alert_id: alert_id }, dataType: "html", success: function(msg) { diff --git a/html/includes/modal/delete_alert_template.inc.php b/html/includes/modal/delete_alert_template.inc.php index 41413a1b9..5161ea5be 100644 --- a/html/includes/modal/delete_alert_template.inc.php +++ b/html/includes/modal/delete_alert_template.inc.php @@ -50,7 +50,7 @@ $('#alert-template-removal').click('', function(event) { var template_id = $("#template_id").val(); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: { type: "delete-alert-template", template_id: template_id }, dataType: "html", success: function(msg) { diff --git a/html/includes/modal/delete_device_group.inc.php b/html/includes/modal/delete_device_group.inc.php index 77c0e70e8..42e504cd9 100644 --- a/html/includes/modal/delete_device_group.inc.php +++ b/html/includes/modal/delete_device_group.inc.php @@ -50,7 +50,7 @@ $('#device-group-removal').click('', function(event) { var group_id = $("#group_id").val(); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: { type: "delete-device-group", group_id: group_id }, dataType: "html", success: function(msg) { diff --git a/html/includes/modal/new_alert_map.inc.php b/html/includes/modal/new_alert_map.inc.php index c9ec494d4..b414d730d 100644 --- a/html/includes/modal/new_alert_map.inc.php +++ b/html/includes/modal/new_alert_map.inc.php @@ -57,7 +57,7 @@ $('#create-map').on('show.bs.modal', function (event) { $('#map_id').val(map_id); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: { type: "parse-alert-map", map_id: map_id }, dataType: "json", success: function(output) { @@ -166,7 +166,7 @@ $('#map-submit').click('', function(e) { e.preventDefault(); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: $('form.maps-form').serialize(), success: function(msg){ $("#message").html('
'+msg+'
'); diff --git a/html/includes/modal/new_alert_rule.inc.php b/html/includes/modal/new_alert_rule.inc.php index 7868a0b00..5d4ff6076 100644 --- a/html/includes/modal/new_alert_rule.inc.php +++ b/html/includes/modal/new_alert_rule.inc.php @@ -184,7 +184,7 @@ $('#create-alert').on('show.bs.modal', function (event) { } $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: { type: "parse-alert-rule", alert_id: alert_id }, dataType: "json", success: function(output) { @@ -347,7 +347,7 @@ $('#rule-submit').click('', function(e) { e.preventDefault(); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: $('form.alerts-form').serialize(), success: function(msg){ if(msg.indexOf("ERROR:") <= -1) { diff --git a/html/includes/modal/new_device_group.inc.php b/html/includes/modal/new_device_group.inc.php index 79fee676d..d1dc5d6f4 100644 --- a/html/includes/modal/new_device_group.inc.php +++ b/html/includes/modal/new_device_group.inc.php @@ -119,7 +119,7 @@ $('#create-group').on('show.bs.modal', function (event) { }); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: { type: "parse-device-group", group_id: group_id }, dataType: "json", success: function(output) { @@ -192,7 +192,7 @@ $('#group-submit').click('', function(e) { e.preventDefault(); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: $('form.group-form').serialize(), success: function(msg){ if(msg.indexOf("ERROR:") <= -1) { diff --git a/html/includes/modal/poller_groups.inc.php b/html/includes/modal/poller_groups.inc.php index 9482c9994..ccbfe2245 100644 --- a/html/includes/modal/poller_groups.inc.php +++ b/html/includes/modal/poller_groups.inc.php @@ -93,7 +93,7 @@ $('#group-removal').click('', function(e) { group_id = $("#group_id").val(); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: $('form.remove_group_form').serialize() , success: function(msg) { $("#thanks").html('
'+msg+'
'); @@ -115,7 +115,7 @@ $('#poller-groups').on('show.bs.modal', function (event) { $('#group_id').val(group_id); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: { type: "parse-poller-groups", group_id: group_id }, dataType: "json", success: function(output) { @@ -133,7 +133,7 @@ $('#create-group').click('', function(e) { var group_id = $('#group_id').val(); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: { type: "poller-groups", group_name: group_name, descr: descr, group_id: group_id }, dataType: "html", success: function(msg){ diff --git a/html/includes/modal/remove_alert_schedule.inc.php b/html/includes/modal/remove_alert_schedule.inc.php index f95464db9..0e168ae77 100644 --- a/html/includes/modal/remove_alert_schedule.inc.php +++ b/html/includes/modal/remove_alert_schedule.inc.php @@ -52,7 +52,7 @@ $('#sched-maintenance-removal').click('', function(e) { e.preventDefault(); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: $('form.schedule-maintenance-del').serialize(), dataType: "json", success: function(data){ diff --git a/html/includes/print-alert-rules.php b/html/includes/print-alert-rules.php index 670a57815..f6296b3eb 100644 --- a/html/includes/print-alert-rules.php +++ b/html/includes/print-alert-rules.php @@ -268,7 +268,7 @@ $('#ack-alert').click('', function(e) { var alert_id = $(this).data("alert_id"); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: { type: "ack-alert", alert_id: alert_id }, success: function(msg){ $("#message").html('
'+msg+'
'); @@ -294,7 +294,7 @@ $('input[name="alert-rule"]').on('switchChange.bootstrapSwitch', function(event var orig_class = $(this).data("orig_class"); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: { type: "update-alert-rule", alert_id: alert_id, state: state }, dataType: "html", success: function(msg) { diff --git a/html/includes/print-interface.inc.php b/html/includes/print-interface.inc.php index bfb5d1bd7..26f33fb50 100644 --- a/html/includes/print-interface.inc.php +++ b/html/includes/print-interface.inc.php @@ -30,7 +30,7 @@ else { } if (dbFetchCell('SELECT COUNT(*) FROM `mac_accounting` WHERE `port_id` = ?', array($port['port_id']))) { - $mac = "
'macaccounting'))."'>"; + $mac = " 'macaccounting'))."'>"; } else { $mac = ''; diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index c436d5b7d..54b51213f 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -489,12 +489,12 @@ if ($_SESSION['userlevel'] >= '10') {
  • - + '.$tab['name'].'
  • '; diff --git a/html/pages/ports.inc.php b/html/pages/ports.inc.php index 9a310ea27..edeea9fbe 100644 --- a/html/pages/ports.inc.php +++ b/html/pages/ports.inc.php @@ -55,7 +55,7 @@ foreach ($menu_options as $option => $text) { echo('
    '); ?> - Export CSV | + Export CSV | Update URL | Error: How did you even get here?!
    '; + echo '
    Error: How did you even get here?!
    '; } else { $twofactor = json_decode($twofactor['twofactor'], true); @@ -94,13 +94,13 @@ else { } else { session_destroy(); - echo '
    Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
    '; + echo '
    Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
    '; } }//end if } else { $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); - echo ''; + echo ''; echo '

    Two-Factor Authentication

    '; if (!empty($twofactor['twofactor'])) { $twofactor = json_decode($twofactor['twofactor'], true); @@ -154,7 +154,7 @@ else { echo '
    Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.
    '; } else { - echo '
    Added TwoFactor credentials. Please reload page.
    '; + echo '
    Added TwoFactor credentials. Please reload page.
    '; } } else { diff --git a/html/pages/search/arp.inc.php b/html/pages/search/arp.inc.php index 9f2ed062f..45cd6888a 100644 --- a/html/pages/search/arp.inc.php +++ b/html/pages/search/arp.inc.php @@ -91,7 +91,7 @@ echo '"'.$_POST['address'].'"+'; address: '' }; }, - url: "ajax_table.php" + url: "/ajax_table.php" }); diff --git a/html/pages/search/ipv4.inc.php b/html/pages/search/ipv4.inc.php index 3d4393ff8..843acbd1b 100644 --- a/html/pages/search/ipv4.inc.php +++ b/html/pages/search/ipv4.inc.php @@ -86,7 +86,7 @@ if ($_POST['interface'] == 'Vlan%') { address: '' }; }, - url: "ajax_table.php" + url: "/ajax_table.php" }); diff --git a/html/pages/search/ipv6.inc.php b/html/pages/search/ipv6.inc.php index 2ce8900b2..2b9115013 100644 --- a/html/pages/search/ipv6.inc.php +++ b/html/pages/search/ipv6.inc.php @@ -87,7 +87,7 @@ if ($_POST['interface'] == 'Vlan%') { address: '' }; }, - url: "ajax_table.php" + url: "/ajax_table.php" }); diff --git a/html/pages/search/mac.inc.php b/html/pages/search/mac.inc.php index a73e132b4..f606e4436 100644 --- a/html/pages/search/mac.inc.php +++ b/html/pages/search/mac.inc.php @@ -88,7 +88,7 @@ echo '"'.$_POST['address'].'"+'; address: '' }; }, - url: "ajax_table.php" + url: "/ajax_table.php" }); diff --git a/html/pages/search/packages.inc.php b/html/pages/search/packages.inc.php index 0848fc372..e1ef1675d 100644 --- a/html/pages/search/packages.inc.php +++ b/html/pages/search/packages.inc.php @@ -158,7 +158,7 @@ foreach( $ordered as $name=>$entry ) { if( sizeof($arch) > 0 && sizeof($vers) > 0 ) { ?> - + ',$vers); ?> ',$arch); ?> ',$devs); ?> diff --git a/html/pages/settings/alerting.inc.php b/html/pages/settings/alerting.inc.php index fbe28993a..9282284ee 100644 --- a/html/pages/settings/alerting.inc.php +++ b/html/pages/settings/alerting.inc.php @@ -823,7 +823,7 @@ echo '
    var config_value = $('#new_conf_value').val(); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: {type: "config-item", config_group: "alerting", config_sub_group: "transports", config_name: config_name, config_value: config_value}, dataType: "json", success: function(data){ @@ -859,7 +859,7 @@ echo '
    var config_extra = $('#slack_extra').val(); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: {type: "config-item", action: 'add-slack', config_group: "alerting", config_sub_group: "transports", config_extra: config_extra, config_value: config_value}, dataType: "json", success: function(data){ @@ -897,7 +897,7 @@ echo '
    var config_from = $('#new_from').val(); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: {type: "config-item", action: 'add-hipchat', config_group: "alerting", config_sub_group: "transports", config_extra: config_extra, config_value: config_value, config_room_id: config_room_id, config_from: config_from}, dataType: "json", success: function(data){ @@ -936,7 +936,7 @@ echo '
    var config_userkey = $('#new_userkey').val(); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: {type: "config-item", action: 'add-pushover', config_group: "alerting", config_sub_group: "transports", config_extra: config_extra, config_value: config_value, config_userkey: config_userkey}, dataType: "json", success: function(data){ @@ -974,7 +974,7 @@ echo '
    var config_extra = $('#boxcar_extra').val(); $.ajax({ type: "POST", - url: "ajax_form.php", + url: "/ajax_form.php", data: {type: "config-item", action: 'add-boxcar', config_group: "alerting", config_sub_group: "transports", config_extra: config_extra, config_value: config_value}, dataType: "json", success: function(data){ @@ -1008,7 +1008,7 @@ echo '
    var config_id = $(this).data('config_id'); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: {type: "config-item", action: 'remove', config_id: config_id}, dataType: "json", success: function (data) { @@ -1029,7 +1029,7 @@ echo '
    var config_id = $(this).data('config_id'); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: {type: "config-item", action: 'remove-slack', config_id: config_id}, dataType: "json", success: function (data) { @@ -1050,7 +1050,7 @@ echo '
    var config_id = $(this).data('config_id'); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: {type: "config-item", action: 'remove-hipchat', config_id: config_id}, dataType: "json", success: function (data) { @@ -1071,7 +1071,7 @@ echo '
    var config_id = $(this).data('config_id'); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: {type: "config-item", action: 'remove-pushover', config_id: config_id}, dataType: "json", success: function (data) { @@ -1092,7 +1092,7 @@ echo '
    var config_id = $(this).data('config_id'); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: {type: "config-item", action: 'remove-boxcar', config_id: config_id}, dataType: "json", success: function (data) { @@ -1114,7 +1114,7 @@ echo '
    var config_id = $(this).data("config_id"); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: {type: "update-config-item", config_id: config_id, config_value: state}, dataType: "json", success: function (data) { @@ -1135,7 +1135,7 @@ echo '
    var config_value = $this.val(); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: {type: "update-config-item", config_id: config_id, config_value: config_value}, dataType: "json", success: function (data) { @@ -1167,7 +1167,7 @@ echo '
    var config_value = $this.val(); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: {type: "update-config-item", config_id: config_id, config_value: config_value}, dataType: "json", success: function (data) { @@ -1200,7 +1200,7 @@ echo '
    var config_type = $this.data("type"); $.ajax({ type: 'POST', - url: 'ajax_form.php', + url: '/ajax_form.php', data: {type: "update-config-item", action: 'update-textarea', config_type: config_type, config_id: config_id, config_value: config_value}, dataType: "json", success: function (data) { diff --git a/html/pages/syslog.inc.php b/html/pages/syslog.inc.php index bd708c175..0fa66c665 100644 --- a/html/pages/syslog.inc.php +++ b/html/pages/syslog.inc.php @@ -87,7 +87,7 @@ var grid = $("#syslog").bootgrid({ from: '', }; }, - url: "ajax_table.php" + url: "/ajax_table.php" }); $(function () { diff --git a/includes/common.php b/includes/common.php index 0749fe9bb..d5ba05fb0 100644 --- a/includes/common.php +++ b/includes/common.php @@ -76,7 +76,7 @@ function print_error($text) { print $console_color->convert("%r".$text."%n\n", false); } else { - echo('
    '.$text.'
    '); + echo('
    '.$text.'
    '); } } @@ -85,7 +85,7 @@ function print_message($text) { print Console_Color2::convert("%g".$text."%n\n", false); } else { - echo('
    '.$text.'
    '); + echo('
    '.$text.'
    '); } }