Fixed merge conflict

This commit is contained in:
laf
2015-06-09 14:36:45 +01:00
53 changed files with 1861 additions and 318 deletions
+1
View File
@@ -33,3 +33,4 @@ Contributors to LibreNMS:
- James Campbell <neokjames@gmail.com> (neokjames)
[1]: http://observium.org/ "Observium web site"
+2 -1
View File
@@ -247,11 +247,12 @@ function ExtTransports($obj) {
global $config;
$tmp = false; //To keep scrutinizer from naging because it doesnt understand eval
foreach( $config['alert']['transports'] as $transport=>$opts ) {
if( ($opts === true || !empty($opts)) && file_exists($config['install_dir']."/includes/alerts/transport.".$transport.".php") ) {
if( ($opts === true || !empty($opts)) && $opts != false && file_exists($config['install_dir']."/includes/alerts/transport.".$transport.".php") ) {
echo $transport." => ";
eval('$tmp = function($obj,$opts) { global $config; '.file_get_contents($config['install_dir']."/includes/alerts/transport.".$transport.".php").' };');
$tmp = $tmp($obj,$opts);
echo ($tmp ? "OK" : "ERROR")."; ";
log_event("Issued ".$obj['severity']." alert for rule '".$obj['name']."' to transport '".$transport."'",$obj['device_id']);
}
}
}
+1 -1
View File
@@ -9,4 +9,4 @@ find . \
-path ./mibs -prune -o \
-path ./rrd -prune -o \
-name .git -prune -o \
-type f -print|xargs grep "$@"
-type f -print0|xargs -0 grep "$@"
+14
View File
@@ -139,6 +139,8 @@ $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;
@@ -165,6 +167,8 @@ $config['alert']['default_mail'] = ''; //Default ema
## <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`.
This basis has to contain an array with URLs of each API to call.
@@ -180,6 +184,8 @@ $config['alert']['transports']['api']['get'][] = "https://api.thirdparti.es/issu
## <a name="transports-nagios">Nagios Compatible</a>
> You can configure these options within the WebUI now, please avoid setting these options within config.php
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
@@ -188,6 +194,8 @@ $config['alert']['transports']['nagios'] = "/path/to/my.fifo"; //Flapjack expect
## <a name="transports-irc">IRC</a>
> 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).
```php
@@ -196,6 +204,8 @@ $config['alert']['transports']['irc'] = true;
## <a name="transports-slack">Slack</a>
> You can configure these options within the WebUI now, please avoid setting these options within config.php
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
@@ -207,6 +217,8 @@ $config['alert']['transports']['slack'][] = array('url' => "https://hooks.slack.
## <a name="transports-hipchat">HipChat</a>
> You can configure these options within the WebUI now, please avoid setting these options within config.php
The HipChat transport requires the following:
__room_id__ = HipChat Room ID
@@ -252,6 +264,8 @@ $config['alert']['transports']['hipchat'][] = array("url" => "https://api.hipcha
## <a name="transports-pagerduty">PagerDuty</a>
> You can configure these options within the WebUI now, please avoid setting these options within config.php
Enabling PagerDuty transports is almost as easy as enabling email-transports.
All you need is to create a Service with type Generic API on your PagerDuty dashboard.
+25 -1
View File
@@ -1,3 +1,22 @@
### June 2015
#### Bug fixes
- Fixed services list SQL issue (PR1181)
- Fixed negative values for storage when volume is > 2TB (PR1185)
- Fixed visual display for input fields on /syslog/ (PR1193)
- Fixed fatal php issue in shoutcast.php (PR1203)
- Fixed percent bars in /bills/ (PR1208)
- Fixed item count in memory and storage pages (PR1210)
#### Improvements
- Updated Syslog docs to include syslog-ng 3.5.1 updates (PR1171)
- Added Pushover Transport (PR1180, PR1191)
- Converted processors and memory table to bootgrid (PR1188, PR1192)
- Issued alerts and transport now logged to eventlog (PR1194)
- Added basic support for Enterasys devices (PR1211)
- Added dynamic config to configure alerting (PR1153)
- Added basic support for Multimatic USV (PR1215)
### May 2015
#### Bug fixes
@@ -31,6 +50,9 @@
- Fixed ARP search graph type reference (PR1131)
- Fixed showing state=X in device list (PR1144)
- Removed ability for demo user to delete users (PR1151)
- Fixed user / port perms for top X front page boxes (PR1156)
- Fixed truncating UTF-8 strings (PR1166)
- Fixed attaching templates due to JS issue (PR1167)
#### Improvements
- Added loading bar to top nav (PR893)
@@ -69,7 +91,7 @@
- Added disk temperature for Synology DSM (PR986)
- Added ICMP, TLS/SSL and Domain expiry service checks (PR987, PR1040, PR1041)
- Added IPMI detection (PR988)
- Miktrotik MIB update (PR991)
- Mikrotik MIB update (PR991)
- Set better timeperiod for caching graphs (PR992)
- Added config option to disable port relationship in ports list (PR996)
- Added support for custom customer description parse (PR998)
@@ -105,6 +127,8 @@
- Added config options for region and resolution on globe map (PR1137)
- Addded RRDCached example docs (PR1148)
- Updated support for additional NetBotz models (PR1152)
- Updated /iftype/ page to include speed/circuit/notes (PR1155)
- Added detection for PowerConnect 55XX devices (PR1165)
### Apr 2015
+2
View File
@@ -215,6 +215,8 @@ Arrays of subnets to exclude in auto discovery mode.
#### Email configuration
> You can configure these options within the WebUI now, please avoid setting these options within config.php
```php
$config['email_backend'] = 'mail';
$config['email_from'] = NULL;
+99
View File
@@ -0,0 +1,99 @@
<?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.
*/
enable_debug();
include_once("../includes/defaults.inc.php");
include_once("../config.php");
include_once("../includes/definitions.inc.php");
include_once("includes/functions.inc.php");
include_once("../includes/functions.php");
include_once("includes/authenticate.inc.php");
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
$new_conf_type = $_POST['new_conf_type'];
$new_conf_name = $_POST['new_conf_name'];
$new_conf_desc = $_POST['new_conf_desc'];
if(empty($new_conf_name))
{
echo("You haven't specified a config name");
exit;
}
elseif(empty($new_conf_desc))
{
echo("You haven't specified a config description");
exit;
}
elseif(empty($_POST['new_conf_single_value']) && empty($_POST['new_conf_multi_value']))
{
echo("You haven't specified a config value");
exit;
}
$db_inserted = '0';
if($new_conf_type == 'Single')
{
$new_conf_type = 'single';
$new_conf_value = $_POST['new_conf_single_value'];
$db_inserted = add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc);
}
elseif($new_conf_type == 'Single Array')
{
$new_conf_type = 'single-array';
$new_conf_value = $_POST['new_conf_single_value'];
$db_inserted = add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc);
}
elseif($new_conf_type == 'Standard Array' || $new_conf_type == 'Multi Array')
{
if($new_conf_type == 'Standard Array')
{
$new_conf_type = 'array';
}
elseif($new_conf_type == 'Multi Array')
{
$new_conf_type = 'multi-array';
}
else
{
# $new_conf_type is invalid so clear values so we don't create any config
$new_conf_value = '';
}
$new_conf_value = nl2br($_POST['new_conf_multi_value']);
$values = explode('<br />',$new_conf_value);
foreach ($values as $item)
{
$new_conf_value = trim($item);
$db_inserted = add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc);
}
}
else
{
echo('Bad config type!');
$db_inserted = 0;
exit;
}
if($db_inserted == 1)
{
echo('Your new config item has been added');
}
else
{
echo('An error occurred adding your config item to the database');
}
?>
+48
View File
@@ -0,0 +1,48 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk>
*
* 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.
*/
// FUA
if(!is_numeric($_POST['config_id']))
{
echo('error with data');
exit;
}
else
{
if($_POST['state'] == 'true')
{
$state = 1;
}
elseif($_POST['state'] == 'false')
{
$state = 0;
}
else
{
$state = 0;
}
$update = dbUpdate(array('config_disabled' => $state), 'config', '`config_id` = ?', array($_POST['config_id']));
if(!empty($update) || $update == '0')
{
echo('success');
exit;
}
else
{
echo('error');
exit;
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk>
*
* 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.
*/
// FUA
if(!is_numeric($_POST['config_id']) || empty($_POST['data']))
{
echo('error with data');
exit;
}
else
{
$data = mres($_POST['data']);
$update = dbUpdate(array('config_value' => "$data"), 'config', '`config_id` = ?', array($_POST['config_id']));
if(!empty($update) || $update == '0')
{
echo('success');
exit;
}
else
{
echo('error');
exit;
}
}
+108
View File
@@ -0,0 +1,108 @@
<?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(is_admin() === false) {
$response = array('status'=>'error','message'=>'Need to be admin');
echo _json_encode($response);
exit;
}
$action = mres($_POST['action']);
$config_group = mres($_POST['config_group']);
$config_sub_group = mres($_POST['config_sub_group']);
$config_name = mres($_POST['config_name']);
$config_value = mres($_POST['config_value']);
$config_extra = mres($_POST['config_extra']);
$config_room_id = mres($_POST['config_room_id']);
$config_from = mres($_POST['config_from']);
$status = 'error';
$message = 'Error with config';
if ($action == 'remove' || $action == 'remove-slack' || $action == 'remove-hipchat') {
$config_id = mres($_POST['config_id']);
if (empty($config_id)) {
$message = 'No config id passed';
} else {
if (dbDelete('config', '`config_id`=?', array($config_id))) {
if ($action == 'remove-slack') {
dbDelete('config', "`config_name` LIKE 'alert.transports.slack.$config_id.%'");
} elseif ($action == 'remove-hipchat') {
dbDelete('config', "`config_name` LIKE 'alert.transports.hipchat.$config_id.%'");
}
$status = 'ok';
$message = 'Config item removed';
} else {
$message = 'General error, could not remove config';
}
}
} elseif ($action == 'add-slack') {
if (empty($config_value)) {
$message = 'No Slack url provided';
} else {
$config_id = dbInsert(array('config_name' => 'alert.transports.slack.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_value, 'config_descr'=>'Slack Transport'), 'config');
if ($config_id > 0) {
dbUpdate(array('config_name' => 'alert.transports.slack.'.$config_id.'.url'), 'config', 'config_id=?', array($config_id));
$status = 'ok';
$message = 'Config item created';
$extras = explode('\n',$config_extra);
foreach ($extras as $option) {
list($k,$v) = explode("=", $option,2);
if (!empty($k) || !empty($v)) {
dbInsert(array('config_name' => 'alert.transports.slack.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$v, 'config_descr'=>'Slack Transport'), 'config');
}
}
} else {
$message = 'Could not create config item';
}
}
} elseif ($action == 'add-hipchat') {
if (empty($config_value) || empty($config_room_id) || empty($config_from)) {
$message = 'No hipchat url, room id or from provided';
} else {
$config_id = dbInsert(array('config_name' => 'alert.transports.hipchat.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_value, 'config_descr'=>'Hipchat Transport'), 'config');
if ($config_id > 0) {
dbUpdate(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.url'), 'config', 'config_id=?', array($config_id));
dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.room_id', 'config_value' => $config_room_id, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_room_id, 'config_descr'=>'Hipchat URL'), 'config');
dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.from', 'config_value' => $config_from, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_from, 'config_descr'=>'Hipchat From'), 'config');
$status = 'ok';
$message = 'Config item created';
$extras = explode('\n',$config_extra);
foreach ($extras as $option) {
list($k,$v) = explode("=", $option,2);
if (!empty($k) || !empty($v)) {
dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$v, 'config_descr'=>'Hipchat '.$v), 'config');
}
}
} else {
$message = 'Could not create config item';
}
}
} else {
if (empty($config_group) || empty($config_sub_group) || empty($config_name) || empty($config_value)) {
$message = 'Missing config name or value';
} else {
$config_id = dbInsert(array('config_name' => $config_name, 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_value, 'config_descr'=>'API Transport'), 'config');
if ($config_id > 0) {
dbUpdate(array('config_name'=>$config_name.$config_id),'config','config_id=?',array($config_id));
$status = 'ok';
$message = 'Config item created';
} else {
$message = 'Could not create config item';
}
}
}
$response = array('status'=>$status,'message'=>$message, 'config_id'=>$config_id);
echo _json_encode($response);
+62
View File
@@ -0,0 +1,62 @@
<?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(is_admin() === false) {
die('ERROR: You need to be admin');
}
$config_id = mres($_POST['config_id']);
$action = mres($_POST['action']);
$config_type = mres($_POST['config_type']);
$status = 'error';
if (!is_numeric($config_id)) {
$message = 'ERROR: No alert selected';
} elseif ($action == 'update-textarea') {
$extras = explode(PHP_EOL,$_POST['config_value']);
foreach ($extras as $option) {
list($k,$v) = explode("=", $option,2);
if (!empty($k) || !empty($v)) {
if ($config_type == 'slack') {
$db_id[] = dbInsert(array('config_name' => 'alert.transports.slack.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default'=>$v, 'config_descr'=>'Slack Transport'), 'config');
} elseif ($config_type == 'hipchat') {
$db_id[] = dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default'=>$v, 'config_descr'=>'Hipchat Transport'), 'config');
}
}
}
$db_inserts = implode(",",$db_id);
if (!empty($db_inserts)) {
if ($config_type == 'slack') {
dbDelete('config',"(`config_name` LIKE 'alert.transports.slack.$config_id.%' AND `config_name` != 'alert.transports.slack.$config_id.url' AND `config_id` NOT IN ($db_inserts))");
} elseif ($config_type == 'hipchat') {
dbDelete('config',"(`config_name` LIKE 'alert.transports.hipchat.$config_id.%' AND (`config_name` != 'alert.transports.hipchat.$config_id.url' AND `config_name` != 'alert.transports.hipchat.$config_id.room_id' AND `config_name` != 'alert.transports.hipchat.$config_id.from') AND `config_id` NOT IN ($db_inserts))");
}
}
$message = 'Config item has been updated:';
$status = 'ok';
} else {
$state = mres($_POST['config_value']);
$update = dbUpdate(array('config_value' => $state), 'config', '`config_id`=?', array($config_id));
if(!empty($update) || $update == '0')
{
$message = 'Alert rule has been updated.';
$status = 'ok';
} else {
$message = 'ERROR: Alert rule has not been updated.';
}
}
$response = array('status'=>$status,'message'=>$message);
echo _json_encode($response);
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

+58
View File
@@ -774,7 +774,65 @@ function clean_bootgrid($string) {
$output = str_replace(array("\r","\n"), "", $string);
$output = addslashes($output);
return $output;
}
//Insert new config items
function add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc) {
if (dbInsert(array('config_name' => $new_conf_name, 'config_value' => $new_conf_value, 'config_default' => $new_conf_value, 'config_type' => $new_conf_type, 'config_desc' => $new_conf_desc, 'config_group' => '500_Custom Settings', 'config_sub_group' => '01_Custom settings', 'config_hidden' => '0', 'config_disabled' => '0'), 'config')) {
$db_inserted = 1;
} else {
$db_inserted = 0;
}
return($db_inserted);
}
function get_config_by_group($group) {
$group = array($group);
$items = array();
foreach (dbFetchRows("SELECT * FROM `config` WHERE `config_group` = '?'", array($group)) as $config_item) {
$val = $config_item['config_value'];
if (filter_var($val,FILTER_VALIDATE_INT)) {
$val = (int) $val;
} elseif (filter_var($val,FILTER_VALIDATE_FLOAT)) {
$val = (float) $val;
} elseif (filter_var($val,FILTER_VALIDATE_BOOLEAN)) {
$val =(boolean) $val;
}
if ($val === TRUE) {
$config_item += array('config_checked'=>'checked');
}
$items[$config_item['config_name']] = $config_item;
}
return $items;
}
function get_config_like_name($name) {
$name = array($name);
$items = array();
foreach (dbFetchRows("SELECT * FROM `config` WHERE `config_name` LIKE '%?%'", array($name)) as $config_item) {
$items[$config_item['config_name']] = $config_item;
}
return $items;
}
function get_config_by_name($name) {
$config_item = dbFetchRow("SELECT * FROM `config` WHERE `config_name` = ?", array($name));
return $config_item;
}
function set_config_name($name,$config_value) {
return dbUpdate(array('config_value' => $config_value), 'config', '`config_name`=?', array($name));
}
function get_url() {
// http://stackoverflow.com/questions/2820723/how-to-get-base-url-with-php
// http://stackoverflow.com/users/184600/ma%C4%8Dek
return sprintf(
"%s://%s%s",
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
$_SERVER['SERVER_NAME'],
$_SERVER['REQUEST_URI']
);
}
function alert_details($details) {
@@ -1,6 +1,7 @@
<?php
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] ."/". safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] ."/".
safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = "Channel";
+72
View File
@@ -0,0 +1,72 @@
<?php
$graph_type = "mempool_usage";
$where = 1;
$sql = " FROM `mempools` AS `M` LEFT JOIN `devices` AS `D` ON `M`.`device_id` = `D`.`device_id`";
if (is_admin() === FALSE && is_read() === FALSE) {
$sql .= " LEFT JOIN `devices_perms` AS `DP` ON `M`.`device_id` = `DP`.`device_id`";
$where .= " AND `DP`.`user_id`=?";
$param[] = $_SESSION['user_id'];
}
$sql .= " WHERE $where";
if (isset($searchPhrase) && !empty($searchPhrase)) {
$sql .= " AND (`hostname` LIKE '%$searchPhrase%' OR `mempool_descr` LIKE '%$searchPhrase%')";
}
$count_sql = "SELECT COUNT(`mempool_id`) $sql";
$count = dbFetchCell($count_sql,$param);
if (empty($count)) {
$count = 0;
}
if (!isset($sort) || empty($sort)) {
$sort = '`D`.`hostname`, `M`.`mempool_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 $mempool) {
$perc = round($mempool['mempool_perc'], 0);
$total = formatStorage($mempool['mempool_total']);
$free = formatStorage($mempool['mempool_free']);
$used = formatStorage($mempool['mempool_used']);
$graph_array['type'] = $graph_type;
$graph_array['id'] = $mempool['mempool_id'];
$graph_array['from'] = $config['time']['day'];
$graph_array['to'] = $config['time']['now'];
$graph_array['height'] = "20";
$graph_array['width'] = "80";
$graph_array_zoom = $graph_array;
$graph_array_zoom['height'] = "150";
$graph_array_zoom['width'] = "400";
$link = "graphs/id=" . $graph_array['id'] . "/type=" . $graph_array['type'] . "/from=" . $graph_array['from'] . "/to=" . $graph_array['to'] . "/";
$mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
$background = get_percentage_colours($perc);
$bar_link = overlib_link($link, print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $free, "ffffff", $background['right']), generate_graph_tag($graph_array_zoom), NULL);
$response[] = array('hostname' => generate_device_link($mempool),
'mempool_descr' => $mempool['mempool_descr'],
'graph' => $mini_graph,
'mempool_used' => $bar_link,
'mempool_perc' => $perc . "%");
if ($_POST['view'] == "graphs") {
$graph_array['height'] = "100";
$graph_array['width'] = "216";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $mempool['mempool_id'];
$graph_array['type'] = $graph_type;
$return_data = true;
include("includes/print-graphrow.inc.php");
unset($return_data);
$response[] = array('hostname' => $graph_data[0],
'mempool_descr' => $graph_data[1],
'graph' => $graph_data[2],
'mempool_used' => $graph_data[3],
'mempool_perc' => '');
} # endif graphs
}
$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$count);
echo _json_encode($output);
+67
View File
@@ -0,0 +1,67 @@
<?php
$graph_type = "processor_usage";
$where = 1;
$sql = " FROM `processors` AS `P` LEFT JOIN `devices` AS `D` ON `P`.`device_id` = `D`.`device_id`";
if (is_admin() === FALSE && is_read() === FALSE) {
$sql .= " LEFT JOIN `devices_perms` AS `DP` ON `P`.`device_id` = `DP`.`device_id`";
$where .= " AND `DP`.`user_id`=?";
$param[] = $_SESSION['user_id'];
}
$sql .= " WHERE $where";
if (isset($searchPhrase) && !empty($searchPhrase)) {
$sql .= " AND (`hostname` LIKE '%$searchPhrase%' OR `processor_descr` LIKE '%$searchPhrase%')";
}
$count_sql = "SELECT COUNT(`processor_id`) $sql";
$total = dbFetchCell($count_sql,$param);
if (empty($total)) {
$total = 0;
}
if (!isset($sort) || empty($sort)) {
$sort = '`D`.`hostname`, `P`.`processor_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 $processor) {
$perc = round($processor['processor_usage'], 0);
$graph_array['type'] = $graph_type;
$graph_array['id'] = $processor['processor_id'];
$graph_array['from'] = $config['time']['day'];
$graph_array['to'] = $config['time']['now'];
$graph_array['height'] = "20";
$graph_array['width'] = "80";
$graph_array_zoom = $graph_array;
$graph_array_zoom['height'] = "150";
$graph_array_zoom['width'] = "400";
$link = "graphs/id=" . $graph_array['id'] . "/type=" . $graph_array['type'] . "/from=" . $graph_array['from'] . "/to=" . $graph_array['to'] . "/";
$mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
$background = get_percentage_colours($perc);
$bar_link = overlib_link($link, print_percentage_bar (400, 20, $perc, $perc."%", "ffffff", $background['left'], (100 - $perc)."%" , "ffffff", $background['right']), generate_graph_tag($graph_array_zoom), NULL);
$response[] = array('hostname' => generate_device_link($processor),
'processor_descr' => $processor['processor_descr'],
'graph' => $mini_graph,
'processor_usage' => $bar_link);
if ($_POST['view'] == "graphs") {
$graph_array['height'] = "100";
$graph_array['width'] = "216";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $processor['processor_id'];
$graph_array['type'] = $graph_type;
$return_data = true;
include("includes/print-graphrow.inc.php");
unset($return_data);
$response[] = array('hostname' => $graph_data[0],
'processor_descr' => $graph_data[1],
'graph' => $graph_data[2],
'processor_usage' => $graph_data[3]);
} # endif graphs
}
$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total);
echo _json_encode($output);
+4 -4
View File
@@ -20,9 +20,9 @@ if (isset($searchPhrase) && !empty($searchPhrase)) {
$count_sql = "SELECT COUNT(`storage_id`) $sql";
$total = dbFetchCell($count_sql,$param);
if (empty($total)) {
$total = 0;
$count = dbFetchCell($count_sql,$param);
if (empty($count)) {
$count = 0;
}
if (!isset($sort) || empty($sort)) {
@@ -87,5 +87,5 @@ foreach (dbFetchRows($sql,$param) as $drive) {
} # endif graphs
}
$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total);
$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$count);
echo _json_encode($output);
+1 -1
View File
@@ -24,7 +24,7 @@ $pagetitle[] = "Alert Log";
<th data-column-id="time_logged" data-order="desc">Time logged</th>
<th data-column-id="details" data-sortable="false">&nbsp;</th>
<th data-column-id="hostname">Device</th>
<th data-column-id="alert">alert</th>
<th data-column-id="alert">Alert</th>
<th data-column-id="status" data-sortable="false">Status</th>
</tr>
</thead>
+1 -1
View File
@@ -271,7 +271,7 @@ for ($x=1;$x<32;$x++) {
<td>$allowed</td>
<td>$used</td>
<td style=\"text-align: center;\">$overuse</td>
<td>".print_percentage_bar (250, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."</td>
<td>".print_percentage_bar (250, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."</td>
<td><a href='".generate_url(array('page' => "bill", 'bill_id' => $bill['bill_id'], 'view' => "edit"))."'><img src='images/16/wrench.png' align=absmiddle alt='Edit'> Edit</a></td>
</tr>
");
+1 -1
View File
@@ -13,7 +13,7 @@ foreach (dbFetchRows("SELECT * FROM `mempools` WHERE device_id = ?", array($devi
{
if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state');
if($debug) { print_r($state); }
+16 -8
View File
@@ -6,17 +6,25 @@ print_optionbar_start();
echo("<strong>Logging</strong> &#187; ");
if ($vars['section'] == "eventlog")
{ echo('<span class="pagemenu-selected">'); }
if ($vars['section'] == "eventlog") {
echo('<span class="pagemenu-selected">');
}
echo(generate_link("Event Log" , $vars, array('section'=>'eventlog')));
if ($vars['section'] == "eventlog") { echo("</span>"); }
if ($vars['section'] == "eventlog") {
echo("</span>");
}
echo(" | ");
if (isset($config['enable_syslog']) && $config['enable_syslog'] == 1) {
echo(" | ");
if ($vars['section'] == "syslog")
{ echo('<span class="pagemenu-selected">'); }
echo(generate_link("Syslog" , $vars, array('section'=>'syslog')));
if ($vars['section'] == "syslog") { echo("</span>"); }
if ($vars['section'] == "syslog") {
echo('<span class="pagemenu-selected">');
}
echo(generate_link("Syslog" , $vars, array('section'=>'syslog')));
if ($vars['section'] == "syslog") {
echo("</span>");
}
}
switch ($vars['section'])
{
+1 -1
View File
@@ -44,7 +44,7 @@ $sql = "SELECT *, DATE_FORMAT(timestamp, '%Y-%m-%d %T') AS date from syslog WHE
$sql .= " ORDER BY timestamp DESC LIMIT 1000";
echo(' <div class="panel panel-default panel-condensed">
<div class="panel-heading">
<strong>Eventlog entries</strong>
<strong>Syslog entries</strong>
</div>
<table class="table table-hover table-condensed table-striped">');
foreach (dbFetchRows($sql, $param) as $entry) { include("includes/print-syslog.inc.php"); }
@@ -14,7 +14,7 @@ if (count($sensors))
<table class="table table-hover table-condensed table-striped">');
foreach ($sensors as $sensor)
{
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value');
}
+1 -1
View File
@@ -22,7 +22,7 @@ if (count($mempools))
foreach ($mempools as $mempool)
{
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state');
if($debug) { print_r($state); }
+1 -1
View File
@@ -4,7 +4,7 @@ if (!isset($vars['view']) ) { $vars['view'] = "graphs"; }
$port = dbFetchRow("SELECT * FROM `ports` WHERE `port_id` = ?", array($vars['port']));
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$state = $memcache->get('port-'.$port['port_id'].'-state');
if($debug) { print_r($state); }
+1 -1
View File
@@ -106,7 +106,7 @@ if ($vars['view'] == 'minigraphs')
foreach ($ports as $port)
{
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$state = $memcache->get('port-'.$port['port_id'].'-state');
if($debug) { print_r($state); }
+3 -3
View File
@@ -9,7 +9,7 @@ if ($used_sensors['voltage']) $datas[] = 'voltage';
if ($used_sensors['frequency']) $datas[] = 'frequency';
if ($used_sensors['current']) $datas[] = 'current';
if ($used_sensors['power']) $datas[] = 'power';
if ($used_sensors['dBm']) $datas[] = 'dBm';
if ($used_sensors['dbm']) $datas[] = 'dbm';
// FIXME generalize -> static-config ?
$type_text['overview'] = "Overview";
@@ -17,7 +17,7 @@ $type_text['temperature'] = "Temperature";
$type_text['charge'] = "Battery Charge";
$type_text['humidity'] = "Humidity";
$type_text['mempool'] = "Memory";
$type_text['storage'] = "Disk Usage";
$type_text['storage'] = "Storage";
$type_text['diskio'] = "Disk I/O";
$type_text['processor'] = "Processor";
$type_text['voltage'] = "Voltage";
@@ -26,7 +26,7 @@ $type_text['frequency'] = "Frequency";
$type_text['current'] = "Current";
$type_text['power'] = "Power";
$type_text['toner'] = "Toner";
$type_text['dBm'] = "dBm";
$type_text['dbm'] = "dBm";
if (!$vars['metric']) { $vars['metric'] = "processor"; }
if (!$vars['view']) { $vars['view'] = "detail"; }
+37 -85
View File
@@ -1,86 +1,38 @@
<?php
<div class="table-responsive">
<table id="mempool" class="table table-hover table-condensed mempool">
<thead>
<tr>
<th data-column-id="hostname">Device</th>
<th data-column-id="mempool_descr">Memory</th>
<th data-column-id="graph" data-sortable="false" data-searchable="false"></th>
<th data-column-id="mempool_used" data-searchable="false">Used</th>
<th data-column-id="mempool_perc" data-searchable="false">Usage</th>
</tr>
</thead>
</table>
</div>
$graph_type = "mempool_usage";
echo("<div style='margin-top: 5px; padding: 0px;'>");
echo("<table class='table table-condensed'>");
echo("<tr class=tablehead>
<th>Device</th>
<th>Memory</th>
<th></th>
<th>Usage</th>
<th>Used</th>
</tr>");
foreach (dbFetchRows("SELECT * FROM `mempools` AS M, `devices` as D WHERE D.device_id = M.device_id ORDER BY D.hostname") as $mempool)
{
if (device_permitted($mempool['device_id']))
{
$text_descr = $mempool['mempool_descr'];
if ($config['memcached']['enable'])
{
$state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state');
if($debug) { print_r($state); }
if(is_array($state)) { $port = array_merge($mempool, $state); }
unset($state);
}
$mempool_url = "device/device=".$mempool['device_id']."/tab=health/metric=mempool/";
$mini_url = "graph.php?id=".$mempool['mempool_id']."&amp;type=".$graph_type."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=80&amp;height=20&amp;bg=f4f4f4";
$mempool_popup = "onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$text_descr;
$mempool_popup .= "</div><img src=\'graph.php?id=" . $mempool['mempool_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['month']."&amp;to=".$config['time']['now']."&amp;width=400&amp;height=125\'>";
$mempool_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"";
$total = formatStorage($mempool['mempool_total']);
$used = formatStorage($mempool['mempool_used']);
$free = formatStorage($mempool['mempool_free']);
$background = get_percentage_colours($mempool['mempool_perc']);
echo("<tr class='health'>
<td>".generate_device_link($mempool)."</td>
<td class=tablehead><a href='".$mempool_url."' $mempool_popup>" . $text_descr . "</a></td>
<td width=90><a href='".$mempool_url."' $mempool_popup><img src='$mini_url'></a></td>
<td width=200><a href='".$mempool_url."' $mempool_popup>
".print_percentage_bar (400, 20, $mempool['mempool_perc'], "$used / $total", "ffffff", $background['left'], $free , "ffffff", $background['right'])."
</a></td>
<td width=50>".$mempool['mempool_perc']."%</td>
</tr>");
if ($vars['view'] == "graphs")
{
echo("<tr></tr><tr class='health'><td colspan=5>");
$daily_graph = "graph.php?id=" . $mempool['mempool_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=211&amp;height=100";
$daily_url = "graph.php?id=" . $mempool['mempool_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=400&amp;height=150";
$weekly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['week']."&amp;to=".$config['time']['now']."&amp;width=211&amp;height=100";
$weekly_url = "graph.php?id=" . $mempool['mempool_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['week']."&amp;to=".$config['time']['now']."&amp;width=400&amp;height=150";
$monthly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['month']."&amp;to=".$config['time']['now']."&amp;width=211&amp;height=100";
$monthly_url = "graph.php?id=" . $mempool['mempool_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['month']."&amp;to=".$config['time']['now']."&amp;width=400&amp;height=150";
$yearly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['year']."&amp;to=".$config['time']['now']."&amp;width=211&amp;height=100";
$yearly_url = "graph.php?id=" . $mempool['mempool_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['year']."&amp;to=".$config['time']['now']."&amp;width=400&amp;height=150";
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$daily_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$weekly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$monthly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$yearly_graph' border=0></a>");
echo("</td></tr>");
} # endif graphs
}
}
echo("</table>");
echo("</div>");
?>
<script>
var grid = $("#mempool").bootgrid({
ajax: true,
rowCount: [25,50,100,250,-1],
post: function ()
{
return {
id: "mempool",
view: '<?php echo $vars['view']; ?>'
};
},
url: "/ajax_table.php",
formatters: {
"status": function(column,row) {
return "<h4><span class='label label-"+row.extra+" threeqtr-width'>" + row.msg + "</span></h4>";
},
"ack": function(column,row) {
return "<button type='button' class='btn btn-"+row.ack_col+" btn-sm command-ack-alert' data-target='#ack-alert' data-state='"+row.state+"' data-alert_id='"+row.alert_id+"' name='ack-alert' id='ack-alert' data-extra='"+row.extra+"'><span class='glyphicon glyphicon-"+row.ack_ico+"'aria-hidden='true'></span></button>";
}
},
templates: {
}
});
</script>
+36 -82
View File
@@ -1,83 +1,37 @@
<?php
<div class="table-responsive">
<table id="processor" class="table table-hover table-condensed processor">
<thead>
<tr>
<th data-column-id="hostname">Device</th>
<th data-column-id="processor_descr">Processor</th>
<th data-column-id="graph" data-sortable="false" data-searchable="false"></th>
<th data-column-id="processor_usage" data-searchable="false">Usage</th>
</tr>
</thead>
</table>
</div>
$graph_type = "processor_usage";
echo("<div style='margin-top: 5px; padding: 0px;'>");
echo(" <table class='table table-condensed'>");
echo("<tr>
<th>Device</th>
<th>Processor</th>
<th></th>
<th>Usage</th>
</tr>");
foreach (dbFetchRows("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.device_id = P.device_id ORDER BY D.hostname") as $proc)
{
if (device_permitted($proc['device_id']))
{
$device = $proc;
// FIXME should that really be done here? :-)
$text_descr = $proc['processor_descr'];
$text_descr = str_replace("Routing Processor", "RP", $text_descr);
$text_descr = str_replace("Switching Processor", "SP", $text_descr);
$text_descr = str_replace("Sub-Module", "Module ", $text_descr);
$text_descr = str_replace("DFC Card", "DFC", $text_descr);
$proc_url = "device/device=".$device['device_id']."/tab=health/metric=processor/";
$mini_url = "graph.php?id=".$proc['processor_id']."&amp;type=".$graph_type."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=80&amp;height=20&amp;bg=f4f4f400";
$proc_popup = "onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$text_descr;
$proc_popup .= "</div><img src=\'graph.php?id=" . $proc['processor_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['month']."&amp;to=".$config['time']['now']."&amp;width=400&amp;height=125\'>";
$proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"";
$perc = round($proc['processor_usage']);
$background = get_percentage_colours($perc);
echo(" <tr class=\"health\">
<td>".generate_device_link($proc)."</td>
<td class=\"tablehead\"><a href='".$proc_url."' $proc_popup>" . $text_descr . "</a></td>
<td width=\"90\"><a href=\"".$proc_url."\" $proc_popup><img src=\"$mini_url\" /></a></td>
<td width=\"200\"><a href=\"".$proc_url."\" $proc_popup>
".print_percentage_bar (400, 20, $perc, $perc."%", "ffffff", $background['left'], (100 - $perc)."%" , "ffffff", $background['right']));
echo('</a></td>
</tr>');
if ($vars['view'] == "graphs")
{
echo(' <tr></tr><tr class="health"><td colspan="5">');
$daily_graph = "graph.php?id=" . $proc['processor_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=211&amp;height=100";
$daily_url = "graph.php?id=" . $proc['processor_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=400&amp;height=150";
$weekly_graph = "graph.php?id=" . $proc['processor_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['week']."&amp;to=".$config['time']['now']."&amp;width=211&amp;height=100";
$weekly_url = "graph.php?id=" . $proc['processor_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['week']."&amp;to=".$config['time']['now']."&amp;width=400&amp;height=150";
$monthly_graph = "graph.php?id=" . $proc['processor_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['month']."&amp;to=".$config['time']['now']."&amp;width=211&amp;height=100";
$monthly_url = "graph.php?id=" . $proc['processor_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['month']."&amp;to=".$config['time']['now']."&amp;width=400&amp;height=150";
$yearly_graph = "graph.php?id=" . $proc['processor_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['year']."&amp;to=".$config['time']['now']."&amp;width=211&amp;height=100";
$yearly_url = "graph.php?id=" . $proc['processor_id'] . "&amp;type=".$graph_type."&amp;from=".$config['time']['year']."&amp;to=".$config['time']['now']."&amp;width=400&amp;height=150";
echo(" <a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src=\"$daily_graph\" border=\"0\"></a> ");
echo(" <a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src=\"$weekly_graph\" border=\"0\"></a> ");
echo(" <a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src=\"$monthly_graph\" border=\"0\"></a> ");
echo(" <a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src=\"$yearly_graph\" border=\"0\"></a>");
echo(" </td>
</tr>");
} #end graphs if
}
}
echo("</table>");
echo("</div>");
?>
<script>
var grid = $("#processor").bootgrid({
ajax: true,
rowCount: [50,100,250,-1],
post: function ()
{
return {
id: "processor",
view: '<?php echo $vars['view']; ?>'
};
},
url: "/ajax_table.php",
formatters: {
"status": function(column,row) {
return "<h4><span class='label label-"+row.extra+" threeqtr-width'>" + row.msg + "</span></h4>";
},
"ack": function(column,row) {
return "<button type='button' class='btn btn-"+row.ack_col+" btn-sm command-ack-alert' data-target='#ack-alert' data-state='"+row.state+"' data-alert_id='"+row.alert_id+"' name='ack-alert' id='ack-alert' data-extra='"+row.extra+"'><span class='glyphicon glyphicon-"+row.ack_ico+"'aria-hidden='true'></span></button>";
}
},
templates: {
}
});
</script>
+1 -1
View File
@@ -26,7 +26,7 @@ echo('<tr class=tablehead>
foreach (dbFetchRows($sql, $param) as $sensor)
{
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value');
if($debug) { echo("Memcached[".'sensor-'.$sensor['sensor_id'].'-value'."=".$sensor['sensor_current']."]"); }
+7 -1
View File
@@ -56,11 +56,17 @@ if ($_SESSION['userlevel'] >= '5')
$host_sql = "SELECT * FROM devices AS D, services AS S, devices_perms AS P WHERE D.device_id = S.device_id AND D.device_id = P.device_id AND P.user_id = ? GROUP BY D.hostname ORDER BY D.hostname";
$host_par = array($_SESSION['user_id']);
}
$shift = 1;
foreach (dbFetchRows($host_sql, $host_par) as $device)
{
$device_id = $device['device_id'];
$device_hostname = $device['hostname'];
array_unshift($sql_param,$device_id);
if ($shift == 1) {
array_unshift($sql_param, $device_id);
$shift = 0;
} else {
$sql_param[0] = $device_id;
}
foreach (dbFetchRows("SELECT * FROM `services` WHERE `device_id` = ? $where", $sql_param) as $service)
{
include("includes/print-service.inc.php");
+55 -1
View File
@@ -1,4 +1,5 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
* 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
@@ -22,11 +23,53 @@
* @subpackage Page
*/
?>
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<span id="message"></span>
</div>
</div>
</div>
<?php
if (isset($vars['sub'])) {
if (file_exists("pages/settings/".mres($vars['sub']).".inc.php")) {
require_once "pages/settings/".mres($vars['sub']).".inc.php";
} else {
print_error("This settings page doesn't exist, please go to the main settings page");
}
} else {
?>
<div class="container-fluid">
<div class="row">
<?php
foreach (dbFetchRows("SELECT `config_group` FROM `config` GROUP BY `config_group`") as $sub_page) {
$sub_page = $sub_page['config_group'];
?>
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
<a class="btn btn-primary" href="<?php echo(generate_url(array('page'=>'settings','sub'=>$sub_page))); ?>"><?php echo ucfirst($sub_page); ?> Settings</a>
</div>
<?php
}
?>
</div>
</div>
<br />
<?php
/**
* Array-To-Table
* @param array $a N-Dimensional, Associative Array
* @return string
*/
function a2t($a) {
$r = "<table class='table table-condensed table-hover'><tbody>";
foreach( $a as $k=>$v ) {
@@ -37,10 +80,21 @@ function a2t($a) {
$r .= '</tbody></table>';
return $r;
}
if( $_SESSION['userlevel'] >= 10 ) {
echo "<div class='table-responsive'>".a2t($config)."</div>";
} else {
include("includes/error-no-perm.inc.php");
}
if ($_SESSION['userlevel'] >= '10') {
if ($debug) {
echo("<pre>");
print_r($config);
echo("</pre>");
}
} else {
include("includes/error-no-perm.inc.php");
}
}
?>
+894
View File
@@ -0,0 +1,894 @@
<?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.
*/
$no_refresh = TRUE;
?>
<!-- API URL Modal -->
<div class="modal fade" id="new-config-api" role="dialog" aria-hidden="true" title="Create new config item">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<form role="form" class="new_config_form">
<div class="form-group">
<span class="message"></span>
</div>
<div class="form-group">
<label for="new_conf_name">Method</label>
<select name="new_method" id="new_method" class="form-control">
<option value="get">GET</option>
<option value="post">POST</option>
<option value="put">PUT</option>
</select>
</div>
<div class="form-group">
<label for="new_conf_value">API URL</label>
<input type="text" class="form-control" name="new_conf_value" id="new_conf_value" placeholder="Enter the config value">
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-success" id="submit">Add config</button>
<a href="#" class="btn" data-dismiss="modal">Cancel</a>
</div>
</div>
</div>
</div>
<!-- End API URL Modal -->
<!-- Slack Modal -->
<div class="modal fade" id="new-config-slack" role="dialog" aria-hidden="true" title="Create new config item">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<form role="form" class="new_config_form">
<div class="form-group">
<span class="message"></span>
</div>
<div class="form-group">
<label for="slack_value">Slack API URL</label>
<input type="text" class="form-control" name="slack_value" id="slack_value" placeholder="Enter the Slack API url">
</div>
<div class="form-group">
<label for="slack_extra">Slack options (specify one per line key=value)</label>
<textarea class="form-control" name="slack_extra" id="slack_extra" placeholder="Enter the config options"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-success" id="submit-slack">Add config</button>
<a href="#" class="btn" data-dismiss="modal">Cancel</a>
</div>
</div>
</div>
</div>
<!-- End Slack Modal -->
<!-- Hipchat Modal -->
<div class="modal fade" id="new-config-hipchat" role="dialog" aria-hidden="true" title="Create new config item">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<form role="form" class="new_config_form">
<div class="form-group">
<span class="message"></span>
</div>
<div class="form-group">
<label for="hipchat_value">Hipchat API URL</label>
<input type="text" class="form-control" name="hipchat_value" id="hipchat_value" placeholder="Enter the Hipchat API url">
</div>
<div class="form-group">
<label for="new_room_id">Room ID</label>
<input type="text" class="form-control" name="new_room_id" id="new_room_id" placeholder="Enter the room ID">
</div>
<div class="form-group">
<label for="new_from">From</label>
<input type="text" class="form-control" name="new_from" id="new_from" placeholder="Enter the from details">
</div>
<div class="form-group">
<label for="hipchat_extra">Hipchat options (specify one per line key=value)</label>
<textarea class="form-control" name="hipchat_extra" id="hipchat_extra" placeholder="Enter the config options"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-success" id="submit-hipchat">Add config</button>
<a href="#" class="btn" data-dismiss="modal">Cancel</a>
</div>
</div>
</div>
</div>
<!-- End Hipchat Modal -->
<?php
if (isset($_GET['error'])) {
print_error('We had issues connecting to your Pager Duty account, please try again');
}
if (isset($_GET['account']) && isset($_GET['service_key']) && isset($_GET['service_name'])) {
set_config_name('alert.transports.pagerduty',$_GET['service_key']);
set_config_name('alert.pagerduty.account',$_GET['account']);
set_config_name('alert.pagerduty.service',$_GET['service_name']);
}
$config_groups = get_config_by_group('alerting');
if (isset($config['base_url'])) {
$callback = $config['base_url'].'/'.$_SERVER['REQUEST_URI'].'/';
} else {
$callback = get_url().'/';
}
$callback = urlencode($callback);
echo '
<div class="panel-group" id="accordion">
<form class="form-horizontal" role="form" action="" method="post">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#general_settings_expand">General alert settings</a>
</h4>
</div>
<div id="general_settings_expand" class="panel-collapse collapse">
<div class="panel-body">
<div class="form-group">
<label for="admins" class="col-sm-4 control-label">Issue alerts to admins </label>
<div data-toggle="tooltip" title="'.$config_groups['alert.admins']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="admins" type="checkbox" name="global-config-check" '.$config_groups['alert.admins']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['alert.admins']['config_id'].'">
</div>
</div>
<div class="form-group">
<label for="globals" class="col-sm-4 control-label">Issue alerts to read only users </label>
<div data-toggle="tooltip" title="'.$config_groups['alert.globals']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="globals" type="checkbox" name="global-config-check" '.$config_groups['alert.globals']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['alert.globals']['config_id'].'">
</div>
</div>
<div class="form-group">
<label for="syscontact" class="col-sm-4 control-label">Issue alerts to sysContact </label>
<div data-toggle="tooltip" title="'.$config_groups['alert.syscontact']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="admins" type="checkbox" name="global-config-check" '.$config_groups['alert.syscontact']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['alert.syscontact']['config_id'].'">
</div>
</div>
<div class="form-group">
<label for="default_only" class="col-sm-4 control-label">Send alerts to default contact only </label>
<div data-toggle="tooltip" title="'.$config_groups['alert.default_only']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="default_only" type="checkbox" name="global-config-check" '.$config_groups['alert.default_only']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['alert.default_only']['config_id'].'">
</div>
</div>
<div class="form-group has-feedback">
<label for="default_mail" class="col-sm-4 control-label">Default contact </label>
<div data-toggle="tooltip" title="'.$config_groups['alert.default_mail']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="default_mail" class="form-control" type="text" name="global-config-input" value="'.$config_groups['alert.default_mail']['config_value'].'" data-config_id="'.$config_groups['alert.default_mail']['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group has-feedback">
<label for="tolerance_window" class="col-sm-4 control-label">Tolerance window for cron </label>
<div data-toggle="tooltip" title="'.$config_groups['alert.tolerance_window']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="tolerance_window" class="form-control" type="text" name="global-config-input" value="'.$config_groups['alert.tolerance_window']['config_value'].'" data-config_id="'.$config_groups['alert.tolerance_window']['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group">
<label for="fixed_contacts" class="col-sm-4 control-label">Updates to contact email addresses not honored </label>
<div data-toggle="tooltip" title="'.$config_groups['alert.fixed-contacts']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="fixed_contacts" type="checkbox" name="global-config-check" '.$config_groups['alert.fixed-contacts']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['alert.fixed-contacts']['config_id'].'">
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#email_transport_expand">Email transport</a>
</h4>
</div>
<div id="email_transport_expand" class="panel-collapse collapse">
<div class="panel-body">
<div class="form-group">
<label for="default_only" class="col-sm-4 control-label">Enable email alerting </label>
<div data-toggle="tooltip" title="'.$config_groups['alert.transports.mail']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="mail_transport" type="checkbox" name="global-config-check" '.$config_groups['alert.transports.mail']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['alert.transports.mail']['config_id'].'">
</div>
</div>
<div class="form-group has-feedback">
<label for="email_backend" class="col-sm-4 control-label">How to deliver mail </label>
<div data-toggle="tooltip" title="'.$config_groups['email_backend']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<select id="email_backend" class="form-control" name="global-config-select" data-config_id="'.$config_groups['email_backend']['config_id'].'">';
foreach ($dyn_config['email_backend'] as $backend) {
echo '<option value="'.$backend.'"';
if ($config_groups['email_backend']['config_value'] == $backend) {
echo ' selected';
}
echo '>'.$backend.'</option>';
}
echo '</select>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group has-feedback">
<label for="email_from" class="col-sm-4 control-label">From address </label>
<div data-toggle="tooltip" title="'.$config_groups['email_from']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="email_from" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_from']['config_value'].'" data-config_id="'.$config_groups['email_from']['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group has-feedback">
<label for="email_user" class="col-sm-4 control-label">From name </label>
<div data-toggle="tooltip" title="'.$config_groups['email_user']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="email_user" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_user']['config_value'].'" data-config_id="'.$config_groups['email_user']['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group has-feedback">
<label for="email_sendmail_path" class="col-sm-4 control-label">Sendmail path </label>
<div data-toggle="tooltip" title="'.$config_groups['email_sendmail_path']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="email_sendmail_path" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_sendmail_path']['config_value'].'" data-config_id="'.$config_groups['email_sendmail_path']['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group has-feedback">
<label for="email_smtp_host" class="col-sm-4 control-label">SMTP Host </label>
<div data-toggle="tooltip" title="'.$config_groups['email_smtp_host']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="email_smtp_host" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_smtp_host']['config_value'].'" data-config_id="'.$config_groups['email_smtp_host']['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group has-feedback">
<label for="email_smtp_port" class="col-sm-4 control-label">SMTP Port </label>
<div data-toggle="tooltip" title="'.$config_groups['email_smtp_port']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="email_smtp_port" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_smtp_port']['config_value'].'" data-config_id="'.$config_groups['email_smtp_port']['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group has-feedback">
<label for="email_smtp_timeout" class="col-sm-4 control-label">SMTP Timeout </label>
<div data-toggle="tooltip" title="'.$config_groups['email_smtp_timeout']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="email_smtp_timeout" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_smtp_timeout']['config_value'].'" data-config_id="'.$config_groups['email_smtp_timeout']['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group has-feedback">
<label for="email_smtp_secure" class="col-sm-4 control-label">SMTP Secure </label>
<div data-toggle="tooltip" title="'.$config_groups['email_smtp_secure']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<select id="email_smtp_secure" class="form-control"name="global-config-select" data-config_id="'.$config_groups['email_smtp_secure']['config_id'].'">';
foreach ($dyn_config['email_smtp_secure'] as $secure) {
echo "<option value='$secure'";
if ($config_groups['email_smtp_secure']['config_value'] == $secure) {
echo " selected";
}
echo ">$secure</option>";
}
echo '</select>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group">
<label for="email_smtp_auth" class="col-sm-4 control-label">SMTP Authentication </label>
<div data-toggle="tooltip" title="'.$config_groups['email_smtp_auth']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="email_smtp_auth" type="checkbox" name="global-config-check" '.$config_groups['email_smtp_auth']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['email_smtp_auth']['config_id'].'">
</div>
</div>
<div class="form-group has-feedback">
<label for="email_smtp_username" class="col-sm-4 control-label">SMTP Authentication username </label>
<div data-toggle="tooltip" title="'.$config_groups['email_smtp_username']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="email_smtp_username" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_smtp_username']['config_value'].'" data-config_id="'.$config_groups['email_smtp_username']['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group has-feedback">
<label for="email_smtp_password" class="col-sm-4 control-label">SMTP AUthentication passoword </label>
<div data-toggle="tooltip" title="'.$config_groups['email_smtp_password']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="email_smtp_password" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_smtp_password']['config_value'].'" data-config_id="'.$config_groups['email_smtp_password']['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#api_transport_expand">API transport</a>
</h4>
</div>
<div id="api_transport_expand" class="panel-collapse collapse">
<div class="panel-body">
<div class="form-group">
<div class="col-sm-8">
<button class="btn btn-success btn-xs" type="button" name="new_config" id="new_config_item" data-toggle="modal" data-target="#new-config-api">Add API URL</button>
</div>
</div>';
$api_urls = get_config_like_name('alert.transports.api.%.');
foreach ($api_urls as $api_url) {
$api_split = split("\.", $api_url['config_name']);
$api_method = $api_split[3];
echo '<div class="form-group has-feedback" id="'.$api_url['config_id'].'">
<label for="api_url" class="col-sm-4 control-label">API URL ('.$api_method.') </label>
<div class="col-sm-4">
<input id="api_url" class="form-control" type="text" name="global-config-input" value="'.$api_url['config_value'].'" data-config_id="'.$api_url['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-api-config" name="del-api-call" data-config_id="'.$api_url['config_id'].'"><i class="fa fa-minus"></i></button>
</div>
</div>';
}
echo '<div class="form-group has-feedback hide" id="api_url_template">
<label for="api_url" class="col-sm-4 control-label api-method">API URL </label>
<div class="col-sm-4">
<input id="api_url" class="form-control" type="text" name="global-config-input" value="" data-config_id="">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-api-config" name="del-api-call" data-config_id=""><i class="fa fa-minus"></i></button>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#pagerduty_transport_expand">Pagerduty transport</a>
</h4>
</div>
<div id="pagerduty_transport_expand" class="panel-collapse collapse">
<div class="panel-body">
<div class="form-group">
<div class="col-sm-2">
<a href="https://connect.pagerduty.com/connect?vendor=2fc7c9f3c8030e74aae6&callback='.$callback.'"><img src="images/pd_connect_button.png" width="202" height="36" alt="Connect to PagerDuty"></a>
</div>
<div class="col-sm-1">';
if (empty($config_groups['alert.transports.pagerduty']['config_value']) === FALSE) {
echo "<i class='fa fa-check-square-o fa-col-success fa-3x'></i>";
} else {
echo "<i class='fa fa-check-square-o fa-col-danger fa-3x'></i>";
}
echo '</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#nagios_transport_expand">Nagios compatible transport</a>
</h4>
</div>
<div id="nagios_transport_expand" class="panel-collapse collapse">
<div class="panel-body">
<div class="form-group has-feedback">
<label for="nagios" class="col-sm-4 control-label">Nagios compatible FIFO </label>
<div data-toggle="tooltip" title="'.$config_groups['alert.transports.nagios']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="nagios" class="form-control" type="text" name="global-config-input" value="'.$config_groups['alert.transports.nagios']['config_value'].'" data-config_id="'.$config_groups['alert.transports.nagios']['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#irc_transport_expand">IRC transport</a>
</h4>
</div>
<div id="irc_transport_expand" class="panel-collapse collapse">
<div class="panel-body">
<div class="form-group">
<label for="irc" class="col-sm-4 control-label">Enable irc transport </label>
<div data-toggle="tooltip" title="'.$config_groups['alert.transports.irc']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div class="col-sm-4">
<input id="irc" type="checkbox" name="global-config-check" '.$config_groups['alert.transports.irc']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['alert.transports.irc']['config_id'].'">
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#slack_transport_expand">Slack transport</a>
</h4>
</div>
<div id="slack_transport_expand" class="panel-collapse collapse">
<div class="panel-body">
<div class="form-group">
<div class="col-sm-8">
<button class="btn btn-success btn-xs" type="button" name="new_config" id="new_config_item" data-toggle="modal" data-target="#new-config-slack">Add Slack URL</button>
</div>
</div>';
$slack_urls = get_config_like_name('alert.transports.slack.%.url');
foreach ($slack_urls as $slack_url) {
unset($upd_slack_extra);
$new_slack_extra = array();
$slack_extras = get_config_like_name('alert.transports.slack.'.$slack_url['config_id'].'.%');
foreach ($slack_extras as $extra) {
$split_extra = explode('.',$extra['config_name']);
if ($split_extra[4] != 'url') {
$new_slack_extra[] = $split_extra[4] . '=' . $extra['config_value'];
}
}
$upd_slack_extra = implode(PHP_EOL,$new_slack_extra);
echo '<div id="'.$slack_url['config_id'].'">
<div class="form-group has-feedback">
<label for="slack_url" class="col-sm-4 control-label">Slack URL </label>
<div class="col-sm-4">
<input id="slack_url" class="form-control" type="text" name="global-config-input" value="'.$slack_url['config_value'].'" data-config_id="'.$slack_url['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-slack-config" name="del-slack-call" data-config_id="'.$slack_url['config_id'].'"><i class="fa fa-minus"></i></button>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-sm-offset-4 col-sm-4">
<textarea class="form-control" name="global-config-textarea" id="upd_slack_extra" placeholder="Enter the config options" data-config_id="'.$slack_url['config_id'].'" data-type="slack">'.$upd_slack_extra.'</textarea>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
</div>';
}
echo '<div class="hide" id="slack_url_template">
<div class="form-group has-feedback">
<label for="slack_url" class="col-sm-4 control-label api-method">Slack URL </label>
<div class="col-sm-4">
<input id="slack_url" class="form-control" type="text" name="global-config-input" value="" data-config_id="">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-slack-config" name="del-slack-call" data-config_id=""><i class="fa fa-minus"></i></button>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-sm-offset-4 col-sm-4">
<textarea class="form-control" name="global-config-textarea" id="upd_slack_extra" placeholder="Enter the config options" data-config_id="" data-type="slack"></textarea>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#hipchat_transport_expand">Hipchat transport</a>
</h4>
</div>
<div id="hipchat_transport_expand" class="panel-collapse collapse">
<div class="panel-body">
<div class="form-group">
<div class="col-sm-8">
<button class="btn btn-success btn-xs" type="button" name="new_config" id="new_config_item" data-toggle="modal" data-target="#new-config-hipchat">Add Hipchat URL</button>
</div>
</div>';
$hipchat_urls = get_config_like_name('alert.transports.hipchat.%.url');
foreach ($hipchat_urls as $hipchat_url) {
unset($upd_hipchat_extra);
$new_hipchat_extra = array();
$hipchat_extras = get_config_like_name('alert.transports.hipchat.'.$hipchat_url['config_id'].'.%');
$hipchat_room_id = get_config_by_name('alert.transports.hipchat.'.$hipchat_url['config_id'].'.room_id');
$hipchat_from = get_config_by_name('alert.transports.hipchat.'.$hipchat_url['config_id'].'.from');
foreach ($hipchat_extras as $extra) {
$split_extra = explode('.',$extra['config_name']);
if ($split_extra[4] != 'url' && $split_extra[4] != 'room_id' && $split_extra[4] != 'from') {
$new_hipchat_extra[] = $split_extra[4] . '=' . $extra['config_value'];
}
}
$upd_hipchat_extra = implode(PHP_EOL,$new_hipchat_extra);
echo '<div id="'.$hipchat_url['config_id'].'">
<div class="form-group has-feedback">
<label for="hipchat_url" class="col-sm-4 control-label">Hipchat URL </label>
<div class="col-sm-4">
<input id="hipchat_url" class="form-control" type="text" name="global-config-input" value="'.$hipchat_url['config_value'].'" data-config_id="'.$hipchat_url['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-hipchat-config" name="del-hipchat-call" data-config_id="'.$hipchat_url['config_id'].'"><i class="fa fa-minus"></i></button>
</div>
</div>
<div class="form-group has-feedback">
<label for="hipchat_room_id" class="col-sm-4 control-label">Room ID</label>
<div class="col-sm-4">
<input id="hipchat_room_id" class="form-control" type="text" name="global-config-input" value="'.$hipchat_room_id['config_value'].'" data-config_id="'.$hipchat_room_id['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group has-feedback">
<label for="hipchat_from" class="col-sm-4 control-label">From</label>
<div class="col-sm-4">
<input id="hipchat_from" class="form-control" type="text" name="global-config-input" value="'.$hipchat_from['config_value'].'" data-config_id="'.$hipchat_from['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-sm-offset-4 col-sm-4">
<textarea class="form-control" name="global-config-textarea" id="upd_hipchat_extra" placeholder="Enter the config options" data-config_id="'.$hipchat_url['config_id'].'" data-type="hipchat">'.$upd_hipchat_extra.'</textarea>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
</div>';
}
echo '<div id="hipchat_url_template" class="hide">
<div class="form-group has-feedback">
<label for="hipchat_url" class="col-sm-4 control-label api-method">Hipchat URL </label>
<div class="col-sm-4">
<input id="hipchat_url" class="form-control" type="text" name="global-config-input" value="" data-config_id="">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-hipchat-config" id="del-hipchat-call" name="del-hipchat-call" data-config_id=""><i class="fa fa-minus"></i></button>
</div>
</div>
<div class="form-group has-feedback">
<label for="hipchat_room_id" class="col-sm-4 control-label">Room ID</label>
<div class="col-sm-4">
<input id="global-config-room_id" class="form-control" type="text" name="global-config-input" value="" data-config_id="">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group has-feedback">
<label for="hipchat_from" class="col-sm-4 control-label">From</label>
<div class="col-sm-4">
<input id="global-config-from" class="form-control" type="text" name="global-config-input" value="" data-config_id="">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-sm-offset-4 col-sm-4">
<textarea class="form-control" name="global-config-textarea" id="upd_hipchat_extra" placeholder="Enter the config options" data-config_id="" data-type="hipchat"></textarea>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
';
?>
<script>
<?php
if(isset($_GET['service_key'])) {
echo "$('#pagerduty_transport_expand').collapse('show');";
}
?>
$(".toolTip").tooltip();
apiIndex = 0;
// Add API config
$("button#submit").click(function(){
var config_name = 'alert.transports.api.'+$('#new_method').val()+'.';
var new_api_method = $('#new_method').val();
var config_value = $('#new_conf_value').val();
$.ajax({
type: "POST",
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){
if (data.status == 'ok') {
apiIndex++;
var $template = $('#api_url_template'),
$clone = $template
.clone()
.removeClass('hide')
.attr('id',data.config_id)
.attr('api-url-index', apiIndex)
.insertBefore($template);
$clone.find('[name="global-config-input"]').attr('data-config_id',data.config_id);
$clone.find('[name="del-api-call"]').attr('data-config_id',data.config_id);
$clone.find('[name="global-config-input"]').attr('value', config_value);
$clone.find('.api-method').text("API URL (" + new_api_method + ")");
console.log(new_api_method);
$("#new-config-api").modal('hide');
} else {
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
}
},
error: function(){
$("#message").html('<div class="alert alert-info">Error creating config item</div>');
}
});
});// End Add API config
// Add Slack config
slackIndex = 0;
$("button#submit-slack").click(function(){
var config_value = $('#slack_value').val();
var config_extra = $('#slack_extra').val();
$.ajax({
type: "POST",
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){
if (data.status == 'ok') {
slackIndex++;
var $template = $('#slack_url_template'),
$clone = $template
.clone()
.removeClass('hide')
.attr('id',data.config_id)
.attr('slack-url-index', slackIndex)
.insertBefore($template);
$clone.find('[name="global-config-input"]').attr('data-config_id',data.config_id);
$clone.find('[name="del-slack-call"]').attr('data-config_id',data.config_id);
$clone.find('[name="global-config-input"]').attr('value', config_value);
$clone.find('[name="global-config-textarea"]').val(config_extra);
$clone.find('[name="global-config-textarea"]').attr('data-config_id',data.config_id);
$("#new-config-slack").modal('hide');
} else {
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
}
},
error: function(){
$("#message").html('<div class="alert alert-info">Error creating config item</div>');
}
});
});// End Add Slack config
// Add Hipchat config
hipchatIndex = 0;
$("button#submit-hipchat").click(function(){
var config_value = $('#hipchat_value').val();
var config_extra = $('#hipchat_extra').val();
var config_room_id = $('#new_room_id').val();
var config_from = $('#new_from').val();
$.ajax({
type: "POST",
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){
if (data.status == 'ok') {
hipchatIndex++;
var $template = $('#hipchat_url_template'),
$clone = $template
.clone()
.removeClass('hide')
.attr('id',data.config_id)
.attr('hipchat-url-index', hipchatIndex)
.insertBefore($template);
$clone.find('[id="hipchat_url"]').attr('data-config_id',data.config_id);
$clone.find('[id="del-hipchat-call"]').attr('data-config_id',data.config_id);
$clone.find('[name="global-config-input"]').attr('value', config_value);
$clone.find('[id="global-config-room_id"]').attr('value', config_room_id);
$clone.find('[id="global-config-from"]').attr('value', config_from);
$clone.find('[id="upd_hipchat_extra"]').val(config_extra);
$clone.find('[id="upd_hipchat_extra"]').attr('data-config_id',data.config_id);
$("#new-config-hipchat").modal('hide');
} else {
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
}
},
error: function(){
$("#message").html('<div class="alert alert-info">Error creating config item</div>');
}
});
});// End Add Hipchat config
// Delete api config
$(document).on('click', 'button[name="del-api-call"]', function(event) {
var config_id = $(this).data('config_id');
$.ajax({
type: 'POST',
url: '/ajax_form.php',
data: {type: "config-item", action: 'remove', config_id: config_id},
dataType: "json",
success: function (data) {
if (data.status == 'ok') {
$("#"+config_id).remove();
} else {
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
}
},
error: function () {
$("#message").html('<div class="alert alert-info">An error occurred.</div>');
}
});
});// End delete api config
// Delete slack config
$(document).on('click', 'button[name="del-slack-call"]', function(event) {
var config_id = $(this).data('config_id');
$.ajax({
type: 'POST',
url: '/ajax_form.php',
data: {type: "config-item", action: 'remove-slack', config_id: config_id},
dataType: "json",
success: function (data) {
if (data.status == 'ok') {
$("#"+config_id).remove();
} else {
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
}
},
error: function () {
$("#message").html('<div class="alert alert-info">An error occurred.</div>');
}
});
});// End delete slack config
// Delete hipchat config
$(document).on('click', 'button[name="del-hipchat-call"]', function(event) {
var config_id = $(this).data('config_id');
$.ajax({
type: 'POST',
url: '/ajax_form.php',
data: {type: "config-item", action: 'remove-hipchat', config_id: config_id},
dataType: "json",
success: function (data) {
if (data.status == 'ok') {
$("#"+config_id).remove();
} else {
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
}
},
error: function () {
$("#message").html('<div class="alert alert-info">An error occurred.</div>');
}
});
});// End delete hipchat config
$("[name='global-config-check']").bootstrapSwitch('offColor','danger');
$('input[name="global-config-check"]').on('switchChange.bootstrapSwitch', function(event, state) {
event.preventDefault();
var config_id = $(this).data("config_id");
$.ajax({
type: 'POST',
url: '/ajax_form.php',
data: {type: "update-config-item", config_id: config_id, config_value: state},
dataType: "json",
success: function (data) {
if (data.status == 'ok') {
} else {
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
}
},
error: function () {
$("#message").html('<div class="alert alert-info">An error occurred.</div>');
}
});
});
$(document).on('blur', 'input[name="global-config-input"]', function(event) {
event.preventDefault();
var $this = $(this);
var config_id = $this.data("config_id");
var config_value = $this.val();
$.ajax({
type: 'POST',
url: '/ajax_form.php',
data: {type: "update-config-item", config_id: config_id, config_value: config_value},
dataType: "json",
success: function (data) {
if (data.status == 'ok') {
$this.closest('.form-group').addClass('has-success');
$this.next().addClass('glyphicon-ok');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-success');
$this.next().removeClass('glyphicon-ok');
}, 2000);
} else {
$(this).closest('.form-group').addClass('has-error');
$this.next().addClass('glyphicon-remove');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-error');
$this.next().removeClass('glyphicon-remove');
}, 2000);
}
},
error: function () {
$("#message").html('<div class="alert alert-info">An error occurred.</div>');
}
});
});
$( 'select[name="global-config-select"]').change(function(event) {
event.preventDefault();
var $this = $(this);
var config_id = $this.data("config_id");
var config_value = $this.val();
$.ajax({
type: 'POST',
url: '/ajax_form.php',
data: {type: "update-config-item", config_id: config_id, config_value: config_value},
dataType: "json",
success: function (data) {
if (data.status == 'ok') {
$this.closest('.form-group').addClass('has-success');
$this.next().addClass('glyphicon-ok');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-success');
$this.next().removeClass('glyphicon-ok');
}, 2000);
} else {
$(this).closest('.form-group').addClass('has-error');
$this.next().addClass('glyphicon-remove');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-error');
$this.next().removeClass('glyphicon-remove');
}, 2000);
}
},
error: function () {
$("#message").html('<div class="alert alert-info">An error occurred.</div>');
}
});
});
$(document).on('blur', 'textarea[name="global-config-textarea"]', function(event) {
event.preventDefault();
var $this = $(this);
var config_id = $this.data("config_id");
var config_value = $this.val();
var config_type = $this.data("type");
$.ajax({
type: 'POST',
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) {
if (data.status == 'ok') {
$this.closest('.form-group').addClass('has-success');
$this.next().addClass('glyphicon-ok');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-success');
$this.next().removeClass('glyphicon-ok');
}, 2000);
} else {
$(this).closest('.form-group').addClass('has-error');
$this.next().addClass('glyphicon-remove');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-error');
$this.next().removeClass('glyphicon-remove');
}, 2000);
}
},
error: function () {
$("#message").html('<div class="alert alert-info">An error occurred.</div>');
}
});
});
</script>
+2 -2
View File
@@ -62,10 +62,10 @@ var grid = $("#syslog").bootgrid({
"</select>"+
"</div>"+
"<div class=\"form-group\">"+
"<input name=\"from\" type=\"text\" class=\"form-control\" id=\"dtpickerfrom\" maxlength=\"16\" value=\"<?php echo $vars['from']; ?>\" placeholder=\"From\" data-date-format=\"YYYY-MM-DD HH:mm\">"+
"<input name=\"from\" type=\"text\" class=\"form-control input-sm\" id=\"dtpickerfrom\" maxlength=\"16\" value=\"<?php echo $vars['from']; ?>\" placeholder=\"From\" data-date-format=\"YYYY-MM-DD HH:mm\">"+
"</div>"+
"<div class=\"form-group\">"+
"<input name=\"to\" type=\"text\" class=\"form-control\" id=\"dtpickerto\" maxlength=\"16\" value=\"<?php echo $vars['to']; ?>\" placeholder=\"To\" data-date-format=\"YYYY-MM-DD HH:mm\">"+
"<input name=\"to\" type=\"text\" class=\"form-control input-sm\" id=\"dtpickerto\" maxlength=\"16\" value=\"<?php echo $vars['to']; ?>\" placeholder=\"To\" data-date-format=\"YYYY-MM-DD HH:mm\">"+
"</div>"+
"<button type=\"submit\" class=\"btn btn-default input-sm\">Filter</button>"+
"</form></span></div>"+
+51 -25
View File
@@ -36,31 +36,57 @@
*/
foreach( $opts as $api ) {
$data = array();
$data['token'] = $api['appkey'];
$data['user'] = $api['userkey'];
if( $obj['severity'] == "critical" ) {
if( !empty($api['sound_critical']) ) {
$data['sound'] = $api['sound_critical'];
}
$severity = "Critical";
$data['priority'] = 1;
}
elseif( $obj['severity'] == "warning" ) {
$severity = "Warning";
$data['priority'] = 0;
$data = array();
$data['token'] = $api['appkey'];
$data['user'] = $api['userkey'];
switch( $obj['severity'] ) {
case "critical":
$severity = "Critical";
$data['priority'] = 1;
if( !empty( $api['sound_critical'] ) ) {
$data['sound'] = $api['sound_critical'];
}
break;
case "warning":
$severity = "Warning";
$data['priority'] = 0;
if( !empty( $api['sound_warning'] ) ) {
$data['sound'] = $api['sound_warning'];
}
break;
}
switch( $obj['state'] ) {
case 0:
$title_text = "OK";
if( !empty( $api['sound_ok'] ) ) {
$data['sound'] = $api['sound_ok'];
}
break;
case 1:
$title_text = $severity;
break;
case 2:
$title_text = "Acknowledged";
break;
}
$data['title'] = $title_text." - ".$obj['hostname']." - ".$obj['name'];
$message_text = "Timestamp: ".$obj['timestamp'];
if( !empty( $obj['faults'] ) ) {
$message_text .= "\n\nFaults:\n";
foreach($obj['faults'] as $k => $faults) {
$message_text .= "#".$k." ".$faults['string']."\n";
}
}
$data['message'] = $message_text;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.pushover.net/1/messages.json');
curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$ret = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if( $code != 200 ) {
var_dump("Pushover returned error"); //FIXME: proper debugging
return false;
}
$curl = curl_init();
$data['title'] = $severity." - ".$obj['hostname'];
$data['message'] = $obj['name'];
curl_setopt($curl, CURLOPT_URL, 'https://api.pushover.net/1/messages.json');
curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$ret = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if( $code != 200 ) {
var_dump("Pushover returned error"); //FIXME: proper debugging
return false;
}
}
return true;
+3 -59
View File
@@ -191,65 +191,6 @@ $config['autodiscovery']['nets-exclude'][] = "169.254.0.0/16";
$config['autodiscovery']['nets-exclude'][] = "224.0.0.0/4";
$config['autodiscovery']['nets-exclude'][] = "240.0.0.0/4";
// Mailer backend Settings
$config['email_backend'] = 'mail'; // Mail backend. Allowed: "mail" (PHP's built-in), "sendmail", "smtp".
$config['email_from'] = NULL; // Mail from. Default: "ProjectName" <projectid@`hostname`>
$config['email_user'] = $config['project_id'];
$config['email_sendmail_path'] = '/usr/sbin/sendmail'; // The location of the sendmail program.
$config['email_smtp_host'] = 'localhost'; // Outgoing SMTP server name.
$config['email_smtp_port'] = 25; // The port to connect.
$config['email_smtp_timeout'] = 10; // SMTP connection timeout in seconds.
$config['email_smtp_secure'] = NULL; // Enable encryption. Use 'tls' or 'ssl'
$config['email_smtp_auth'] = FALSE; // Whether or not to use SMTP authentication.
$config['email_smtp_username'] = NULL; // SMTP username.
$config['email_smtp_password'] = NULL; // Password for SMTP authentication.
// Alerting Settings
$config['alert'] = array(
'macros' => array( //Macros:
'rule' => array( // For Rules
//Time Macros
'now' => 'NOW()',
'past_5m' => 'DATE_SUB(NOW(),INTERVAL 5 MINUTE)',
'past_10m' => 'DATE_SUB(NOW(),INTERVAL 10 MINUTE)',
'past_15m' => 'DATE_SUB(NOW(),INTERVAL 15 MINUTE)',
'past_30m' => 'DATE_SUB(NOW(),INTERVAL 30 MINUTE)',
'past_60m' => 'DATE_SUB(NOW(),INTERVAL 60 MINUTE)',
//Device Macros
'device' => '%devices.disabled = "0" && %devices.ignore = "0"',
'device_up' => '%devices.status = "1" && %macros.device',
'device_down' => '%devices.status = "0" && %macros.device',
//Port Macros
'port' => '%ports.deleted = "0" && %ports.ignore = "0" && %ports.disabled = "0"',
'port_up' => '%ports.ifOperStatus = "up" && %ports.ifAdminStatus = "up" && %macros.port',
'port_down' => '%ports.ifOperStatus = "down" && %ports.ifAdminStatus != "down" && %macros.port',
'port_usage_perc' => '((%ports.ifInOctets_rate*8)/%ports.ifSpeed)*100',
//Misc Macros
),
),
'transports' => array( //Transports:
'dummy' => false, // Dummy alerting (debug)
'mail' => false, // E-Mail alerting
'irc' => false, // IRC Alerting
),
'syscontact' => true, //Issue to SysContact (or it's override)
'globals' => false, //Issue to global-read users
'admins' => false, //Issue to administrators
'default_only' => false, //Only issue to default
'default_mail' => '', //Default email
'tolerance-window' => 10, //Allow +/-10s tolerance to delay values to counter cron-irregularities
'fixed-contacts' => true, //If true any changes in user-permissions,user-mail,syscontact,default-mail will not be honoured until the next alert triggers.
);
//Legacy options
$config['alerts']['email']['default'] = NULL; // Default alert recipient
$config['alerts']['email']['default_only'] = FALSE; // Only use default recipient
$config['alerts']['email']['enable'] = FALSE; // Enable email alerts
$config['alerts']['bgp']['whitelist'] = NULL; // Populate as an array() with ASNs to alert on.
$config['alerts']['port']['ifdown'] = FALSE; // Generate alerts for ports that go down
@@ -670,4 +611,7 @@ $config['ipmi']['type'][] = "lan";
$config['ipmi']['type'][] = "imb";
$config['ipmi']['type'][] = "open";
// Options needed for dyn config - do NOT edit
$dyn_config['email_backend'] = array('mail','sendmail','smtp');
$dyn_config['email_smtp_secure'] = array('', 'tls', 'ssl');
?>
+81 -18
View File
@@ -1,5 +1,71 @@
<?php
// Observium Includes
include_once($config['install_dir'] . "/includes/dbFacile.php");
// Connect to database
$database_link = mysql_pconnect($config['db_host'], $config['db_user'], $config['db_pass']);
if (!$database_link)
{
echo("<h2>MySQL Error</h2>");
echo(mysql_error());
die;
}
$database_db = mysql_select_db($config['db_name'], $database_link);
function mergecnf($obj) {
/* Copyright (C) 2014 Daniel Preussker <f0o@devilcode.org>
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* Merge config function
* @author f0o <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Config
*/
$pointer = array();
$val = $obj['config_value'];
$obj = $obj['config_name'];
$obj = explode('.',$obj,2);
if( !isset($obj[1]) ) {
if( filter_var($val,FILTER_VALIDATE_INT) ) {
$val = (int) $val;
} elseif( filter_var($val,FILTER_VALIDATE_FLOAT) ) {
$val = (float) $val;
} elseif( filter_var($val,FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE) !== NULL ) {
$val = filter_var($val,FILTER_VALIDATE_BOOLEAN);
}
if( !empty($obj[0]) ) {
return array($obj[0] => $val);
} else {
return array($val);
}
} else {
$pointer[$obj[0]] = mergecnf(array('config_name'=>$obj[1],'config_value'=>$val));
}
return $pointer;
}
$clone = $config;
foreach( dbFetchRows('select config_name,config_value from config') as $obj ) {
$clone = array_replace_recursive($clone,mergecnf($obj));
}
$config = array_replace_recursive($clone,$config);
/////////////////////////////////////////////////////////
# NO CHANGES TO THIS FILE, IT IS NOT USER-EDITABLE #
/////////////////////////////////////////////////////////
@@ -670,13 +736,6 @@ $config['os'][$os]['text'] = "D-Link Access Point";
$config['os'][$os]['type'] = "wireless";
$config['os'][$os]['icon'] = "dlink";
//$os = "ubiquitiap";
//$config['os'][$os]['text'] = "Ubiquiti Networks Wireless";
//$config['os'][$os]['type'] = "wireless";
//$config['os'][$os]['icon'] = "ubiquiti";
//$config['os'][$os]['over'][0]['graph'] = "device_bits";
//$config['os'][$os]['over'][0]['text'] = "Device Traffic";
$os = "axiscam";
$config['os'][$os]['text'] = "AXIS Network Camera";
$config['os'][$os]['icon'] = "axis";
@@ -1123,6 +1182,20 @@ $config['os'][$os]['over'][0]['graph'] = "device_bits";
$config['os'][$os]['over'][0]['text'] = "Device Traffic";
$config['os'][$os]['icon'] = "pbn";
// Enterasys
$os = "enterasys";
$config['os'][$os]['text'] = "Enterasys";
$config['os'][$os]['type'] = "network";
$config['os'][$os]['over'][0]['graph'] = "device_bits";
$config['os'][$os]['over'][0]['text'] = "Device Traffic";
$config['os'][$os]['icon'] = "enterasys";
// Multimatic UPS (Generex CS121 SNMP Adapter)
$os = "multimatic";
$config['os'][$os]['text'] = "Multimatic UPS";
$config['os'][$os]['type'] = "power";
$config['os'][$os]['icon'] = "multimatic";
foreach ($config['os'] as $this_os => $blah)
{
if (isset($config['os'][$this_os]['group']))
@@ -1749,17 +1822,7 @@ if (isset($_SERVER['HTTPS']))
$config['base_url'] = preg_replace('/^http:/','https:', $config['base_url']);
}
// Connect to database
$database_link = mysql_pconnect($config['db_host'], $config['db_user'], $config['db_pass']);
if (!$database_link)
{
echo("<h2>MySQL Error</h2>");
echo(mysql_error());
die;
}
$database_db = mysql_select_db($config['db_name'], $database_link);
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
if (class_exists("Memcached"))
{
+9
View File
@@ -0,0 +1,9 @@
<?php
if (!$os) {
if (preg_match("/^Enterasys Networks/", $sysDescr)) {
$os = "enterasys";
}
}
?>
+9
View File
@@ -0,0 +1,9 @@
<?php
if (!$os) {
if (preg_match("/^CS121/", $sysDescr)) {
if (strstr(snmp_get($device, "UPS-MIB::upsIdentManufacturer.0", "-Oqv", ""), "Multimatic")){
$os = "multimatic";
}
}
}
@@ -9,6 +9,8 @@ if (is_array($hrstorage_array))
{
$fstype = $storage['hrStorageType'];
$descr = $storage['hrStorageDescr'];
$storage['hrStorageSize'] = fix_integer_value($storage['hrStorageSize']);
$storage['hrStorageUsed'] = fix_integer_value($storage['hrStorageUsed']);
$size = $storage['hrStorageSize'] * $storage['hrStorageAllocationUnits'];
$used = $storage['hrStorageUsed'] * $storage['hrStorageAllocationUnits'];
$units = $storage['hrStorageAllocationUnits'];
+9 -1
View File
@@ -18,6 +18,7 @@ include_once("Net/IPv4.php");
include_once("Net/IPv6.php");
// Observium Includes
include_once($config['install_dir'] . "/includes/dbFacile.php");
include_once($config['install_dir'] . "/includes/common.php");
include_once($config['install_dir'] . "/includes/rrdtool.inc.php");
@@ -27,7 +28,6 @@ include_once($config['install_dir'] . "/includes/syslog.php");
include_once($config['install_dir'] . "/includes/rewrites.php");
include_once($config['install_dir'] . "/includes/snmp.inc.php");
include_once($config['install_dir'] . "/includes/services.inc.php");
include_once($config['install_dir'] . "/includes/dbFacile.php");
include_once($config['install_dir'] . "/includes/console_colour.php");
$console_color = new Console_Color2();
@@ -1217,3 +1217,11 @@ function hex_to_ip($hex) {
}
return $return;
}
function fix_integer_value($value) {
if ($value < 0) {
$return = 4294967296+$value;
} else {
$return = $value;
}
return $return;
}
+1 -1
View File
@@ -99,7 +99,7 @@ function poll_sensor($device, $class, $unit)
log_event(ucfirst($class) . ' ' . $sensor['sensor_descr'] . " above threshold: " . $sensor_value . " $unit (> " . $sensor['sensor_limit'] . " $unit)", $device, $class, $sensor['sensor_id']);
}
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$memcache->set('sensor-'.$sensor['sensor_id'].'-value', $sensor_value);
} else {
+1 -1
View File
@@ -46,7 +46,7 @@ foreach (dbFetchRows("SELECT * FROM mempools WHERE device_id = ?", array($device
$mempool['state']['mempool_lowestfree'] = $mempool['lowestfree'];
}
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
if($debug) { print_r($mempool['state']); }
$memcache->set('mempool-'.$mempool['mempool_id'].'-value', $mempool['state']);
+8
View File
@@ -0,0 +1,8 @@
<?php
# Enterasys Networks, Inc. G3G124-24P Rev 06.03.08.0012
list(,,,$hardware,,$version) = explode(" ", $device['sysDescr']);
?>
+5
View File
@@ -0,0 +1,5 @@
<?php
$hardware = snmp_get($device, "upsIdentModel.0", "-OQv", "UPS-MIB");
$version = snmp_get($device, "upsIdentAgentSoftwareVersion.0", "-OQv", "UPS-MIB");
+7 -7
View File
@@ -164,7 +164,7 @@ foreach ($ports as $port)
if ($device['os'] == "vmware" && preg_match("/Device ([a-z0-9]+) at .*/", $this_port['ifDescr'], $matches)) { $this_port['ifDescr'] = $matches[1]; }
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$state = $memcache->get('port-'.$port['port_id'].'-state');
if($debug) { print_r($state); }
@@ -184,7 +184,7 @@ foreach ($ports as $port)
$port['update']['poll_period'] = $polled_period;
}
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$port['state']['poll_time'] = $polled;
$port['state']['poll_prev'] = $port['poll_time'];
@@ -215,7 +215,7 @@ foreach ($ports as $port)
$this_port['ifOutMulticastPkts'] = $this_port['ifHCOutMulticastPkts'];
}
// Overwrite ifSpeed with ifHighSpeed if it's over 10G
// Overwrite ifSpeed with ifHighSpeed if it's over 1G
if (is_numeric($this_port['ifHighSpeed']) && $this_port['ifSpeed'] > "1000000000")
{
echo("HighSpeed ");
@@ -303,7 +303,7 @@ foreach ($ports as $port)
$port['update'][$oid.'_prev'] = $port[$oid];
}
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$port['state'][$oid] = $this_port[$oid];
$port['state'][$oid.'_prev'] = $port[$oid];
@@ -323,7 +323,7 @@ foreach ($ports as $port)
$port['update'][$oid.'_delta'] = $oid_diff;
}
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$port['state'][$oid.'_rate'] = $oid_rate;
$port['state'][$oid.'_delta'] = $oid_diff;
@@ -356,7 +356,7 @@ foreach ($ports as $port)
echo('pkts('.format_si($port['stats']['ifInUcastPkts_rate']).'pps/'.format_si($port['stats']['ifOutUcastPkts_rate']).'pps)');
// Store aggregate in/out state
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$port['state']['ifOctets_rate'] = $port['stats']['ifOutOctets_rate'] + $port['stats']['ifInOctets_rate'];
$port['state']['ifUcastPkts_rate'] = $port['stats']['ifOutUcastPkts_rate'] + $port['stats']['ifInUcastPkts_rate'];
@@ -434,7 +434,7 @@ foreach ($ports as $port)
if ($device['os'] == "aos") { include("port-alcatel.inc.php"); }
// Update Memcached
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
if($debug) { print_r($port['state']); }
$memcache->set('port-'.$port['port_id'].'-state', $port['state']);
+1 -1
View File
@@ -36,7 +36,7 @@ foreach (dbFetchRows("SELECT * FROM storage WHERE device_id = ?", array($device[
rrdtool_update($storage_rrd,"N:".$storage['used'].":".$storage['free']);
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$memcache->set('storage-'.$storage['storage_id'].'-used', $storage['used']);
$memcache->set('storage-'.$storage['storage_id'].'-free', $storage['free']);
+3 -1
View File
@@ -11,8 +11,10 @@ if (!is_array($storage_cache['hrstorage']))
$entry = $storage_cache['hrstorage'][$storage[storage_index]];
$storage['units'] = $entry['hrStorageAllocationUnits'];
$entry['hrStorageUsed'] = fix_integer_value($entry['hrStorageUsed']);
$entry['hrStorageSize'] = fix_integer_value($entry['hrStorageSize']);
$storage['used'] = $entry['hrStorageUsed'] * $storage['units'];
$storage['size'] = $entry['hrStorageSize'] * $storage['units'];
$storage['free'] = $storage['size'] - $storage['used'];
?>
?>
+1 -1
View File
@@ -40,7 +40,7 @@
$cmd = (isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : "");
function get_data($host, $port) {
$fp = @fsockopen($host, $port, &$errno, &$errstr, 5);
$fp = @fsockopen($host, $port, $errno, $errstr, 5);
if(!$fp) { $connect = 0; }
if (!isset($connect)) {
fputs($fp, "GET /7.html HTTP/1.0\r\n"
File diff suppressed because one or more lines are too long
+4 -4
View File
@@ -16,10 +16,10 @@
include("includes/defaults.inc.php");
include("config.php");
include("includes/definitions.inc.php");
include("includes/syslog.php");
include("includes/dbFacile.php");
include("includes/common.php");
include("includes/functions.php");
include_once("includes/syslog.php");
include_once("includes/dbFacile.php");
include_once("includes/common.php");
include_once("includes/functions.php");
$i = "1";