Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Michael Newton
2015-08-11 14:38:39 -07:00
80 changed files with 829 additions and 606 deletions
+2 -4
View File
@@ -23,7 +23,7 @@ Contributors to LibreNMS:
- Stuart Henderson <stu@spacehopper.org> (sthen)
- Filippo Giunchedi <filippo@esaurito.net> (filippog)
- Lasse Leegaard <lasse@brandbil.dk> (lasseleegaard)
- Mickael Marchand <mmarchand@corp.free.fr> (mmarchand)
- Mickael Marchand <mmarchand@corp.free.fr> (mmarchand)
- Mohammad Al-Shami <mohammad@al-shami.net> (mohshami)
- Rudy Hardeman <zarya@gigafreak.net> (zarya)
- Arjit Chaudhary (arjit.c@gmail.com) (arjitc)
@@ -35,7 +35,7 @@ Contributors to LibreNMS:
- Christian Marg <marg@rz.tu-clausthal.de> (einhirn)
- Louis Rossouw <lrossouw@gmail.com> (spinza)
- Clint Armstrong <clint@clintarmstrong.net> (clinta)
- Tony Ditchfield <tony.ditchfield@gmail.com> (arnoldthebat)
- Tony Ditchfield <tony.ditchfield@gmail.com> (arnoldthebat)
- Travis Hegner <travis.hegner@gmail.com> (travishegner)
- Will Jones <email@willjones.eu> (willjones)
- Job Snijders <job@instituut.net> (job)
@@ -45,8 +45,6 @@ Contributors to LibreNMS:
- Aaron Daniels <aaron@daniels.id.au> (adaniels21487)
- David M. Syzdek <david@syzdek.net> (syzdek)
- Gerben Meijer <gerben@daybyday.nl> (infernix)
- Michael Newton <mnewton@pofp.com> (miken32)
[1]: http://observium.org/ "Observium web site"
+33 -3
View File
@@ -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.
# <a name="rules">Rules</a>
@@ -125,34 +127,41 @@ Alert sent to: {foreach %contacts}%value <%key> {/foreach}
# <a name="transports">Transports</a>
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
```
~~
## <a name="transports-email">E-Mail</a>
> 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`:
~
```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" <projectid@`hostname`>
@@ -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
```
~~
## <a name="transports-api">API</a>
> 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";
```
~~
## <a name="transports-nagios">Nagios Compatible</a>
@@ -193,9 +205,11 @@ $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'
```
~~
## <a name="transports-irc">IRC</a>
@@ -203,9 +217,11 @@ $config['alert']['transports']['nagios'] = "/path/to/my.fifo"; //Flapjack expect
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).
~~
```php
$config['alert']['transports']['irc'] = true;
```
~~
## <a name="transports-slack">Slack</a>
@@ -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:');
```
~~
## <a name="transports-hipchat">HipChat</a>
@@ -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',
);
```
~~
## <a name="transports-boxcar">Boxcar</a>
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',
);
```
~~
# <a name="entities">Entities
+5
View File
@@ -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.
+5 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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: <i>$name: $rule</i>";
if (is_array($_POST['maps'])) {
foreach ($_POST['maps'] as $target) {
+46
View File
@@ -0,0 +1,46 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2015 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
*
* 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);
+1 -1
View File
@@ -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';
+13 -14
View File
@@ -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);
}
+1 -1
View File
@@ -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;
}
+6 -6
View File
@@ -22,7 +22,7 @@ $common_output[] = '
</table>
</div>
<script>
var grid = $("#alerts").bootgrid({
var alerts_grid = $("#alerts").bootgrid({
ajax: true,
post: function ()
{
@@ -31,7 +31,7 @@ var grid = $("#alerts").bootgrid({
device_id: \'' . $device['device_id'] .'\'
};
},
url: "ajax_table.php",
url: "/ajax_table.php",
formatters: {
"status": function(column,row) {
return "<h4><span class=\'label label-"+row.extra+" threeqtr-width\'>" + row.msg + "</span></h4>";
@@ -43,14 +43,14 @@ var grid = $("#alerts").bootgrid({
templates: {
}
}).on("loaded.rs.jquery.bootgrid", function() {
grid.find(".incident-toggle").each( function() {
alerts_grid.find(".incident-toggle").each( function() {
$(this).parent().addClass(\'incident-toggle-td\');
}).on("click", function(e) {
var target = $(this).data("target");
$(target).collapse(\'toggle\');
$(this).toggleClass(\'glyphicon-plus glyphicon-minus\');
});
grid.find(".incident").each( function() {
alerts_grid.find(".incident").each( function() {
$(this).parent().addClass(\'col-lg-4 col-md-4 col-sm-4 col-xs-4\');
$(this).parent().parent().on("mouseenter", function() {
$(this).find(".incident-toggle").fadeIn(200);
@@ -64,13 +64,13 @@ var grid = $("#alerts").bootgrid({
}
});
});
grid.find(".command-ack-alert").on("click", function(e) {
alerts_grid.find(".command-ack-alert").on("click", function(e) {
e.preventDefault();
var alert_id = $(this).data("alert_id");
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(\'<div class="alert alert-info">\'+msg+\'</div>\');
+2 -2
View File
@@ -14,7 +14,7 @@ $common_output[] = '
<script>
var grid = $("#eventlog").bootgrid({
var eventlog_grid = $("#eventlog").bootgrid({
ajax: true,
post: function ()
{
@@ -24,7 +24,7 @@ var grid = $("#eventlog").bootgrid({
type: "' .mres($vars['type']) .'",
};
},
url: "ajax_table.php"
url: "/ajax_table.php"
});
</script>
+2 -2
View File
@@ -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){
+2 -2
View File
@@ -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){
@@ -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) {
+1 -1
View File
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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) {
+2 -2
View File
@@ -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('<div class="alert alert-info">'+msg+'</div>');
+2 -2
View File
@@ -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) {
+2 -2
View File
@@ -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) {
+3 -3
View File
@@ -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('<div class="alert alert-info">'+msg+'</div>');
@@ -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){
@@ -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){
+2 -2
View File
@@ -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('<div class="alert alert-info">'+msg+'</div>');
@@ -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) {
+1 -1
View File
@@ -30,7 +30,7 @@ else {
}
if (dbFetchCell('SELECT COUNT(*) FROM `mac_accounting` WHERE `port_id` = ?', array($port['port_id']))) {
$mac = "<a href='".generate_port_url($port, array('view' => 'macaccounting'))."'><img src='images/16/chart_curve.png' align='absmiddle'></a>";
$mac = "<a href='".generate_port_url($port, array('view' => 'macaccounting'))."'><img src='/images/16/chart_curve.png' align='absmiddle'></a>";
}
else {
$mac = '';
+3 -3
View File
@@ -489,12 +489,12 @@ if ($_SESSION['userlevel'] >= '10') {
<li class="dropdown-submenu">
<a href="#"><i class="fa fa-clock-o fa-fw fa-lg"></i> Pollers</a>
<ul class="dropdown-menu scrollable-menu">
<li><a href="poll-log/"><i class="fa fa-exclamation fa-fw fa-lg"></i> Poll-log</a></li>');
<li><a href="/poll-log/"><i class="fa fa-exclamation fa-fw fa-lg"></i> Poll-log</a></li>');
if($config['distributed_poller'] === TRUE) {
echo ('
<li><a href="pollers/tab=pollers/"><i class="fa fa-clock-o fa-fw fa-lg"></i> Pollers</a></li>
<li><a href="pollers/tab=groups/"><i class="fa fa-gears fa-fw fa-lg"></i> Groups</a></li>');
<li><a href="/pollers/tab=pollers/"><i class="fa fa-clock-o fa-fw fa-lg"></i> Pollers</a></li>
<li><a href="/pollers/tab=groups/"><i class="fa fa-gears fa-fw fa-lg"></i> Groups</a></li>');
}
echo ('
</ul>
+105
View File
@@ -0,0 +1,105 @@
<?php
if (!is_array($config['customers_descr'])) {
$config['customers_descr'] = array($config['customers_descr']);
}
$descr_type = "'".implode("', '", $config['customers_descr'])."'";
$i = 0;
$sql = ' FROM `ports` LEFT JOIN `devices` AS `D` ON `ports`.`device_id` = `D`.`device_id` WHERE `port_descr_type` IN (?)';
$param[] = array($descr_type);
if (isset($searchPhrase) && !empty($searchPhrase)) {
$sql .= " AND (`port_descr_descr` LIKE '%$searchPhrase%' OR `ifName` LIKE '%$searchPhrase%' OR `ifDescr` LIKE '%$searchPhrase%' OR `ifAlias` LIKE '%$searchPhrase%' OR `D`.`hostname` LIKE '%$searchPhrase%' OR `port_descr_speed` LIKE '%$searchPhrase%' OR `port_descr_notes` LIKE '%$searchPhrase%')";
}
$count_sql = "SELECT COUNT(DISTINCT(`port_descr_descr`)) $sql";
$sql .= ' GROUP BY `port_descr_descr`';
$total = dbFetchCell($count_sql,$param);
if (empty($total)) {
$total = 0;
}
if (!isset($sort) || empty($sort)) {
$sort = '`port_descr_descr`';
}
$sql .= " ORDER BY $sort";
if (isset($current)) {
$limit_low = ($current * $rowCount) - ($rowCount);
$limit_high = $rowCount;
}
if ($rowCount != -1) {
$sql .= " LIMIT $limit_low,$limit_high";
}
$sql = "SELECT * $sql";
foreach (dbFetchRows($sql, $param) as $customer) {
$i++;
$customer_name = $customer['port_descr_descr'];
foreach (dbFetchRows('SELECT * FROM `ports` WHERE `port_descr_type` IN (?) AND `port_descr_descr` = ?', array(array($descr_type), $customer['port_descr_descr'])) as $port) {
$device = device_by_id_cache($port['device_id']);
$ifname = fixifname($device['ifDescr']);
$ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
if ($device['os'] == 'ios') {
if ($port['ifTrunk']) {
$vlan = '<span class=box-desc><span class=red>'.$port['ifTrunk'].'</span></span>';
}
else if ($port['ifVlan']) {
$vlan = '<span class=box-desc><span class=blue>VLAN '.$port['ifVlan'].'</span></span>';
}
else {
$vlan = '';
}
}
$response[] = array(
'port_descr_descr' => $customer_name,
'device_id' => generate_device_link($device),
'ifDescr' => generate_port_link($port, makeshortif($port['ifDescr'])),
'port_descr_speed' => $port['port_descr_speed'],
'port_descr_circuit' => $port['port_descr_circuit'],
'port_descr_notes' => $port['port_descr_notes'],
);
unset($customer_name);
}
$graph_array['type'] = 'customer_bits';
$graph_array['height'] = '100';
$graph_array['width'] = '220';
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $customer['port_descr_descr'];
$return_data = true;
include 'includes/print-graphrow.inc.php';
$response[] = array(
'port_descr_descr' => $graph_data[0],
'device_id' => $graph_data[1],
'ifDescr' => '',
'port_descr_speed' => '',
'port_descr_circuit' => $graph_data[2],
'port_descr_notes' => $graph_data[3],
);
}
$output = array(
'current' => $current,
'rowCount' => $rowCount,
'rows' => $response,
'total' => $total,
);
echo _json_encode($output);
+1 -2
View File
@@ -79,8 +79,7 @@ if (!empty($_POST['location']) && $_POST['location'] == 'Unset') {
if (!empty($_POST['location'])) {
$sql .= " AND `location` = ?";
$param[] = mres($_POST['location']);
$param[] = mres($_POST['location']);
$param[] = $_POST['location'];
}
if (!empty($_POST['group'])) {
+51
View File
@@ -0,0 +1,51 @@
<?php
$device_id = mres($_POST['device_id']);
$sql = " FROM `storage` AS `S` LEFT JOIN `devices` AS `D` ON `S`.`device_id` = `D`.`device_id` WHERE `D`.`device_id`=? AND `S`.`storage_deleted`=0";
$param[] = $device_id;
if (isset($searchPhrase) && !empty($searchPhrase)) {
$sql .= " AND (`D`.`hostname` LIKE '%$searchPhrase%' OR `S`.`storage_descr` LIKE '%$searchPhrase%' OR `S.`storage_perc` LIKE '%$searchPhrase%' OR `S`.`storage_perc_warn` LIKE '%$searchPhrase%')";
}
$count_sql = "SELECT COUNT(`storage_id`) $sql";
$total = dbFetchCell($count_sql,$param);
if (empty($total)) {
$total = 0;
}
if (!isset($sort) || empty($sort)) {
$sort = '`D`.`hostname`, `S`.`storage_descr`';
}
$sql .= " ORDER BY $sort";
if (isset($current)) {
$limit_low = ($current * $rowCount) - ($rowCount);
$limit_high = $rowCount;
}
if ($rowCount != -1) {
$sql .= " LIMIT $limit_low,$limit_high";
}
$sql = "SELECT * $sql";
//$response[] = array('storage_descr' => $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);
+1 -1
View File
@@ -54,7 +54,7 @@ $msg_box = array();
// Check for install.inc.php
if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') {
// no config.php does so let's redirect to the install
header('Location: install.php');
header('Location: /install.php');
exit;
}
+3 -2
View File
@@ -29,7 +29,7 @@ if($stage == "4" || $stage == "3") {
require '../includes/defaults.inc.php';
// Work out the install directory
$cur_dir = explode('/',__DIR__);
$cur_dir = explode('/',$_SERVER['DOCUMENT_ROOT']);
$check = end($cur_dir);
if( empty($check) ) {
$install_dir = array_pop($cur_dir);
@@ -90,6 +90,7 @@ $complete = 1;
<html>
<head>
<title><?php echo($config['page_title_prefix']); ?></title>
<base href="<?php echo($config['base_url']); ?>" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="content-language" content="en-us" />
@@ -300,7 +301,7 @@ elseif($stage == "2") {
<div class="col-md-3">
</div>
<div class="col-md-6">
<h5 class="text-center">Importing MySQL DB - Do not close this page or interupt the import</h5>
<h5 class="text-center">Importing MySQL DB - Do not close this page or interrupt the import</h5>
<?php
// Ok now let's set the db connection up
$config['db_host']=$dbhost;
+254
View File
@@ -0,0 +1,254 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage map
* @author Adam Armstrong <adama@memetic.org>
* @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 '<pre>$map</pre>';
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("<a ", '<a target="_parent" ', $img);
}
echo $img;
}
else {
if ($_SESSION['authenticated']) {
// FIXME level 10 only?
echo '<center>
<object width=1200 height=1000 data="'. $config['base_url'] . '/map.php?format=svg" type="image/svg+xml"></object>
</center>
';
}
}
+2 -2
View File
@@ -208,7 +208,7 @@ echo "
event.preventDefault();
$.ajax({
type: 'POST',
url: 'ajax_form.php',
url: '/ajax_form.php',
data: { type: "callback-statistics", state: state},
dataType: "html",
success: function(data){
@@ -222,7 +222,7 @@ echo "
event.preventDefault();
$.ajax({
type: 'POST',
url: 'ajax_form.php',
url: '/ajax_form.php',
data: { type: "callback-clear"},
dataType: "html",
success: function(data){
+1 -1
View File
@@ -72,7 +72,7 @@ foreach (get_all_devices() as $hostname) {
device_id: '<?php echo htmlspecialchars($_POST['device_id']); ?>'
};
},
url: "ajax_table.php"
url: "/ajax_table.php"
}).on("loaded.rs.jquery.bootgrid", function() {
var results = $("div.infos").text().split(" ");
+1 -1
View File
@@ -73,7 +73,7 @@ var grid = $("#alert-schedule").bootgrid({
id: "alert-schedule",
};
},
url: "ajax_table.php"
url: "/ajax_table.php"
}).on("loaded.rs.jquery.bootgrid", function()
{
/* Executes after data is loaded and rendered */
+3 -3
View File
@@ -160,7 +160,7 @@ foreach (dbFetchRows('SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN
var token_id = $(this).data("token_id");
$.ajax({
type: 'POST',
url: 'ajax_form.php',
url: '/ajax_form.php',
data: { type: "token-item-disable", token_id: token_id, state: state},
dataType: "html",
success: function(data){
@@ -180,7 +180,7 @@ foreach (dbFetchRows('SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN
token_id = $("#token_id").val();
$.ajax({
type: "POST",
url: "ajax_form.php",
url: "/ajax_form.php",
data: $('form.remove_token_form').serialize() ,
success: function(msg){
$("#thanks").html('<div class="alert alert-info">'+msg+'</div>');
@@ -197,7 +197,7 @@ foreach (dbFetchRows('SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN
event.preventDefault();
$.ajax({
type: "POST",
url: "ajax_form.php",
url: "/ajax_form.php",
data: $('form.create_token_form').serialize(),
success: function(msg){
$("#thanks").html('<div class="alert alert-info">'+msg+'</div>');
+1 -1
View File
@@ -146,7 +146,7 @@ if (bill_permitted($bill_id)) {
}
}//end if
echo '<div style="font-weight: bold; float: right;"><a href="'.generate_url(array('page' => 'bills')).'/"><img align=absmiddle src="images/16/arrow_left.png"> Back to Bills</a></div>';
echo '<div style="font-weight: bold; float: right;"><a href="'.generate_url(array('page' => 'bills')).'/"><img align=absmiddle src="/images/16/arrow_left.png"> Back to Bills</a></div>';
print_optionbar_end();
+1 -1
View File
@@ -99,7 +99,7 @@ else if ($vars['view'] == 'add') {
}
}
echo '<div style="font-weight: bold; float: right;"><a href="'.generate_url(array('page' => 'bills')).'/"><img align=absmiddle src="images/16/arrow_left.png"> Back to Bills</a></div>';
echo '<div style="font-weight: bold; float: right;"><a href="'.generate_url(array('page' => 'bills')).'/"><img align=absmiddle src="/images/16/arrow_left.png"> Back to Bills</a></div>';
print_optionbar_end();
?>
+27 -80
View File
@@ -1,87 +1,34 @@
<?php
echo '<table border=0 cellspacing=0 cellpadding=2 class=devicetable width=100%>';
echo "
<tr bgcolor='$list_colour_a'>
<th width='7'></th>
<th width='250'><span style='font-weight: bold;' class=interface>Customer</span></th>
<th width='150'>Device</th>
<th width='100'>Interface</th>
<th width='100'>Speed</th>
<th width='100'>Circuit</th>
<th>Notes</th>
</tr>
";
$i = 1;
$pagetitle[] = 'Customers';
if (!is_array($config['customers_descr'])) {
$config['customers_descr'] = array($config['customers_descr']);
}
?>
$descr_type = "'".implode("', '", $config['customers_descr'])."'";
<div class="table-responsive">
<table id="customers" class="table table-hover table-condensed table-striped">
<thead>
<tr>
<th data-column-id="port_descr_descr" data-order="asc">Customer</th>
<th data-column-id="device_id">Device</th>
<th data-column-id="ifDescr">Interface</th>
<th data-column-id="port_descr_speed">Speed</th>
<th data-column-id="port_descr_circuit">Circuit</th>
<th data-column-id="port_descr_notes">Notes</th>
</tr>
</thead>
</table>
</div>
foreach (dbFetchRows('SELECT * FROM `ports` WHERE `port_descr_type` IN (?) GROUP BY `port_descr_descr` ORDER BY `port_descr_descr`', array(array($descr_type))) as $customer) {
$i++;
<script>
$customer_name = $customer['port_descr_descr'];
if (!is_integer($i / 2)) {
$bg_colour = $list_colour_a;
}
else {
$bg_colour = $list_colour_b;
}
foreach (dbFetchRows('SELECT * FROM `ports` WHERE `port_descr_type` IN (?) AND `port_descr_descr` = ?', array(array($descr_type), $customer['port_descr_descr'])) as $port) {
$device = device_by_id_cache($port['device_id']);
unset($class);
$ifname = fixifname($device['ifDescr']);
$ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
if ($device['os'] == 'ios') {
if ($port['ifTrunk']) {
$vlan = '<span class=box-desc><span class=red>'.$port['ifTrunk'].'</span></span>';
}
else if ($port['ifVlan']) {
$vlan = '<span class=box-desc><span class=blue>VLAN '.$port['ifVlan'].'</span></span>';
}
else {
$vlan = '';
}
}
echo "
<tr bgcolor='$bg_colour'>
<td width='7'></td>
<td width='250'><span style='font-weight: bold;' class=interface>".$customer_name."</span></td>
<td width='150'>".generate_device_link($device)."</td>
<td width='100'>".generate_port_link($port, makeshortif($port['ifDescr']))."</td>
<td width='100'>".$port['port_descr_speed']."</td>
<td width='100'>".$port['port_descr_circuit'].'</td>
<td>'.$port['port_descr_notes'].'</td>
</tr>
';
unset($customer_name);
}
echo "<tr bgcolor='$bg_colour'><td></td><td colspan=6>";
$graph_array['type'] = 'customer_bits';
$graph_array['height'] = '100';
$graph_array['width'] = '220';
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $customer['port_descr_descr'];
include 'includes/print-graphrow.inc.php';
echo '</tr>';
}
echo '</table>';
var grid = $("#customers").bootgrid({
ajax: true,
post: function ()
{
return {
id: "customers",
};
},
url: "/ajax_table.php"
});
</script>
+2
View File
@@ -34,6 +34,8 @@ else {
$panes['health'] = 'Health';
}
$panes['storage'] = 'Storage';
print_optionbar_start();
unset($sep);
+1 -1
View File
@@ -149,7 +149,7 @@ if ($unknown) {
var device_id = $(this).data("device_id");
$.ajax({
type: 'POST',
url: 'ajax_form.php',
url: '/ajax_form.php',
data: { type: "rediscover-device", device_id: device_id },
dataType: "json",
success: function(data){
+4 -4
View File
@@ -101,7 +101,7 @@ $('#newThread').on('click', function(e){
var form = $('#alert-reset');
$.ajax({
type: 'POST',
url: 'ajax_form.php',
url: '/ajax_form.php',
data: form.serialize(),
dataType: "html",
success: function(data){
@@ -125,7 +125,7 @@ $( ".sensor" ).blur(function() {
var $this = $(this);
$.ajax({
type: 'POST',
url: 'ajax_form.php',
url: '/ajax_form.php',
data: { type: "health-update", device_id: device_id, data: data, sensor_id: sensor_id , value_type: value_type},
dataType: "html",
success: function(data){
@@ -155,7 +155,7 @@ $('input[name="alert-status"]').on('switchChange.bootstrapSwitch', function(eve
var sensor_id = $(this).data("sensor_id");
$.ajax({
type: 'POST',
url: 'ajax_form.php',
url: '/ajax_form.php',
data: { type: "sensor-alert-update", device_id: device_id, sensor_id: sensor_id, state: state},
dataType: "html",
success: function(data){
@@ -172,7 +172,7 @@ $("[name='remove-custom']").on('click', function(event) {
var sensor_id = $(this).data("sensor_id");
$.ajax({
type: 'POST',
url: 'ajax_form.php',
url: '/ajax_form.php',
data: { type: "sensor-alert-update", sensor_id: sensor_id, sub_type: "remove-custom" },
dataType: "html",
success: function(data){
+2 -2
View File
@@ -153,7 +153,7 @@ echo('
var device_id = $(this).data("device_id");
$.ajax({
type: 'POST',
url: 'ajax_form.php',
url: '/ajax_form.php',
data: { type: "poller-module-update", poller_module: poller_module, device_id: device_id, state: state},
dataType: "html",
success: function(data){
@@ -184,7 +184,7 @@ echo('
var device_id = $(this).data("device_id");
$.ajax({
type: 'POST',
url: 'ajax_form.php',
url: '/ajax_form.php',
data: { type: "discovery-module-update", discovery_module: discovery_module, device_id: device_id, state: state},
dataType: "html",
success: function(data){
+2 -2
View File
@@ -79,7 +79,7 @@
event.preventDefault();
$.ajax({
type: "POST",
url: "ajax_form.php",
url: "/ajax_form.php",
data: $('form#ignoreport').serialize(),
dataType: "json",
success: function(data){
@@ -108,6 +108,6 @@
device_id: "<?php echo $device['device_id']; ?>"
};
},
url: "ajax_table.php"
url: "/ajax_table.php"
});
</script>
+86
View File
@@ -0,0 +1,86 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2015 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
*
* 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.
*/
?>
<h3>Storage settings</h3>
<div class="table-responsive">
<table id="storage" class="table table-hover table-condensed storage">
<thead>
<tr>
<th data-column-id="hostname">Device</th>
<th data-column-id="storage_descr">Storage</th>
<th data-column-id="storage_perc">%</th>
<th data-column-id="storage_perc_warn" data-formatter="perc_update" data-header-css-class="edit-storage-input">% Warn</th>
</tr>
</thead>
</table>
</div>
<script>
var grid = $("#storage").bootgrid({
ajax: true,
rowCount: [25,50,100,250,-1],
post: function ()
{
return {
id: "storage-edit",
device_id: <?php echo $device['device_id']; ?>,
};
},
url: "/ajax_table.php",
formatters: {
"perc_update": function(column,row) {
return "<div class='form-group'><input type='text' class='form-control input-sm storage' data-device_id='<?php echo $device['device_id']; ?>' data-storage_id='"+row.storage_id+"' value='"+row.storage_perc_warn+"'></div>";
}
},
templates: {
}
}).on("loaded.rs.jquery.bootgrid", function() {
grid.find(".storage").blur(function(event) {
event.preventDefault();
var device_id = $(this).data("device_id");
var storage_id = $(this).data("storage_id");
var data = $(this).val();
var $this = $(this);
$.ajax({
type: 'POST',
url: '/ajax_form.php',
data: {type: "storage-update", device_id: device_id, data: data, storage_id: storage_id},
dataType: "json",
success: function (data) {
if (data.status == 'ok') {
$this.closest('.form-group').addClass('has-success');
setTimeout(function () {
$this.closest('.form-group').removeClass('has-success');
}, 2000);
} else {
$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');
setTimeout(function () {
$this.closest('.form-group').removeClass('has-error');
}, 2000);
}
});
});
});
</script>
+10 -1
View File
@@ -14,4 +14,13 @@
$pagetitle[] = 'Map';
require_once 'includes/print-map.inc.php';
if ($config['gui']['network-map']['style'] == 'old') {
echo '
<center style="height:100%">
<object data="network-map.php?device='.$device['device_id'].'&format=svg" type="image/svg+xml" style="width: 100%; height:100%"></object>
</center>
';
}
else {
require_once 'includes/print-map.inc.php';
}
+5 -5
View File
@@ -192,7 +192,7 @@ if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_i
echo "<span class='pagemenu-selected'>";
}
echo "<a href='" . generate_url(array('page'=>'device','device'=>$device['device_id'], 'tab'=>'port', 'port'=>$port['port_id'])) . "/junose-atm-vp/bits/'>Bits</a>";
echo "<a href='/device/device=".$device['device_id'].'/tab=port/port='.$port['port_id']."/junose-atm-vp/bits/'>Bits</a>";
if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') {
echo '</span>';
}
@@ -202,7 +202,7 @@ if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_i
echo "<span class='pagemenu-selected'>";
}
echo "<a href='" . generate_url(array('page'=>'device','device'=>$device['device_id'], 'tab'=>'port', 'port'=>$port['port_id'])) . "/junose-atm-vp/packets/'>Packets</a>";
echo "<a href='device/device=".$device['device_id'].'/tab=port/port='.$port['port_id']."/junose-atm-vp/packets/'>Packets</a>";
if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') {
echo '</span>';
}
@@ -212,7 +212,7 @@ if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_i
echo "<span class='pagemenu-selected'>";
}
echo "<a href='" . generate_url(array('page'=>'device','device'=>$device['device_id'], 'tab'=>'port', 'port'=>$port['port_id'])) . "/junose-atm-vp/cells/'>Cells</a>";
echo "<a href='device/device=".$device['device_id'].'/tab=port/port='.$port['port_id']."/junose-atm-vp/cells/'>Cells</a>";
if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') {
echo '</span>';
}
@@ -222,14 +222,14 @@ if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_i
echo "<span class='pagemenu-selected'>";
}
echo "<a href='" . generate_url(array('page'=>'device','device'=>$device['device_id'], 'tab'=>'port', 'port'=>$port['port_id'])) . "/junose-atm-vp/errors/'>Errors</a>";
echo "<a href='device/device=".$device['device_id'].'/tab=port/port='.$port['port_id']."/junose-atm-vp/errors/'>Errors</a>";
if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') {
echo '</span>';
}
}//end if
if ($_SESSION['userlevel'] >= '10') {
echo "<span style='float: right;'><a href='" . generate_url(array('page'=>'bills', 'view'=>'add', 'port'=>$port['port_id'])) . "'><img src='images/16/money.png' border='0' align='absmiddle'> Create Bill</a></span>";
echo "<span style='float: right;'><a href='bills/view=add/port=".$port['port_id']."/'><img src='images/16/money.png' border='0' align='absmiddle'> Create Bill</a></span>";
}
print_optionbar_end();
+1 -1
View File
@@ -85,7 +85,7 @@ foreach ($heads as $head => $extra) {
$icon .= "'";
}
echo '<th><a href="' . generate_url(array('page'=>'device','device'=>$device['device_id'], 'tab'=>'processes', 'order'=>$lhead, 'by'=>$bhead)) . '"><span'.$icon.'>&nbsp;';
echo '<th><a href="/device/device='.$device['device_id'].'/tab=processes/order='.$lhead.'/by='.$bhead.'"><span'.$icon.'>&nbsp;';
if (!empty($extra)) {
echo "<abbr title='$extra'>$head</abbr>";
}
+1 -1
View File
@@ -435,7 +435,7 @@ var grid = $("#devices").bootgrid({
group: '<?php echo mres($vars['group']); ?>',
};
},
url: "ajax_table.php"
url: "/ajax_table.php"
});
</script>
+5 -5
View File
@@ -74,7 +74,7 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
var s = JSON.stringify(gridster.serialize());
$.ajax({
type: 'POST',
url: 'ajax_form.php',
url: '/ajax_form.php',
data: {type: "update-dashboard-config", data: s},
dataType: "json",
success: function (data) {
@@ -134,7 +134,7 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
var widget_id = $(this).data('widget-id');
$.ajax({
type: 'POST',
url: 'ajax_form.php',
url: '/ajax_form.php',
data: {type: "update-dashboard-config", sub_type: 'remove-all'},
dataType: "json",
success: function (data) {
@@ -155,7 +155,7 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
var widget_id = $(this).data('widget_id');
$.ajax({
type: 'POST',
url: 'ajax_form.php',
url: '/ajax_form.php',
data: {type: "update-dashboard-config", sub_type: 'add', widget_id: widget_id},
dataType: "json",
success: function (data) {
@@ -189,7 +189,7 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
var widget_id = $(this).data('widget-id');
$.ajax({
type: 'POST',
url: 'ajax_form.php',
url: '/ajax_form.php',
data: {type: "update-dashboard-config", sub_type: 'remove', widget_id: widget_id},
dataType: "json",
success: function (data) {
@@ -213,7 +213,7 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
new_refresh = refresh * 1000;
$.ajax({
type: 'POST',
url: 'ajax_dash.php',
url: '/ajax_dash.php',
data: {type: data_type},
dataType: "json",
success: function (data) {
+1 -1
View File
@@ -23,7 +23,7 @@
view: '<?php echo $vars['view']; ?>'
};
},
url: "ajax_table.php",
url: "/ajax_table.php",
formatters: {
"status": function(column,row) {
return "<h4><span class='label label-"+row.extra+" threeqtr-width'>" + row.msg + "</span></h4>";
+1 -1
View File
@@ -22,7 +22,7 @@
view: '<?php echo $vars['view']; ?>'
};
},
url: "ajax_table.php",
url: "/ajax_table.php",
formatters: {
"status": function(column,row) {
return "<h4><span class='label label-"+row.extra+" threeqtr-width'>" + row.msg + "</span></h4>";
+1 -1
View File
@@ -23,7 +23,7 @@
view: '<?php echo $vars['view']; ?>'
};
},
url: "ajax_table.php",
url: "/ajax_table.php",
formatters: {
"status": function(column,row) {
return "<h4><span class='label label-"+row.extra+" threeqtr-width'>" + row.msg + "</span></h4>";
+1 -1
View File
@@ -89,7 +89,7 @@ if ($if_list) {
<td colspan='5'";
if (dbFetchCell('SELECT count(*) FROM mac_accounting WHERE port_id = ?', array($port['port_id']))) {
echo "<span style='float: right;'><a href='" . generate_url(array('page'=>'device', 'device'=>$port['device_id'], 'tab'=>'port', 'port'=>$port['port_id'], 'view'=>'macaccounting')) . "'><img src='images/16/chart_curve.png' align='absmiddle'> MAC Accounting</a></span>";
echo "<span style='float: right;'><a href='device/device=".$port['device_id'].'/tab=port/port='.$port['port_id']."/view=macaccounting/'><img src='/images/16/chart_curve.png' align='absmiddle'> MAC Accounting</a></span>";
}
echo '<br />';
+1 -1
View File
@@ -92,7 +92,7 @@ foreach (dbFetchRows('SELECT * FROM `devices` ORDER BY `hostname`') as $data) {
serial: '<?php echo mres($_POST['serial']); ?>'
};
},
url: "ajax_table.php"
url: "/ajax_table.php"
});
</script>
+7 -1
View File
@@ -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';
}
+1 -1
View File
@@ -22,7 +22,7 @@ var grid = $("#poll-log").bootgrid({
id: "poll-log"
};
},
url: "ajax_table.php"
url: "/ajax_table.php"
});
</script>
+1 -1
View File
@@ -30,7 +30,7 @@ $poll_tabs = array(
foreach ($poll_tabs as $tab) {
echo '
<li>
<a href="' . generate_url(array('page'=>'pollers','tab'=>lcfirst($tab['name']))) . '">
<a href="/pollers/tab='.lcfirst($tab['name']).'">
<img src="images/16/'.$tab['icon'].'.png" align="absmiddle" border="0"> '.$tab['name'].'
</a>
</li>';
+1 -1
View File
@@ -55,7 +55,7 @@ foreach ($menu_options as $option => $text) {
echo('<div style="float: right;">');
?>
<a href="csv.php/report=<?php echo generate_url($vars,array('format'=>'')); ?>" title="Export as CSV" target="_blank">Export CSV</a> |
<a href="/csv.php/report=<?php echo generate_url($vars,array('format'=>'')); ?>" title="Export as CSV" target="_blank">Export CSV</a> |
<a href="<?php echo(generate_url($vars)); ?>" title="Update the browser URL to reflect the search criteria." >Update URL</a> |
<?php
+4 -4
View File
@@ -78,7 +78,7 @@ else {
else {
$twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username']));
if (empty($twofactor['twofactor'])) {
echo '<div class="alert alert-danger">Error: How did you even get here?!</div><script>window.location = "preferences/";</script>';
echo '<div class="alert alert-danger">Error: How did you even get here?!</div><script>window.location = "/preferences/";</script>';
}
else {
$twofactor = json_decode($twofactor['twofactor'], true);
@@ -94,13 +94,13 @@ else {
}
else {
session_destroy();
echo '<div class="alert alert-danger">Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.</div><script>window.location = "' . $config['base_url'] . '";</script>';
echo '<div class="alert alert-danger">Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.</div><script>window.location = "/";</script>';
}
}//end if
}
else {
$twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username']));
echo '<script src="js/jquery.qrcode.min.js"></script>';
echo '<script src="/js/jquery.qrcode.min.js"></script>';
echo '<div class="well"><h3>Two-Factor Authentication</h3>';
if (!empty($twofactor['twofactor'])) {
$twofactor = json_decode($twofactor['twofactor'], true);
@@ -154,7 +154,7 @@ else {
echo '<div class="alert alert-danger">Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.</div>';
}
else {
echo '<div class="alert alert-success">Added TwoFactor credentials. Please reload page.</div><script>window.location = "preferences/";</script>';
echo '<div class="alert alert-success">Added TwoFactor credentials. Please reload page.</div><script>window.location = "/preferences/";</script>';
}
}
else {
+1 -1
View File
@@ -91,7 +91,7 @@ echo '"'.$_POST['address'].'"+';
address: '<?php echo mres($_POST['address']); ?>'
};
},
url: "ajax_table.php"
url: "/ajax_table.php"
});
</script>
+1 -1
View File
@@ -86,7 +86,7 @@ if ($_POST['interface'] == 'Vlan%') {
address: '<?php echo mres($_POST['address']); ?>'
};
},
url: "ajax_table.php"
url: "/ajax_table.php"
});
</script>
+1 -1
View File
@@ -87,7 +87,7 @@ if ($_POST['interface'] == 'Vlan%') {
address: '<?php echo mres($_POST['address']); ?>'
};
},
url: "ajax_table.php"
url: "/ajax_table.php"
});
</script>
+1 -1
View File
@@ -88,7 +88,7 @@ echo '"'.$_POST['address'].'"+';
address: '<?php echo mres($_POST['address']); ?>'
};
},
url: "ajax_table.php"
url: "/ajax_table.php"
});
</script>
+1 -1
View File
@@ -158,7 +158,7 @@ foreach( $ordered as $name=>$entry ) {
if( sizeof($arch) > 0 && sizeof($vers) > 0 ) {
?>
<tr>
<td><a href="<?php echo(generate_url(array('page'=>'packages','name'=>$name))); ?>"><?php echo $name; ?></a></td>
<td><a href="/packages/name=<?php echo $name; ?>/"><?php echo $name; ?></a></td>
<td><?php echo implode('<br/>',$vers); ?></td>
<td><?php echo implode('<br/>',$arch); ?></td>
<td><?php echo implode('<br/>',$devs); ?></td>
+14 -14
View File
@@ -823,7 +823,7 @@ echo '<div id="boxcar_appkey_template" class="hide">
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 '<div id="boxcar_appkey_template" class="hide">
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 '<div id="boxcar_appkey_template" class="hide">
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 '<div id="boxcar_appkey_template" class="hide">
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 '<div id="boxcar_appkey_template" class="hide">
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 '<div id="boxcar_appkey_template" class="hide">
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 '<div id="boxcar_appkey_template" class="hide">
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 '<div id="boxcar_appkey_template" class="hide">
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 '<div id="boxcar_appkey_template" class="hide">
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 '<div id="boxcar_appkey_template" class="hide">
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 '<div id="boxcar_appkey_template" class="hide">
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 '<div id="boxcar_appkey_template" class="hide">
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 '<div id="boxcar_appkey_template" class="hide">
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 '<div id="boxcar_appkey_template" class="hide">
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) {
+1 -1
View File
@@ -87,7 +87,7 @@ var grid = $("#syslog").bootgrid({
from: '<?php echo htmlspecialchars($vars['from']); ?>',
};
},
url: "ajax_table.php"
url: "/ajax_table.php"
});
$(function () {
+2 -2
View File
@@ -76,7 +76,7 @@ function print_error($text) {
print $console_color->convert("%r".$text."%n\n", false);
}
else {
echo('<div class="alert alert-danger"><img src="images/16/exclamation.png" align="absmiddle"> '.$text.'</div>');
echo('<div class="alert alert-danger"><img src="/images/16/exclamation.png" align="absmiddle"> '.$text.'</div>');
}
}
@@ -85,7 +85,7 @@ function print_message($text) {
print Console_Color2::convert("%g".$text."%n\n", false);
}
else {
echo('<div class="alert alert-success"><img src="images/16/tick.png" align="absmiddle"> '.$text.'</div>');
echo('<div class="alert alert-success"><img src="/images/16/tick.png" align="absmiddle"> '.$text.'</div>');
}
}
+3
View File
@@ -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;
+14 -1
View File
@@ -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;
@@ -0,0 +1,22 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
*
* 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);
}
}
@@ -0,0 +1,23 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
*
* 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);
}
}
+1 -1
View File
@@ -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
+7
View File
@@ -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")));
+2 -2
View File
@@ -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
+3
View File
@@ -1,3 +1,6 @@
<?php
$hardware = $poll_device['sysDescr'];
$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');
-87
View File
@@ -1,87 +0,0 @@
<?php
// MYSQL Check - FIXME
// 1 DROP
// 1 CREATE
// 25 ALTERS
include("includes/defaults.inc.php");
include("config.php");
echo("Updating Billing...");
$create_sql = "CREATE TABLE IF NOT EXISTS `bill_history` (
`bill_hist_id` int(11) NOT NULL AUTO_INCREMENT,
`bill_id` int(11) NOT NULL,
`updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`bill_datefrom` datetime NOT NULL,
`bill_dateto` datetime NOT NULL,
`bill_type` text NOT NULL,
`bill_allowed` bigint(20) NOT NULL,
`bill_used` bigint(20) NOT NULL,
`bill_overuse` bigint(20) NOT NULL,
`bill_percent` decimal(10,2) NOT NULL,
`rate_95th_in` bigint(20) NOT NULL,
`rate_95th_out` bigint(20) NOT NULL,
`rate_95th` bigint(20) NOT NULL,
`dir_95th` varchar(3) NOT NULL,
`rate_average` bigint(20) NOT NULL,
`rate_average_in` bigint(20) NOT NULL,
`rate_average_out` bigint(20) NOT NULL,
`traf_in` bigint(20) NOT NULL,
`traf_out` bigint(20) NOT NULL,
`traf_total` bigint(20) NOT NULL,
`pdf` longblob,
PRIMARY KEY (`bill_hist_id`),
UNIQUE KEY `unique_index` (`bill_id`,`bill_datefrom`,`bill_dateto`),
KEY `bill_id` (`bill_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;";
mysql_query("DROP TABLE `bill_history`");
mysql_query($create_sql);
mysql_query("ALTER TABLE `bills` ADD `bill_quota` bigint(20) NOT NULL AFTER `bill_gb`;");
mysql_query("ALTER TABLE `bills` DROP `rate_95th_in`;");
mysql_query("ALTER TABLE `bills` DROP `rate_95th_out`;");
mysql_query("ALTER TABLE `bills` DROP `rate_95th`;");
mysql_query("ALTER TABLE `bills` DROP `dir_95th`;");
mysql_query("ALTER TABLE `bills` DROP `total_data`;");
mysql_query("ALTER TABLE `bills` DROP `total_data_in`;");
mysql_query("ALTER TABLE `bills` DROP `total_data_out`;");
mysql_query("ALTER TABLE `bills` DROP `rate_average_in`;");
mysql_query("ALTER TABLE `bills` DROP `rate_average_out`;");
mysql_query("ALTER TABLE `bills` DROP `rate_average`;");
mysql_query("ALTER TABLE `bills` DROP `bill_last_calc`;");
mysql_query("ALTER TABLE `bills` ADD `rate_95th_in` bigint(20) NOT NULL;");
mysql_query("ALTER TABLE `bills` ADD `rate_95th_out` bigint(20) NOT NULL;");
mysql_query("ALTER TABLE `bills` ADD `rate_95th` bigint(20) NOT NULL;");
mysql_query("ALTER TABLE `bills` ADD `dir_95th` varchar(3) NOT NULL;");
mysql_query("ALTER TABLE `bills` ADD `total_data` bigint(20) NOT NULL;");
mysql_query("ALTER TABLE `bills` ADD `total_data_in` bigint(20) NOT NULL;");
mysql_query("ALTER TABLE `bills` ADD `total_data_out` bigint(20) NOT NULL;");
mysql_query("ALTER TABLE `bills` ADD `rate_average_in` bigint(20) NOT NULL;");
mysql_query("ALTER TABLE `bills` ADD `rate_average_out` bigint(20) NOT NULL;");
mysql_query("ALTER TABLE `bills` ADD `rate_average` bigint(20) NOT NULL;");
mysql_query("ALTER TABLE `bills` ADD `bill_last_calc` datetime NOT NULL;");
mysql_query("ALTER TABLE `bills` CHANGE `bill_cdr` bigint(20) NOT NULL;");
foreach (dbFetchRows("SELECT * FROM `bills`") as $bill_data) {
echo("Bill ".$bill['bill_id']." ".$bill['bill_name']);
if($bill_data['bill_gb'] > 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`");
?>
-20
View File
@@ -1,20 +0,0 @@
<?php
// MYSQL Check - FIXME
// 3 ALTERS
// 1 SELECT
// 1 UPDATE
mysql_query('ALTER TABLE `eventlog` DROP `id`');
mysql_query('ALTER TABLE `eventlog` ADD `event_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST');
$s = 'SELECT * FROM eventlog';
$q = mysql_query($s);
while ($event = mysql_fetch_assoc($q)) {
if ($event['interface']) {
mysql_query("UPDATE `eventlog` SET `interface` = NULL, `type` = 'interface', `reference` = '".$event['interface']."' WHERE `event_id` = '".$event['event_id']."'");
}
$i++;
}
mysql_query('ALTER TABLE `eventlog` DROP `interface`');
-202
View File
@@ -1,202 +0,0 @@
<?php
require 'includes/defaults.inc.php';
require 'config.php';
$basepath = $config['rrd_dir'].'/';
$files = (getDirectoryTree($basepath));
$count = count($files);
if ($config['rrdcached']) {
$rrdcached = ' --daemon '.$config['rrdcached'];
}
echo $count." Files \n";
$start = date('U');
$i = 0;
foreach ($files as $file) {
fixRdd($file);
$i++;
if ((date('U') - $start) > 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 = <<<FIRST
<ds>
<name> INDISCARDS </name>
<type> DERIVE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> 1.2500000000e+10 </max>
<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
<ds>
<name> OUTDISCARDS </name>
<type> DERIVE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> 1.2500000000e+10 </max>
<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
<ds>
<name> INUNKNOWNPROTOS </name>
<type> DERIVE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> 1.2500000000e+10 </max>
<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
<ds>
<name> INBROADCASTPKTS </name>
<type> DERIVE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> 1.2500000000e+10 </max>
<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
<ds>
<name> OUTBROADCASTPKTS </name>
<type> DERIVE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> 1.2500000000e+10 </max>
<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
<ds>
<name> INMULTICASTPKTS </name>
<type> DERIVE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> 1.2500000000e+10 </max>
<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
<ds>
<name> OUTMULTICASTPKTS </name>
<type> DERIVE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> 1.2500000000e+10 </max>
<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
<!-- Round Robin Archives -->
FIRST;
$second = <<<SECOND
<ds>
<primary_value> 0.0000000000e+00 </primary_value>
<secondary_value> NaN </secondary_value>
<value> NaN </value>
<unknown_datapoints> 0 </unknown_datapoints>
</ds>
<ds>
<primary_value> 0.0000000000e+00 </primary_value>
<secondary_value> NaN </secondary_value>
<value> NaN </value>
<unknown_datapoints> 0 </unknown_datapoints>
</ds>
<ds>
<primary_value> 0.0000000000e+00 </primary_value>
<secondary_value> NaN </secondary_value>
<value> NaN </value>
<unknown_datapoints> 0 </unknown_datapoints>
</ds>
<ds>
<primary_value> 0.0000000000e+00 </primary_value>
<secondary_value> NaN </secondary_value>
<value> NaN </value>
<unknown_datapoints> 0 </unknown_datapoints>
</ds>
<ds>
<primary_value> 0.0000000000e+00 </primary_value>
<secondary_value> NaN </secondary_value>
<value> NaN </value>
<unknown_datapoints> 0 </unknown_datapoints>
</ds>
<ds>
<primary_value> 0.0000000000e+00 </primary_value>
<secondary_value> NaN </secondary_value>
<value> NaN </value>
<unknown_datapoints> 0 </unknown_datapoints>
</ds>
<ds>
<primary_value> 0.0000000000e+00 </primary_value>
<secondary_value> NaN </secondary_value>
<value> NaN </value>
<unknown_datapoints> 0 </unknown_datapoints>
</ds>
</cdp_prep>
SECOND;
$third = <<<THIRD
<v> NaN </v><v> NaN </v><v> NaN </v><v> NaN </v><v> NaN </v><v> NaN </v><v> NaN </v></row>
THIRD;
// ---------------------------------------------------------------------------------------------------------
if (!preg_match('/DISCARDS/', $fileC)) {
$fileC = str_replace('<!-- Round Robin Archives -->', $first, $fileC);
$fileC = str_replace('</cdp_prep>', $second, $fileC);
$fileC = str_replace('</row>', $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";
-81
View File
@@ -1,81 +0,0 @@
<?php
require 'includes/defaults.inc.php';
require 'config.php';
$basepath = $config['rrd_dir'].'/';
$files = (sensor_getDirectoryTree($basepath));
$count = count($files);
echo $count." Files \n";
$start = date('U');
$i = 0;
foreach ($files as $file) {
sensor_fixRdd($file);
$i++;
if ((date('U') - $start) > 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('/<name> fan/', $fileC)) {
shell_exec("{$config['rrdtool']} tune $file $rrdcached -r fan:sensor");
rename($file, str_replace('/fan-', '/fanspeed-', $file));
}
else if (preg_match('/<name> volt/', $fileC)) {
shell_exec("{$config['rrdtool']} tune $file $rrdcached -r volt:sensor");
rename($file, str_replace('/volt-', '/voltage-', $file));
}
else if (preg_match('/<name> current/', $fileC)) {
shell_exec("{$config['rrdtool']} tune $file $rrdcached -r current:sensor");
}
else if (preg_match('/<name> freq/', $fileC)) {
shell_exec("{$config['rrdtool']} tune $file $rrdcached -r freq:sensor");
rename($file, str_replace('/freq-', '/frequency-', $file));
}
else if (preg_match('/<name> humidity/', $fileC)) {
shell_exec("{$config['rrdtool']} tune $file $rrdcached -r humidity:sensor");
}
else if (preg_match('/<name> temp/', $fileC)) {
shell_exec("{$config['rrdtool']} tune $file $rrdcached -r temp:sensor");
rename($file, str_replace('/temp-', '/temperature-', $file));
}
}
echo "\n";