diff --git a/AUTHORS.md b/AUTHORS.md index 1fa25c6eb..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) @@ -35,7 +35,7 @@ Contributors to LibreNMS: - Christian Marg (einhirn) - Louis Rossouw (spinza) - Clint Armstrong (clinta) -- Tony Ditchfield (arnoldthebat) +- Tony Ditchfield (arnoldthebat) - Travis Hegner (travishegner) - Will Jones (willjones) - Job Snijders (job) @@ -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/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 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/css/styles.css b/html/css/styles.css index 8e5faa412..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; } @@ -1759,3 +1759,7 @@ tr.search:nth-child(odd) { #leaflet-map { height: 600px; } + +.edit-storage-input { + width: 100px; +} 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/storage-update.inc.php b/html/forms/storage-update.inc.php new file mode 100644 index 000000000..200a8f3d6 --- /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_id))) { + $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/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'; diff --git a/html/includes/api_functions.inc.php b/html/includes/api_functions.inc.php index 83f99e9b1..3c2c7fab1 100644 --- a/html/includes/api_functions.inc.php +++ b/html/includes/api_functions.inc.php @@ -878,33 +878,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 +905,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); } 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 d4d033812..0dabec69d 100644 --- a/html/includes/common/alerts.inc.php +++ b/html/includes/common/alerts.inc.php @@ -22,7 +22,7 @@ $common_output[] = ' 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.'
    '); } } 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; 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/discovery/mempools/zywall.inc.php b/includes/discovery/mempools/zywall.inc.php new file mode 100644 index 000000000..94a506fd8 --- /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, $oid, '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/discovery/temperatures/dsm.inc.php b/includes/discovery/temperatures/dsm.inc.php index 0c3e56262..8f1067620 100644 --- a/includes/discovery/temperatures/dsm.inc.php +++ b/includes/discovery/temperatures/dsm.inc.php @@ -12,7 +12,7 @@ if ($device['os'] == 'dsm') { // Get DiskStation temperature $diskstation_temperature = snmp_get($device, $diskstation_temperature_oid, '-Oqv'); // Save the DiskStation temperature - discover_sensor($valid['sensor'], 'temperature', $device, $diskstation_temperature_oid, '2', 'snmp', 'System Temperature', '1', '1', null, null, null, null, $diskstation_temperature); + discover_sensor($valid['sensor'], 'temperature', $device, $diskstation_temperature_oid, '99', 'snmp', 'System Temperature', '1', '1', null, null, null, null, $diskstation_temperature); // Get all disks in the device 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"))); 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 diff --git a/includes/polling/os/zywall.inc.php b/includes/polling/os/zywall.inc.php index 9b67f5f78..dbf822e6f 100644 --- a/includes/polling/os/zywall.inc.php +++ b/includes/polling/os/zywall.inc.php @@ -1,3 +1,6 @@ 0) { - $bill_data['bill_quota'] = $bill_data['bill_gb'] * $config['billing']['base'] * $config['billing']['base']; - dbUpdate(array('bill_quota' => $bill_data['bill_quota']), 'bills', '`bill_id` = ?', array($bill_data['bill_id'])); - echo("Quota -> ".$bill_data['bill_quota']); - } - - if($bill_data['bill_cdr'] > 0) { - $bill_data['bill_cdr'] = $bill_data['bill_cdr'] * 1000; - dbUpdate(array('bill_cdr' => $bill_data['bill_cdr']), 'bills', '`bill_id` = ?', array($bill_data['bill_id'])); - echo("CDR -> ".$bill_data['bill_cdr']); - } - echo("\n"); -} - -mysql_query("ALTER TABLE `bills` DROP `bill_gb`"); - -?> diff --git a/upgrade-scripts/fix-events.php b/upgrade-scripts/fix-events.php deleted file mode 100755 index 02d235b3e..000000000 --- a/upgrade-scripts/fix-events.php +++ /dev/null @@ -1,20 +0,0 @@ - 1) { - echo (round((($i / $count) * 100), 2)."% \r"); - } -} - - -function getDirectoryTree($outerDir, &$files=array()) -{ - $dirs = array_diff(scandir($outerDir), array( '.', '..' )); - foreach ($dirs as $d) { - if (is_dir($outerDir.'/'.$d)) { - getDirectoryTree($outerDir.'/'.$d, $files); - } - else { - if (preg_match('/^[\d]+.rrd$/', $d)) { - array_push($files, preg_replace('/\/+/', '/', $outerDir.'/'.$d)); - } - } - } - - return $files; - -}//end getDirectoryTree() - - -function fixRdd($file) -{ - global $config; - global $rrdcached; - $fileC = shell_exec("{$config['rrdtool']} dump $file $rrdcached"); - - // --------------------------------------------------------------------------------------------------------- - $first = << - INDISCARDS - DERIVE - 600 - 0.0000000000e+00 - 1.2500000000e+10 - - UNKN - 0.0000000000e+00 - 0 - - - OUTDISCARDS - DERIVE - 600 - 0.0000000000e+00 - 1.2500000000e+10 - - UNKN - 0.0000000000e+00 - 0 - - - INUNKNOWNPROTOS - DERIVE - 600 - 0.0000000000e+00 - 1.2500000000e+10 - - UNKN - 0.0000000000e+00 - 0 - - - INBROADCASTPKTS - DERIVE - 600 - 0.0000000000e+00 - 1.2500000000e+10 - - UNKN - 0.0000000000e+00 - 0 - - - OUTBROADCASTPKTS - DERIVE - 600 - 0.0000000000e+00 - 1.2500000000e+10 - - UNKN - 0.0000000000e+00 - 0 - - - INMULTICASTPKTS - DERIVE - 600 - 0.0000000000e+00 - 1.2500000000e+10 - - UNKN - 0.0000000000e+00 - 0 - - - OUTMULTICASTPKTS - DERIVE - 600 - 0.0000000000e+00 - 1.2500000000e+10 - - UNKN - 0.0000000000e+00 - 0 - - - -FIRST; - - $second = << - 0.0000000000e+00 - NaN - NaN - 0 - - - 0.0000000000e+00 - NaN - NaN - 0 - - - 0.0000000000e+00 - NaN - NaN - 0 - - - 0.0000000000e+00 - NaN - NaN - 0 - - - 0.0000000000e+00 - NaN - NaN - 0 - - - 0.0000000000e+00 - NaN - NaN - 0 - - - 0.0000000000e+00 - NaN - NaN - 0 - - -SECOND; - - $third = << NaN NaN NaN NaN NaN NaN NaN -THIRD; - - // --------------------------------------------------------------------------------------------------------- - if (!preg_match('/DISCARDS/', $fileC)) { - $fileC = str_replace('', $first, $fileC); - $fileC = str_replace('', $second, $fileC); - $fileC = str_replace('', $third, $fileC); - $tmpfname = tempnam('/tmp', 'OBS'); - file_put_contents($tmpfname, $fileC); - @unlink($file); - $newfile = preg_replace('/(\d+)\.rrd/', 'port-\\1.rrd', $file); - @unlink($newfile); - shell_exec($config['rrdtool']." restore $tmpfname $newfile"); - unlink($tmpfname); - } - -}//end fixRdd() - - -echo "\n"; diff --git a/upgrade-scripts/fix-sensor-rrd.php b/upgrade-scripts/fix-sensor-rrd.php deleted file mode 100755 index e508dbf2d..000000000 --- a/upgrade-scripts/fix-sensor-rrd.php +++ /dev/null @@ -1,81 +0,0 @@ - 1) { - echo (round((($i / $count) * 100), 2)."% \r"); - } -} - - -function sensor_getDirectoryTree($outerDir, &$files=array()) -{ - - $dirs = array_diff(scandir($outerDir), array( '.', '..' )); - foreach ($dirs as $d) { - if (is_dir($outerDir.'/'.$d)) { - sensor_getDirectoryTree($outerDir.'/'.$d, $files); - } - else { - if ((preg_match('/^fan-.*.rrd$/', $d)) - || (preg_match('/^current-.*.rrd$/', $d)) - || (preg_match('/^freq-.*.rrd$/', $d)) - || (preg_match('/^humidity-.*.rrd$/', $d)) - || (preg_match('/^volt-.*.rrd$/', $d)) - || (preg_match('/^temp-.*.rrd$/', $d)) - ) { - array_push($files, preg_replace('/\/+/', '/', $outerDir.'/'.$d)); - } - } - } - - return $files; - -} - - -function sensor_fixRdd($file) -{ - global $config; - global $rrdcached; - $fileC = shell_exec("{$config['rrdtool']} dump $file $rrdcached"); - if (preg_match('/ fan/', $fileC)) { - shell_exec("{$config['rrdtool']} tune $file $rrdcached -r fan:sensor"); - rename($file, str_replace('/fan-', '/fanspeed-', $file)); - } - else if (preg_match('/ volt/', $fileC)) { - shell_exec("{$config['rrdtool']} tune $file $rrdcached -r volt:sensor"); - rename($file, str_replace('/volt-', '/voltage-', $file)); - } - else if (preg_match('/ current/', $fileC)) { - shell_exec("{$config['rrdtool']} tune $file $rrdcached -r current:sensor"); - } - else if (preg_match('/ freq/', $fileC)) { - shell_exec("{$config['rrdtool']} tune $file $rrdcached -r freq:sensor"); - rename($file, str_replace('/freq-', '/frequency-', $file)); - } - else if (preg_match('/ humidity/', $fileC)) { - shell_exec("{$config['rrdtool']} tune $file $rrdcached -r humidity:sensor"); - } - else if (preg_match('/ temp/', $fileC)) { - shell_exec("{$config['rrdtool']} tune $file $rrdcached -r temp:sensor"); - rename($file, str_replace('/temp-', '/temperature-', $file)); - } - -} - - -echo "\n";