This commit is contained in:
laf 2016-01-04 12:09:32 +00:00
commit 0f33f6d1fa
316 changed files with 36603 additions and 11399 deletions

View File

@ -63,5 +63,18 @@ Contributors to LibreNMS:
- Falk Stern <falk@fourecks.de> (fstern)
- Donovan Bridoux <donovan.bridoux@gmail.com> (PandaWawawa)
- Sebastian Neuner <sebastian@sneuner.org> (9er)
- Robert Zollner <wolfit_ro@yahoo.com> (Lupul)
- Richard Hartmann <richih@debian.org> (RichiH)
- Robert Gornall <roblnm@khobbits.co.uk (KHobbits)
- Rob Gormley <robert@gormley.me> (rgormley)
- Richard Kojedzinszky <krichy@nmdps.net> (rkojedzinszky)
- Tony Murray <murraytony@gmail.com> (murrant)
- Peter Lamperud <peter.lamperud@gmail.com> (vizay)
- Louis Bailleul <louis.bailleul@gmail.com> (alucardfh)
- Rick Hodger <rick@fuzzi.org.uk> (Tatermen)
- Eldon Koyle <ekoyle@gmail.com> (ekoyle)
- Jonathan Bailey <jcbailey@code0.net> (jcbailey2)
- Ruairi Carroll <ruairi.carroll@gmail.com> (rucarrol)
- Maxim Tsyplakov <maxim.tsyplakov@gmail.com> (tsypa)
- D. Britz <github@wrind.de> (flatterlight)
[1]: http://observium.org/ "Observium web site"

View File

@ -48,7 +48,7 @@ typeahead:
$(GIT_SUBTREE) --prefix=lib/typeahead https://github.com/twitter/typeahead.js.git master
gridster:
$(GIT_SUBTREE) --prefix=lib/gridster https://github.com/ducksboard/gridster.js.git master
$(GIT_SUBTREE) --prefix=lib/gridster https://github.com/dsmorse/gridster.js.git master
jquery-mapael:
$(GIT_SUBTREE) --prefix=lib/jQuery-Mapael https://github.com/neveldo/jQuery-Mapael.git master

View File

@ -203,5 +203,5 @@ print $console_color->convert(
-f forces the device to be added by skipping the icmp and snmp check against the host.
%rRemember to run discovery for the host afterwards.%n
'
'
);

View File

@ -48,7 +48,7 @@ require_once $config['install_dir'].'/includes/definitions.inc.php';
require_once $config['install_dir'].'/includes/functions.php';
require_once $config['install_dir'].'/includes/alerts.inc.php';
if (!defined('TEST')) {
if (!defined('TEST') && $config['alert']['disable'] != 'true') {
echo 'Start: '.date('r')."\r\n";
echo "RunFollowUp():\r\n";
RunFollowUp();
@ -314,6 +314,9 @@ function ExtTransports($obj) {
$tmp = false;
// To keep scrutinizer from naging because it doesnt understand eval
foreach ($config['alert']['transports'] as $transport => $opts) {
if (is_array($opts)) {
$opts = array_filter($opts);
}
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').' return false; };');

View File

@ -31,8 +31,16 @@ foreach (dbFetchRows('SELECT * FROM `devices` AS D, `services` AS S WHERE S.devi
include $checker_script;
}
else {
$status = '2';
$check = "Error : Script not found ($checker_script)";
$cmd = $config['nagios_plugins'] . "/check_" . $service['service_type'] . " -H " . ($service['service_ip'] ? $service['service_ip'] : $service['hostname']);
$cmd .= " ".$service['service_param'];
$check = shell_exec($cmd);
list($check, $time) = split("\|", $check);
if(stristr($check, "ok -")) {
$status = 1;
}
else {
$status = 0;
}
}
$update = array();

View File

@ -13,10 +13,8 @@ require 'includes/functions.php';
$options = getopt('f:');
if ($options['f'] === 'update') {
$pool_size = dbFetchCell('SELECT @@innodb_buffer_pool_size');
// The following query is from the excellent mysqltuner.pl by Major Hayden https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
$pool_used = dbFetchCell('SELECT SUM(DATA_LENGTH+INDEX_LENGTH) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ("information_schema", "performance_schema", "mysql") AND ENGINE = "InnoDB" GROUP BY ENGINE ORDER BY ENGINE ASC');
if ($pool_used > $pool_size) {
$innodb_buffer = innodb_buffer_check();
if ($innodb_buffer['used'] > $innodb_buffer['size']) {
if (!empty($config['alert']['default_mail'])) {
$subject = $config['project_name'] . ' auto-update action required';
$message = '
@ -26,22 +24,28 @@ We have just tried to update your installation but it looks like the InnoDB buff
Because of this we have stopped the auto-update running to ensure your system is ok.
You currently have a configured innodb_buffer_pool_size of ' . $pool_size / 1024 / 1024 . ' MiB but is currently using ' . $pool_used / 1024 / 1024 . ' MiB
You currently have a configured innodb_buffer_pool_size of ' . $innodb_buffer['size'] / 1024 / 1024 . ' MiB but is currently using ' . $innodb_buffer['used'] / 1024 / 1024 . ' MiB
Take a look at https://dev.mysql.com/doc/refman/5.6/en/innodb-buffer-pool.html for further details.
The ' . $config['project_name'] . ' team.';
send_mail($config['alert']['default_mail'],$subject,$message,$html=false);
} else {
echo 'InnoDB Buffersize too small.'.PHP_EOL;
echo 'Current size: '.($pool_size / 1024 / 1024).' MiB'.PHP_EOL;
echo 'Minimum Required: '.($pool_used / 1024 / 1024).' MiB'.PHP_EOL;
echo 'To ensure integrity, we\'re not going to pull any updates until the buffersize has been adjusted.'.PHP_EOL;
}
echo warn_innodb_buffer($innodb_buffer);
exit(2);
}
else {
exit((int) $config['update']);
if ($config['update']) {
if ($config['update_channel'] == 'master') {
exit(1);
}
elseif ($config['update_channel'] == 'release') {
exit(3);
}
}
else {
exit(0);
}
}
}
@ -102,3 +106,23 @@ if ($options['f'] === 'device_perf') {
}
}
}
if ($options['f'] === 'notifications') {
include_once 'notifications.php';
}
if ($options['f'] === 'purgeusers') {
$purge = 0;
if (is_numeric($config['radius']['users_purge']) && $config['auth_mechanism'] === 'radius') {
$purge = $config['radius']['users_purge'];
}
if ($purge > 0) {
foreach (dbFetchRows("SELECT DISTINCT(`user`) FROM `authlog` WHERE `datetime` >= DATE_SUB(NOW(), INTERVAL ? DAY)", array($purge)) as $user) {
$users[] = $user['user'];
}
$del_users = '"'.implode('","',$users).'"';
if (dbDelete('users', "username NOT IN ($del_users)",array($del_users))) {
echo "Removed users that haven't logged in for $purge days";
}
}
}

View File

@ -1,18 +1,79 @@
#!/usr/bin/env bash
set -eu
# Copyright (C) 2015 Daniel Preussker, QuxLabs UG <preussker@quxlabs.com>
# 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/>.
cd "$(dirname "$0")"
arg="$1"
up=$(php daily.php -f update >&2; echo $?)
if [ "$up" -eq 1 ]; then
git pull --quiet
php includes/sql-schema/update.php
# Fancy-Print and run commands
# @arg Text
# @arg Command
# @return Exit-Code of Command
status_run() {
printf "%-50s" "$1"
echo "$1" >> logs/daily.log
tmp=$(bash -c "$2" 2>&1)
ex=$?
echo "$tmp" >> logs/daily.log
echo "Returned: $ex" >> logs/daily.log
[ $ex -eq 0 ] && echo -e ' \033[0;32mOK\033[0m' || echo -e ' \033[0;31mFAIL\033[0m'
return $ex
}
if [ -z "$arg" ]; then
up=$(php daily.php -f update >&2; echo $?)
if [ "$up" -eq 1 ]; then
# Update to Master-Branch
status_run 'Updating to latest codebase' 'git pull --quiet'
elif [ "$up" -eq 3 ]; then
# Update to last Tag
status_run 'Updating to latest release' 'git fetch --tags && git checkout $(git describe --tags $(git rev-list --tags --max-count=1))'
fi
cnf=$(echo $(grep '\[.distributed_poller.\]' config.php | egrep -v -e '^//' -e '^#' | cut -d = -f 2 | sed 's/;//g'))
cnd=${cnf,,}
if [ -z "$cnf" ] || [ "$cnf" == "0" ] || [ "$cnf" == "false" ]; then
# Call ourself again in case above pull changed or added something to daily.sh
$0 post-pull
fi
else
case $arg in
post-pull)
# List all tasks to do after pull in the order of execution
status_run 'Updating SQL-Schema' 'php includes/sql-schema/update.php'
status_run 'Updating submodules' "$0 submodules"
status_run 'Cleaning up DB' "$0 cleanup"
status_run 'Fetching notifications' "$0 notifications"
;;
cleanup)
# DB-Cleanups
php daily.php -f syslog
php daily.php -f eventlog
php daily.php -f authlog
php daily.php -f perf_times
php daily.php -f callback
php daily.php -f device_perf
php daily.php -f purgeusers
;;
submodules)
# Init+Update our submodules
git submodule --quiet init
git submodule --quiet update
;;
notifications)
# Get notifications
php daily.php -f notifications
;;
esac
fi
php daily.php -f syslog
php daily.php -f eventlog
php daily.php -f authlog
php daily.php -f perf_times
php daily.php -f callback
php daily.php -f device_perf

View File

@ -18,6 +18,11 @@
- [`list_devices`](#api-route-10)
- [`add_device`](#api-route-11)
- [`list_oxidized`](#api-route-21)
- [`update_device_field`](#api-route-update_device_field)
- [`get_device_groups`](#api-route-get_device_groups)
- [`devicegroups`](#api-devicegroups)
- [`get_devicegroups`](#api-route-get_devicegroups)
- [`get_devices_by_group`](#api-route-get_devices_by_group)
- [`routing`](#api-routing)
- [`list_bgp`](#api-route-1)
- [`switching`](#api-switching)
@ -315,6 +320,7 @@ Input:
- to: This is the date you would like the graph to end - See http://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html for more information.
- width: The graph width, defaults to 1075.
- height: The graph height, defaults to 300.
- ifDescr: If this is set to true then we will use ifDescr to lookup the port instead of ifName. Pass the ifDescr value you want to search as you would ifName.
Example:
```curl
@ -462,6 +468,183 @@ Output:
]
```
### <a name="api-route-update_device_field">Function: `update_device_field`</a> [`top`](#top)
Update devices field in the database.
Route: /api/v0/devices/:hostname
- hostname can be either the device hostname or id
Input (JSON):
- field: The column name within the database
- data: The data to update the column with
Examples:
```curl
curl -X PATCH -d '{"field": "notes", "data": "This server should be kept online"}' -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/devices/localhost
```
Output:
```text
[
{
"status": "ok",
"message": "Device notes has been updated"
}
]
```
### <a name="api-route-get_device_groups">Function `get_device_groups`</a> [`top`](#top)
List the device groups that a device is matched on.
Route: /api/v0/devices/:hostname/groups
- hostname can be either the device hostname or id
Input (JSON):
-
Examples:
```curl
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/devices/localhost/groups
```
Output:
```text
[
{
"status": "ok",
"message": "Found 1 device groups",
"count": 1,
"groups": [
{
"id": "1",
"name": "Testing",
"desc": "Testing",
"pattern": "%devices.status = \"1\" &&"
}
]
}
]
```
## <a name="api-devicegroups">`Device Groups`</a> [`top`](#top)
### <a name="api-route-get_devicegroups">Function `get_devicegroups`</a> [`top`](#top)
List all device groups.
Route: /api/v0/devicegroups
Input (JSON):
-
Examples:
```curl
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/devicegroups
```
Output:
```text
[
{
"status": "ok",
"message": "Found 1 device groups",
"count": 1,
"groups": [
{
"id": "1",
"name": "Testing",
"desc": "Testing",
"pattern": "%devices.status = \"1\" &&"
}
]
}
]
```
### <a name="api-route-get_devices_by_group">Function `get_devices_by_group`</a> [`top`](#top)
List all devices matching the group provided.
Route: /api/v0/devicegroups/:name
- name Is the name of the device group which can be obtained using [`get_devicegroups`](#api-route-get_devicegroups). Please ensure that the name is urlencoded if it needs to be (i.e Linux Servers would need to be urlencoded.
Input (JSON):
-
Examples:
```curl
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/devicegroups/LinuxServers
```
Output:
```text
[
{
"status": "error",
"message": "Found 1 in group LinuxServers",
"count": 1,
"devices": [
{
"device_id": "1",
"hostname": "localhost",
"sysName": "hostname",
"community": "librenms",
"authlevel": null,
"authname": null,
"authpass": null,
"authalgo": null,
"cryptopass": null,
"cryptoalgo": null,
"snmpver": "v2c",
"port": "161",
"transport": "udp",
"timeout": null,
"retries": null,
"bgpLocalAs": null,
"sysObjectID": ".1.3.6.1.4.1.8072.3.2.10",
"sysDescr": "Linux li1045-133.members.linode.com 4.1.5-x86_64-linode61 #7 SMP Mon Aug 24 13:46:31 EDT 2015 x86_64",
"sysContact": "",
"version": "4.1.5-x86_64-linode61",
"hardware": "Generic x86 64-bit",
"features": "CentOS 7.1.1503",
"location": "",
"os": "linux",
"status": "1",
"status_reason": "",
"ignore": "0",
"disabled": "0",
"uptime": "4615964",
"agent_uptime": "0",
"last_polled": "2015-12-12 13:20:04",
"last_poll_attempted": null,
"last_polled_timetaken": "1.90",
"last_discovered_timetaken": "79.53",
"last_discovered": "2015-12-12 12:34:21",
"last_ping": "2015-12-12 13:20:04",
"last_ping_timetaken": "0.08",
"purpose": null,
"type": "server",
"serial": null,
"icon": null,
"poller_group": "0",
"override_sysLocation": "0",
"notes": "Nope"
}
]
}
]
```
## <a name="api-routing">`Routing`</a> [`top`](#top)
### <a name="api-route-1">Function: `list_bgp`</a> [`top`](#top)

View File

@ -18,7 +18,7 @@ This will determine the default config option for `$config['alert']['tolerance_w
If the sub-section you want to add the new config option already exists then update the relevant file within
`html/pages/settings/` otherwise you will need to create the new sub-section page. Here's an example of this:
[Commit example](https://github.com/librenm/librenms/commit/c5998f9ee27acdac0c0f7d3092fc830c51ff684c)
[Commit example](https://github.com/librenms/librenms/commit/c5998f9ee27acdac0c0f7d3092fc830c51ff684c)
```php
<?php

View File

@ -18,6 +18,9 @@ Table of Content:
- [Pushover](#transports-pushover)
- [Boxcar](#transports-boxcar)
- [Pushbullet](#transports-pushbullet)
- [Clickatell](#transports-clickatell)
- [PlaySMS](#transports-playsms)
- [VictorOps](#transports-victorops)
- [Entities](#entities)
- [Devices](#entity-devices)
- [BGP Peers](#entity-bgppeers)
@ -30,6 +33,7 @@ Table of Content:
- [Device](#macros-device)
- [Port](#macros-port)
- [Time](#macros-time)
- [Additional Options](#extra)
# <a name="about">About</a>
@ -372,6 +376,54 @@ $config['alert']['transports']['pushbullet'] = 'MYFANCYACCESSTOKEN';
```
~~
## <a name="transports-clickatell">Clickatell</a>
Clickatell provides a REST-API requiring an Authorization-Token and at least one Cellphone number.
Please consult Clickatell's documentation regarding number formating.
Here an example using 3 numbers, any amount of numbers is supported:
~~
```php
$config['alert']['transports']['clickatell']['token'] = 'MYFANCYACCESSTOKEN';
$config['alert']['transports']['clickatell']['to'][] = '+1234567890';
$config['alert']['transports']['clickatell']['to'][] = '+1234567891';
$config['alert']['transports']['clickatell']['to'][] = '+1234567892';
```
~~
## <a name="transports-playsms">PlaySMS</a>
PlaySMS is an OpenSource SMS-Gateway that can be used via their HTTP-API using a Username and WebService-Token.
Please consult PlaySMS's documentation regarding number formating.
Here an example using 3 numbers, any amount of numbers is supported:
~~
```php
$config['alert']['transports']['playsms']['url'] = 'https://localhost/index.php?app=ws';
$config['alert']['transports']['playsms']['user'] = 'user1';
$config['alert']['transports']['playsms']['token'] = 'MYFANCYACCESSTOKEN';
$config['alert']['transports']['playsms']['from'] = '+1234567892'; //Optional
$config['alert']['transports']['playsms']['to'][] = '+1234567890';
$config['alert']['transports']['playsms']['to'][] = '+1234567891';
```
~~
## <a name="transports-victorops">VictorOps</a>
VictorOps provide a webHook url to make integration extremely simple. To get the URL required login to your VictorOps account and go to:
Settings -> Integrations -> REST Endpoint -> Enable Integration.
The URL provided will have $routing_key at the end, you need to change this to something that is unique to the system sending the alerts such as librenms. I.e:
`https://alert.victorops.com/integrations/generic/20132414/alert/2f974ce1-08fc-4dg8-a4f4-9aee6cf35c98/librenms`
~~
```php
$config['alert']['transports']['victorops']['url'] = 'https://alert.victorops.com/integrations/generic/20132414/alert/2f974ce1-08fc-4dg8-a4f4-9aee6cf35c98/librenms';
```
~~
# <a name="entities">Entities
Entities as described earlier are based on the table and column names within the database, if you are unsure of what the entity is you want then have a browse around inside MySQL using `show tables` and `desc <tablename>`.
@ -582,4 +634,14 @@ Description: Packet loss % value for the device within the last 15 minutes.
Example: `%macros.packet_loss_15m` > 50
# <a name="extra">Additional Options</a>
Here are some of the other options available when adding an alerting rule:
- Rule name: The name associated with the rule.
- Severity: How "important" the rule is.
- Max alerts: The maximum number of alerts sent for the event. `-1` means unlimited.
- Delay: The amount of time to wait after a rule is matched before sending an alert.
- Interval: The interval of time between alerts for an event until Max is reached.
- Mute alerts: Disable sending alerts for this rule.
- Invert match: Invert the matching rule (ie. alert on items that _don't_ match the rule).

View File

@ -9,7 +9,11 @@ Here we will provide configuration details for these modules.
- LDAP: ldap
HTTP Auth: http-auth
- Active Directory: active_directory
- HTTP Auth: http-auth
- Radius: radius
#### User levels
@ -99,3 +103,43 @@ $config['auth_ldap_groupmemberattr'] = "memberUid";
```
Replace {id} with the unique ID provided by Jumpcloud.
#### Active Directory Authentication
Config option: `active_directory`
This is similar to LDAP Authentication. Install __php_ldap__ for CentOS/RHEL or __php5-ldap__ for Debian/Ubuntu.
If you have issues with secure LDAP try setting `$config['auth_ad_check_certificates']` to `0`.
##### Require actual membership of the configured groups
If you set ```$config['auth_ad_require_groupmembership']``` to 1, the authenticated user has to be a member of the specific group. Otherwise all users can authenticate, but are limited to user level 0 and only have access to shared dashboards.
##### Sample configuration
```
$config['auth_ad_url'] = "ldaps://your-domain.controll.er";
$config['auth_ad_check_certificates'] = 1; // or 0
$config['auth_ad_domain'] = "your-domain.com";
$config['auth_ad_base_dn'] = "dc=your-domain,dc=com";
$config['auth_ad_groups']['admin']['level'] = 10;
$config['auth_ad_groups']['pfy']['level'] = 7;
$config['auth_ad_require_groupmembership'] = 0;
```
#### Radius Authentication
Please note that a mysql user is created for each user the logs in successfully. User level 1 is assigned to those accounts so you will then need to assign the relevant permissions unless you set `$config['radius']['userlevel']` to be something other than 1.
> Cleanup of old accounts is done using the authlog. You will need to set the cleanup date for when old accounts will be purged which will happen AUTOMATICALLY.
> Please ensure that you set the $config['authlog_purge'] value to be greater than $config['radius']['users_purge'] otherwise old users won't be removed.
```php
$config['radius']['hostname'] = 'localhost';
$config['radius']['port'] = '1812';
$config['radius']['secret'] = 'testing123';
$config['radius']['timeout'] = 3;
$config['radius']['users_purge'] = 14;//Purge users who haven't logged in for 14 days.
$config['radius']['default_level'] = 1;//Set the default user level when automatically creating a user.
```

View File

@ -14,3 +14,5 @@ By default values are kept for 4 Minutes inside the memcached, you can adjust th
It's strongly discouraged to set this above `300` (5 Minutes) to avoid interferences with the polling, discovery and alerting processes.
If you use the Distributed Poller, you can point this to the same memcached instance. However a local memcached will perform better in any case.
By default `memcached` on many distributions starts itself with 64 MB of memory for it to store data in. If you have lots of devices or look at graphs frequently, it might be worth it to expand `memcached`'s footprint a bit. Generally this can be done in `/etc/memcached.conf`, replacing `-m 64` with `-m 512`, or however many megs of memory you want to allocate for `memcached`. Then restart the `memcached` service.

View File

@ -40,3 +40,10 @@ You will need to configure default credentials for your devices, LibreNMS doesn'
```
If you have devices which you do not wish to appear in Oxidized then you can edit those devices in Device -> Edit -> Misc and enable "Exclude from Oxidized?"
It's also possible to exclude certain device types and OS' from being output via the API. This is currently only possible via config.php:
```php
$config['oxidized']['ignore_types'] = array('server');
$config['oxidized']['ignore_os'] = array('linux');
```

View File

@ -1,6 +1,5 @@
# Proxmox graphing
It is possible to create graphs of the Proxmox VMs that run on your monitored machines. Currently, only trafficgraphs are created. One for each interface on each VM. Possibly, IO grahps will be added later on.
It is possible to create graphs of the Proxmox **VMs** that run on your monitored machines. Currently, only trafficgraphs are created. One for each interface on each VM. Possibly, IO grahps will be added later on.
The ultimate goal is to be able to create traffic bills for VMs, no matter on which physical machine that VM runs.
@ -10,14 +9,20 @@ To enable Proxmox graphs, do the following:
In config.php, enable Proxmox:
```php
$config['enable_proxmox'] = 1
$config['enable_proxmox'] = 1;
```
Then, install librenms-agent on the machines running Proxmox, and enable the Proxmox-plugin using:
Then, install [librenms-agent](http://docs.librenms.org/Extensions/Agent-Setup/) on the machines running Proxmox and enable the Proxmox-script using:
```bash
mk_enplug proxmox
cp /opt/librenms-agent/proxmox /usr/lib/check_mk_agent/local/proxmox
chmod +x /usr/lib/check_mk_agent/local/proxmox
```
Then, enable the unix-agent on the machines running Proxmox.
Then, restart the xinetd service
```bash
/etc/init.d/xinetd restart
```
Then in LibreNMS active the librenms-agent and proxmox application flag for the device you are monitoring.
You should now see an application in LibreNMS, as well as a new menu-item in the topmenu, allowing you to choose which cluster you want to look at.

21
doc/Extensions/RRDTune.md Normal file
View File

@ -0,0 +1,21 @@
# RRDTune?
When we create rrd files for ports, we currently do so with a max value of 12500000000 (100G). Because of this if a device sends us bad data back then it can appear as though
a 100M port is doing 40G+ which is impossible. To counter this you can enable the rrdtool tune option which will fix the max value to the interfaces physical speed (minimum of 10M).
To enable this you can do so in three ways!
- Globally under Global Settings -> External Settings -> RRDTool Setup
- For the actual device, Edit Device -> Misc
- For each port, Edit Device -> Port Settings
Now when a port interface speed changes (this can happen because of a physical change or just because the device has mis-reported) the max value is set. If you don't want to wait until
a port speed changes then you can run the included script:
script/tune_port.php -h <hostname> -p <ifName>
Wildcards are supported using *, i.e:
script/tune_port.php -h local* -p eth*
This script will then perform the rrdtool tune on each port found using the provided ifSpeed for that port.

View File

@ -3,7 +3,7 @@
Services within LibreNMS provides the ability to use Nagios plugins to perform additional monitoring outside of SNMP.
These services are tied into an existing device so you need at least one device that supports SNMP to be able to add it
to LibreNMS - localhot is a good one.
to LibreNMS - localhost is a good one.
## Setup

View File

@ -43,3 +43,129 @@ $config['own_hostname']
```
You should now see a new tab in your device page called ping.
### Install and integrate Smokeping [Debian/Ubuntu] ###
> This guide assumes you have already <a href="http://docs.librenms.org/Installation/Installation-(Debian-Ubuntu)/">installed librenms</a>, and you installed apache2 in the process. Tested with Ubuntu 14.04 and Apache 2.4.
Nearly everything we do will require root, and at one point we'll encounter a problem if we just use sudo, so we'll just switch to root at the beginning...
```bash
sudo su -
```
### Install Smokeping ###
```bash
apt-get install smokeping
```
At the end of installation, you may have gotten this error: `ERROR: /etc/smokeping/config.d/pathnames, line 1: File '/usr/sbin/sendmail' does not exist`
If so, just edit smokeping's pathnames.
```bash
nano /etc/smokeping/config.d/pathnames
```
Comment out the first line:
```bash
#sendmail = /usr/sbin/sendmail
```
Exit and save.
Check if the smokeping config file was created for apache2:
```bash
ls /etc/apache2/conf-available/
```
If you don't see `smokeping.conf` listed, you'll need to create a symlink for it:
```bash
ln -s /etc/smokeping/apache2.conf /etc/apache2/conf-available/smokeping.conf
```
Edit the smokeping config so smokeping knows the hostname it's running on:
```bash
nano /etc/smokeping/config.d/General
```
Change the `cgiurl` value to `http://yourhost/cgi-bin/smokeping.cgi`
Modify any other values you wish, then exit and save.
### LibreNMS integration ###
So far this is a relatively normal Smokeping installation; next we'll set up the LibreNMS integration.
Generate the configuration file so Smokeping knows the hosts you have set up for monitoring in LibreNMS.
```bash
cd /opt/librenms/scripts/
(echo "+ LibreNMS"; php ./gen_smokeping.php) > /etc/smokeping/config.d/librenms.conf
```
Add a cron job so as you add or remove hosts in librenms they'll get updated with Smokeping.
```bash
crontab -e
```
Add the example cron below; it's set to run daily at 02:05
```bash
05 02 * * * root cd /opt/librenms/scripts && (echo "+ LibreNMS"; php ./gen_smokeping.php) > /etc/smokeping/config.d/librenms.conf && service smokeping reload >> /dev/null
```
Exit and save.
Include `librenms.conf` in smokeping's config:
```bash
nano /etc/smokeping/config
```
Add the following line at the end:
```bash
@include /etc/smokeping/config.d/librenms.conf
```
Exit and save.
### Configure LibreNMS ###
```bash
nano /opt/librenms/config.php
```
Scroll to the bottom, and paste in the following:
```bash
$config['smokeping']['dir'] = '/var/lib/smokeping';
$config['smokeping']['integration'] = true;
```
Exit and save.
Run the following commands:
```bash
a2enconf smokeping
a2enmod cgid
service apache2 restart
service smokeping restart
```
Return to your normal user shell
```bash
exit
```
Done! You should be able to load the Smokeping web interface at `http://yourhost/cgi-bin/smokeping.cgi`
In LibreNMS, a Ping tab should also appear.

View File

@ -23,6 +23,7 @@ LibreNMS 3rd party acknowledgements
- Tag Manager (http://soliantconsulting.github.io/tagmanager/): MIT
- TW Sack (https://code.google.com/p/tw-sack/): GPLv3
- Gridster (http://gridster.net/): MIT
- Pure PHP radius class (http://developer.sysco.ch/php/): GPLv3
#### 3rd Party GPLv3 Non-compliant

View File

@ -28,5 +28,6 @@ Now onto the bit you're interested in, what is submitted and what we do with tha
Hopefully this answers the questions you might have on why and what we are doing here, if not, please pop into our irc channel or google mailing list and ask any questions you like.
#### How do I enable stats submission? ####
If you're happy with all of this - please consider switching the call back system on, you can do this within the About LibreNMS page within your control panel. In the Statistics section you will find a toggle switch to enable / disable the feature. If you've previously had it switched on and want to opt out and remove your data, click the 'Clear remote stats' button and on the next submission all the data you've sent us will be removed!

View File

@ -1,16 +1,157 @@
### December 2015
#### Bug fixes
- WebUI:
- Fixed regex for negative lat/lng coords (PR2524)
- Fixed map page looping due to device connected to itself (PR2545)
- Fixed PATH_INFO for nginx (PR2551)
- urlencode the custom port types (PR2597)
- Stop non-admin users from being able to get to settings pages (PR2627)
- Fix JpGraph php version compare (PR2631)
- Discovery / Polling:
- Pointed snmp calls for Huawei to correct MIB folder (PR2541)
- Fixed Ceph unix-agent support. (PR2588)
- Moved memory graphs from storage to memory polling (PR2616)
- Mask alert_log mysql output when debug is enabled to stop console crashes (PR2618)
- Stop Quanta devices being detected as Ubiquiti (PR2632)
- Fix MySQL unix-agent graphs (PR2645)
- Added MTA-MIB and NETWORK-SERVICES-MIB to stop warnings printed in poller debug (PR2653)
- Services:
- Fix SSL check for PHP 7 (PR2647)
- Alerting:
- Fix glue-expansion for alerts (PR2522)
- Fix HipChat transport (PR2586)
- Documentation:
- Removed duplicate mysql-client install from Debian/Ubuntu install docs (PR2543)
- Misc:
- Update daily.sh to ignore issues writing to log file (PR2595)
#### Improvements
- WebUI:
- Converted sensors page to use bootgrid (PR2531)
- Added new widgets for dashboard. Notes (PR2582), Generic image (PR2617)
- Added config option to disable lazy loading of images (PR2589)
- Visual update to Navbar. (PR2593)
- Update alert rules to show actual alert rule ID (PR2603)
- Initial support added for per user default dashboard (PR2620)
- Updated Worldmap to show clusters in red if one device is down (PR2621)
- Discovery / Polling
- Added traffic bits as default for Cambium devices (PR2525)
- Overwrite eth0 port data from UniFi MIBs for AirFibre devices (PR2544)
- Added lastupdate column to sensors table for use with alerts (PR2590,PR2592)
- Updated auto discovery via lldp to check for devices that use mac address in lldpRemPortId (PR2591)
- Updated auto discovery via lldp with absent lldpRemSysName (PR2619)
- API:
- Added ability to filter devices by type and os for Oxidized API call (PR2539)
- Added ability to update device information (PR2585)
- Added support for returning device groups (PR2611)
- Added ability to select port graphs based on ifDescr (PR2648)
- Documentation:
- Improved alerting docs explaining more options (PR2560)
- Added Docs for Ubuntu/Debian Smokeping integration (PR2610)
- Added detection for:
- Updated Netonix switch MIBs (PR2523)
- Updated Fotinet MIBs (PR2529, PR2534)
- Cisco SG500 (PR2609)
- Updated processor support for Fortigate (PR2613)
- Misc:
- Updated validation to check for php extension and classes required (PR2602)
- Added Radius Authentication support (PR2615)
- Removed distinct() from alerts query to use indexes (PR2649)
### November 2015
#### Bug fixes
- WebUI:
- getRates should return in and out average rates (PR2375)
- Fix 95th percent lines in negative range (PR2405)
- Fix percentage bar for billing pages (PR2419)
- Use HC counters first in realtime graphs (PR2420)
- Fix netcmd.php URI for sub dir installations (PR2428)
- Fixed Oxidized fetch config with groups (PR2501)
- Fixed background colour to white for some graphs (PR2516)
- API:
- Added missing quotes for MySQL queries (PR2382)
- Discovery / Polling:
- Specified MIB used when polling ntpd-server (PR2418)
- Added missing fields when inserting data into applications table (PR2445)
- Fix auto-discovery failing (PR2457)
- Juniper hardware inventory fix (PR2466)
- Fix discovery of Cisco PIX running PixOS 8.0 (PR2480)
- Fix bug in Proxmox support if only one VM was detected (PR2490, PR2547)
- Alerting:
- Strip && and || from query for device-groups (PR2476)
- Fix transports being triggered when empty keys set (PR2491)
Misc:
- Updated device_traffic_descr config to stop graphs failing (PR2386)
#### Improvements
- WebUI:
- Status column now sortable for /devices/ (PR2397)
- Update Gridster library to be responsive (PR2414)
- Improved rrdtool 1.4/1.5 compatibility (PR2430)
- Use event_id in query for Eventlog (PR2437)
- Add graph selector to devices overview (PR2438)
- Improved Navbar for varying screen sizes (PR2450)
- Added RIPE NCC API support for lookups (PR2455, PR2474)
- Improved ports page for device with large number of neighbours (PR2460)
- Merged all CPU graphs into one on overview page (PR2470)
- Added support for sortting by traffic on device port page (PR2508)
- Added support for dynamic graph sizes based on browser size (PR2510)
- Made device location clickable in device header (PR2515)
- Visual improvements to bills page (PR2519)
- Discovery / Polling:
- Updated Cisco SB discovery (PR2396)
- Added Ceph support via Applications (PR2412)
- Added support for per device unix-agent port (PR2439)
- Added ability to select up/down devices on worldmap (PR2441)
- Allow powerdns app to be set for Unix Agent (PR2489)
- Added SLES detection to distro script (PR2502)
- Added detection for:
- Added CPU + Memory usage for Ubiquiti UniFi (PR2421)
- Added support for LigoWave Infinity AP's (PR2456)
- Alerting:
- Added ability to globally disable sending alerts (PR2385)
- Added support for Clickatell, PlaySMS and VictorOps (PR24104, PR2443)
- Documnetation:
- Improved CentOS install docs (PR2462)
- Improved Proxmox setup docs (PR2483)
- Misc:
- Provide InnoDB config for buffer size issues (PR2401)
- Added AD Authentication support (PR2411, PR2425, PR2432, PR2434)
- Added Features document (PR2436, PR2511, PR2513)
- Centralised innodb buffer check and added to validate (PR2482)
- Updated and improved daily.sh (PR2487)
### October 2015
#### Bug fixes
- Discovery / Polling:
- Check file exists via rrdcached before creating new files on 1.5 (PR2041)
- Fix Riverbed discovery (PR2133)
- Fixes issue where snmp_get would not return the value 0 (PR2134)
- Fixed powerdns snmp checks (PR2176)
- De-dupe checks for hostname when adding hosts (PR2189)
- WebUI:
- Soft fail if PHP Pear not installed (PR2036)
- Escape quotes for ifAlias in overlib calls (PR2072)
- Fix table name for access points (PR2075)
- Removed STACK text in graphs (PR2097)
- Enable multiple ifDescr overrides to be done per device (PR2099)
- Removed ping + performance graphs and tab if skip ping check (PR2175)
- Fixed services -> Alerts menu link + page (PR2173)
- Fix percent bar also for quota bills (PR2198)
- Fix new Bill (PR2199)
- Change default solver to hierarchicalRepulsion in vis.js (PR2202)
- Fix: setting user port permissions fails (PR2203)
- Updated devices Graphs links to use non-static time references (PR2211)
- Removed ignored,deleted and disabled ports from query (PR2213)
- API:
- Fixed API call for alert states (PR2076)
- Fixed nginx rewrite for api (PR2112)
- Change on the add_edit_rule to modify a rule without modify the name (PR2159)
- Fixed list_bills function when using :bill_id (PR2212)
#### Improvements
- WebUI:
@ -18,23 +159,46 @@
- Added billing graphs to graphs widget (PR2027)
- Lock widgets by default so they can't be moved (PR2042)
- Moved Device Groups menu (PR2049)
- Show Config tab only if device isn't excluded from oxidized (PR2118)
- Simplify adding config options to WebUI (PR2120)
- Move red map markers to foreground (PR2127)
- Styled the two factor auth token prompt (PR2151)
- Update Font Awesome (PR2167)
- Allow user to influence when devices are grouped on world map (PR2170)
- Centralised the date selector for graphs for re-use (PR2183)
- Dont show dashboard settings if `/bare=yes/` (PR2364)
- API:
- Added unmute alert function to API (PR2082)
- Added detection support for:
- Pulse Secure OS (PR2053)
- Discovery / Polling:
- Added additional support for some UPS' based on Multimatic cards (PR2046)
- Improved WatchGuard OS detection (PR2048)
- Treat Dell branded Wifi controllers as ArubaOS (PR2065)
- Added discovery option for OS or Device type (PR2088)
- Updated pfSense to firewall type (PR2096)
- Added ability to turn off icmp checks globally or per device (PR2131)
- Reformat check a bit to make it easier for adding additional oids in (PR2135)
- Updated to disable auto-discovery by ip (PR2182)
- Updated to use env in distro script (PR2204)
- Added detection for:
- Pulse Secure OS (PR2053)
- Riverbed Steelhead support (PR2107)
- OpenBSD sensors (PR2113)
- Additional comware detection (PR2162)
- Version from Synology MIB (PR2163)
- VCSA as VMWare (PR2185)
- SAF Lumina radios (PR2361)
- TP-Link detection (PR2362)
- Documentation:
- Improved RHEL/CentOS install docs (PR2043)
- Update Varnish Docs (PR2116, PR2126)
- Added passworded channels for the IRC-Bot (PR2122)
- Updated Two-Factor-Auth.md RE: Google Authenticator (PR2146)
- General:
- Added colour support to IRC bot (PR2059)
- Fixed IRC bot reconnect if socket dies (PR2061)
- Updated default crons (PR2177)
- Reverts:
- "Removed what appears to be unecessary STACK text" (PR2128)
### September 2015

View File

@ -57,7 +57,7 @@ This host is where the web server and SNMP poller run. It could be the same mac
Install the required software:
apt-get install libapache2-mod-php5 php5-cli php5-mysql php5-gd php5-snmp php-pear php5-curl snmp graphviz php5-mcrypt php5-json apache2 fping imagemagick whois mtr-tiny nmap python-mysqldb snmpd mysql-client php-net-ipv4 php-net-ipv6 rrdtool git
apt-get install libapache2-mod-php5 php5-cli php5-mysql php5-gd php5-snmp php-pear php5-curl snmp graphviz php5-mcrypt php5-json apache2 fping imagemagick whois mtr-tiny nmap python-mysqldb snmpd php-net-ipv4 php-net-ipv6 rrdtool git
The packages listed above are an all-inclusive list of packages that were necessary on a clean install of Ubuntu 12.04/14.04.

View File

@ -99,7 +99,8 @@ Note if not using HTTPd (Apache): RHEL requires `httpd` to be installed regardle
**CentOS 7**
```bash
yum install php php-cli php-gd php-mysql php-snmp php-pear php-curl httpd net-snmp graphviz graphviz-php mariadb ImageMagick jwhois nmap mtr rrdtool MySQL-python net-snmp-utils vixie-cron php-mcrypt fping git
yum install epel-release
yum install php php-cli php-gd php-mysql php-snmp php-pear php-curl httpd net-snmp graphviz graphviz-php mariadb ImageMagick jwhois nmap mtr rrdtool MySQL-python net-snmp-utils cronie php-mcrypt fping git
pear install Net_IPv4-1.3.4
pear install Net_IPv6-1.2.2b2
```
@ -185,6 +186,7 @@ server {
try_files $uri $uri/ @librenms;
}
location ~ \.php {
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi.conf;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;

View File

@ -177,6 +177,11 @@ $config['web_mouseover'] = TRUE;
```
You can disable the mouseover popover for mini graphs by setting this to FALSE.
```php
$config['enable_lazy_load'] = true;
```
You can disable image lazy loading by setting this to false.
```php
$config['show_overview_tab'] = TRUE;
```
@ -261,6 +266,12 @@ $config['autodiscovery']['nets-exclude'][] = "240.0.0.0/4";
```
Arrays of subnets to exclude in auto discovery mode.
```php
$config['discovery_by_ip'] = true;
```
Enable auto discovery by IP. By default we only discover based on hostnames but manually adding by IP is allowed.
Please note this could lead to duplicate devices being added based on IP, Hostname or sysName.
#### Email configuration
> You can configure these options within the WebUI now, please avoid setting these options within config.php
@ -430,7 +441,7 @@ $config['auth_mechanism'] = "mysql";
```
This is the authentication type to use for the WebUI. MySQL is the default and configured when following the installation
instructions. ldap and http-auth are also valid options. For instructions on the different authentication modules please
see [Authentication](http://doc.librenms.org/Extensions/Authentication/).
see [Authentication](http://docs.librenms.org/Extensions/Authentication/).
```php
$config['auth_remember'] = '30';

View File

@ -12,6 +12,7 @@
- [How do I debug the discovery process?](#faq11)
- [How do I debug the poller process?](#faq12)
- [Why do I get a lot apache or rrdtool zombies in my process list?](#faq14)
- [Why do I see traffic spikes in my graphs?](#faq15)
### Developing
- [How do I add support for a new OS?](#faq8)
@ -94,6 +95,13 @@ Please see the [Poller Support](http://docs.librenms.org/Support/Poller Support)
If this is related to your web service for LibreNMS then this has been tracked down to an issue within php which the developers aren't fixing. We have implemented a work around which means you
shouldn't be seeing this. If you are, please report this in [issue 443](https://github.com/librenms/librenms/issues/443).
#### <a name="faq15"> Why do I see traffic spikes in my graphs?</a>
This occurs either when a counter resets or the device sends back bogus data making it look like a counter reset. We have enabled support for setting a maximum value for rrd files for ports.
Before this all rrd files were set to 100G max values, now you can enable support to limit this to the actual port speed.
rrdtool tune will change the max value when the interface speed is detected as being changed (min value will be set for anything 10M or over) or when you run the included script (scripts/tune_port.php).
#### <a name="faq8"> How do I add support for a new OS?</a>
The easiest way to show you how to do that is to link to an existing pull request that has been merged in on [GitHub](https://github.com/librenms/librenms/pull/352/files)

128
doc/Support/Features.md Normal file
View File

@ -0,0 +1,128 @@
### Features
Here's a brief list of supported features, some might be missing.
If you think something is missing, feel free to ask us.
* Alerting
* API
* Auto Updating
* Customizable Dashboards
* Device Backup (Oxidized, RANCID)
* Distributed Polling
* Multiple Authentication Methods (MySQL, LDAP, Active Directory, HTTP)
* NetFlow, sFlow, IPFIX (NfSen)
* Service monitoring (Nagios Plugins)
* Syslog (Integrated, Graylog)
* Traffic Billing (Quota, 95th Percentile)
* Two Factor Authentication
### Vendors
Here's a brief list of supported vendors, some might be missing.
If you are unsure of whether your device is supported or not, feel free to ask us.
* 3Com
* Aerohive
* AKCP
* Alcatel-Lucent
* Allied Telesis
* APC
* Apple
* Areca
* Arista
* Aruba
* Avaya
* Avocent
* Axis
* Barracuda
* BCM963
* BNT
* Brocade
* Brother
* Canopy
* Cisco
* Cisco Small Business
* Citrix
* Cometsystem
* Comware
* D-Link
* Datacom
* Dell
* Delta Power Solutions
* Eaton
* Engenius
* Enterasys
* Epson
* Extreme Networks
* F5
* FiberHome
* Force10
* Fortigate
* FreeBSD
* Gamatronic
* Hikvision
* HP
* Huawei
* IBM
* iPoMan
* ITWatchDogs
* Juniper
* Konica Minolta
* Kyocera
* Liebert
* LigoWave
* Linux
* Mellanox
* Meraki
* MGE
* Mikrotic
* MRVLD
* Multimatic
* NetApp
* NetBSD
* NETGEAR
* NetMan
* Netonix
* Netopia
* NetVision
* NetWare
* NRG
* OKI
* OpenBSD
* PacketShaper
* Palo Alto Networks
* Papouch
* PBN
* Perle
* Powercode
* Prestige
* Proxim
* Proxmox
* Quanta
* Radlan
* Raritan
* Redback
* Ricoh
* Riverbed
* Ruckus
* SAF
* Siklu
* Sentry3
* Solaris
* SonicWALL
* SpeedTouch
* Supermicro
* Symbol
* TPLink
* Tranzeo
* Triplite
* Ubiquiti
* VMware
* VRP
* Vyatta
* VyOS
* Watchguard
* WebPower
* Windows
* Xerox
* ZTE
* ZyXEL

View File

@ -0,0 +1,8 @@
<?php
session_start();
if(isset($_REQUEST['width']) AND isset($_REQUEST['height'])) {
$_SESSION['screen_width'] = $_REQUEST['width'];
$_SESSION['screen_height'] = $_REQUEST['height'];
}
echo $_SESSION['screen_width'];
echo $_SESSION['screen_height'];

View File

@ -42,12 +42,14 @@ $app->group(
// api/v0/devices/$hostname
$app->get('/:hostname', 'authToken', 'get_device')->name('get_device');
// api/v0/devices/$hostname
$app->patch('/:hostname', 'authToken', 'update_device')->name('update_device_field');
$app->get('/:hostname/vlans', 'authToken', 'get_vlans')->name('get_vlans');
// api/v0/devices/$hostname/vlans
$app->get('/:hostname/graphs', 'authToken', 'get_graphs')->name('get_graphs');
// api/v0/devices/$hostname/graphs
$app->get('/:hostname/ports', 'authToken', 'get_port_graphs')->name('get_port_graphs');
// api/v0/devices/$hostname/ports
$app->get('/:hostname/groups', 'authToken', 'get_device_groups')->name('get_device_groups');
$app->get('/:hostname/:type', 'authToken', 'get_graph_generic_by_hostname')->name('get_graph_generic_by_hostname');
// api/v0/devices/$hostname/$type
$app->get('/:hostname/ports/:ifname', 'authToken', 'get_port_stats_by_port_hostname')->name('get_port_stats_by_port_hostname');
@ -60,6 +62,13 @@ $app->group(
// api/v0/devices
$app->post('/devices', 'authToken', 'add_device')->name('add_device');
// api/v0/devices (json data needs to be passed)
$app->group(
'/devicegroups',
function () use ($app) {
$app->get('/:name', 'authToken', 'get_devices_by_group')->name('get_devices_by_group');
}
);
$app->get('/devicegroups', 'authToken', 'get_device_groups')->name('get_devicegroups');
$app->group(
'/portgroups',
function () use ($app) {

View File

@ -1764,4 +1764,94 @@ tr.search:nth-child(odd) {
label {
font-weight: normal;
}
}
.nav>li>a.dropdown-toggle {
padding: 15px 6px;
}
.badge-navbar-user{
background:red;
border-radius: 40%;
font-size: 65%;
height: auto;
margin: 0;
padding:5px;
position:absolute;
right:-3px;
top:5px;
width: auto;
}
@media only screen and (max-width: 480px) {
.thumbnail_graph_table b { font-size : 6px;}
.thumbnail_graph_table img {
max-width: 45px;
max-height: 50px;
}
.device-header-table .device_icon img {
max-width: 20px;
max-height: 20px;
}
.device-header-table img {
max-width: 115px;
max-height: 40px;
}
.device-header-table {font-size : 8px;}
.device-header-table a {font-size : 11px;}
}
@media only screen and (max-width: 768px) and (min-width: 481px) {
.thumbnail_graph_table b { font-size : 8px;}
.thumbnail_graph_table img {
max-width: 60px;
max-height: 55px;
}
.device-header-table img {
max-width: 150px;
max-height: 50px;
}
.device-header-table {font-size : 10px;}
.device-header-table a {font-size : 17px;}
}
@media only screen and (max-width: 800px) and (min-width: 721px) {
.thumbnail_graph_table b { font-size : 8px;}
.thumbnail_graph_table img {
max-width: 75px;
max-height: 60px;
}
}
@media only screen and (max-width: 1024px) and (min-width: 801px) {
.thumbnail_graph_table b { font-size : 9px;}
.thumbnail_graph_table img {
max-width: 105px;
max-height: 70px;
}
}
@media only screen and (min-width: 1024px) {
}
.redCluster {
background-color: rgba(255,0,0);
background-color: rgba(255,0,0,0.7);
text-align: center;
width: 25px !important;
height: 25px !important;
font-size: 14px;
color: white;
}
.greenCluster {
background-color: rgba(0,255,0);
background-color: rgba(0,255,0,0.7);
text-align: center;
width: 25px !important;
height: 25px !important;
font-size: 14px;
color: black;
border-color:transparent;
}

View File

@ -31,14 +31,14 @@ if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || port_permitted
$auth = true;
}
$in = snmp_get($device, 'ifInOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
$out = snmp_get($device, 'ifOutOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
$in = snmp_get($device, 'ifHCInOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
if (empty($in)) {
$in = snmp_get($device, 'ifHCInOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
$in = snmp_get($device, 'ifInOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
}
$out = snmp_get($device, 'ifHCOutOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
if (empty($out)) {
$out = snmp_get($device, 'ifHCOutOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
$out = snmp_get($device, 'ifOutOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
}
$time = time();

BIN
html/images/os/ligowave.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
html/images/os/quanta.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
html/images/os/saf.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
html/images/os/tplink.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -13,7 +13,7 @@
*/
require_once '../includes/functions.php';
require_once '../includes/device-groups.inc.php';
function authToken(\Slim\Route $route) {
$app = \Slim\Slim::getInstance();
@ -62,10 +62,17 @@ function get_graph_by_port_hostname() {
$vars['to'] = $_GET['to'];
}
if ($_GET['ifDescr'] == true) {
$port = 'ifDescr';
}
else {
$port = 'ifName';
}
$vars['width'] = $_GET['width'] ?: 1075;
$vars['height'] = $_GET['height'] ?: 300;
$auth = '1';
$vars['id'] = dbFetchCell('SELECT `P`.`port_id` FROM `ports` AS `P` JOIN `devices` AS `D` ON `P`.`device_id` = `D`.`device_id` WHERE `D`.`hostname`=? AND `P`.`ifName`=?', array($hostname, $vars['port']));
$vars['id'] = dbFetchCell("SELECT `P`.`port_id` FROM `ports` AS `P` JOIN `devices` AS `D` ON `P`.`device_id` = `D`.`device_id` WHERE `D`.`hostname`=? AND `P`.`$port`=?", array($hostname, $vars['port']));
$app->response->headers->set('Content-Type', 'image/png');
include 'includes/graphs/graph.inc.php';
@ -163,23 +170,23 @@ function list_devices() {
}
if (stristr($order, ' desc') === false && stristr($order, ' asc') === false) {
$order .= ' ASC';
$order = '`'.$order.'` ASC';
}
if ($type == 'all' || empty($type)) {
$sql = '1';
}
elseif ($type == 'ignored') {
$sql = "ignore='1' AND disabled='0'";
$sql = "`ignore`='1' AND `disabled`='0'";
}
elseif ($type == 'up') {
$sql = "status='1' AND ignore='0' AND disabled='0'";
$sql = "`status`='1' AND `ignore`='0' AND `disabled`='0'";
}
elseif ($type == 'down') {
$sql = "status='0' AND ignore='0' AND disabled='0'";
$sql = "`status`='0' AND `ignore`='0' AND `disabled`='0'";
}
elseif ($type == 'disabled') {
$sql = "disabled='1'";
$sql = "`disabled`='1'";
}
elseif ($type == 'mac') {
$join = " LEFT JOIN `ports` ON `devices`.`device_id`=`ports`.`device_id` LEFT JOIN `ipv4_mac` ON `ports`.`port_id`=`ipv4_mac`.`port_id` ";
@ -890,12 +897,14 @@ function get_inventory() {
function list_oxidized() {
// return details of a single device
global $config;
$app = \Slim\Slim::getInstance();
$app->response->headers->set('Content-Type', 'application/json');
$devices = array();
foreach (dbFetchRows("SELECT hostname,os FROM `devices` LEFT JOIN devices_attribs AS `DA` ON devices.device_id = DA.device_id AND `DA`.attrib_type='override_Oxidized_disable' WHERE `status`='1' AND (DA.attrib_value = 'false' OR DA.attrib_value IS NULL)") as $device) {
$device_types = "'".implode("','", $config['oxidized']['ignore_types'])."'";
$device_os = "'".implode("','", $config['oxidized']['ignore_os'])."'";
foreach (dbFetchRows("SELECT hostname,os FROM `devices` LEFT JOIN devices_attribs AS `DA` ON devices.device_id = DA.device_id AND `DA`.attrib_type='override_Oxidized_disable' WHERE `status`='1' AND (DA.attrib_value = 'false' OR DA.attrib_value IS NULL) AND (`type` NOT IN ($device_types) AND `os` NOT IN ($device_os))") as $device) {
$devices[] = $device;
}
@ -925,7 +934,7 @@ function list_bills() {
$param = array($bill_ref);
}
elseif (is_numeric($bill_id)) {
$sql = '`bill_id` = ?';
$sql = '`bills`.`bill_id` = ?';
$param = array($bill_id);
}
else {
@ -976,3 +985,109 @@ function list_bills() {
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}
function update_device() {
global $config;
$app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams();
$status = 'error';
$code = 500;
$hostname = $router['hostname'];
// use hostname as device_id if it's all digits
$device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
$data = json_decode(file_get_contents('php://input'), true);
$bad_fields = array('id','hostname');
if (empty($data['field'])) {
$message = 'Device field to patch has not been supplied';
}
elseif (in_array($data['field'], $bad_fields)) {
$message = 'Device field is not allowed to be updated';
}
else {
if (dbUpdate(array(mres($data['field']) => mres($data['data'])), 'devices', '`device_id`=?', array($device_id)) >= 0) {
$status = 'ok';
$message = 'Device ' . mres($data['field']) . ' field has been updated';
$code = 200;
}
else {
$message = 'Device ' . mres($data['field']) . ' field failed to be updated';
}
}
$output = array(
'status' => $status,
'message' => $message,
);
$app->response->setStatus($code);
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}
function get_device_groups() {
$app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams();
$status = 'error';
$code = 404;
$hostname = $router['hostname'];
// use hostname as device_id if it's all digits
$device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
if (is_numeric($device_id)) {
$groups = GetGroupsFromDevice($device_id,1);
}
else {
$groups = GetDeviceGroups();
}
if (empty($groups)) {
$message = 'No device groups found';
}
else {
$status = 'ok';
$code = 200;
$message = 'Found ' . count($groups) . ' device groups';
}
$output = array(
'status' => $status,
'message' => $message,
'count' => count($groups),
'groups' => $groups,
);
$app->response->setStatus($code);
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}
function get_devices_by_group() {
$app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams();
$status = 'error';
$code = 404;
$count = 0;
$name = urldecode($router['name']);
$devices = array();
if (empty($name)) {
$message = 'No device group name provided';
}
else {
$group_id = dbFetchCell("SELECT `id` FROM `device_groups` WHERE `name`=?",array($name));
$devices = GetDevicesFromGroup($group_id);
$count = count($devices);
if (empty($devices)) {
$message = 'No devices found in group ' . $name;
}
else {
$message = "Found $count in group $name";
$code = 200;
}
}
$output = array(
'status' => $status,
'message' => $message,
'count' => $count,
'devices' => $devices,
);
$app->response->setStatus($code);
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}

View File

@ -62,7 +62,7 @@ else {
$auth_success = 0;
if ((isset($_SESSION['username'])) || (isset($_COOKIE['sess_id'],$_COOKIE['token']))) {
if ((authenticate($_SESSION['username'], $_SESSION['password'])) || (reauthenticate($_COOKIE['sess_id'], $_COOKIE['token']))) {
if (reauthenticate($_COOKIE['sess_id'], $_COOKIE['token']) || authenticate($_SESSION['username'], $_SESSION['password'])) {
$_SESSION['userlevel'] = get_userlevel($_SESSION['username']);
$_SESSION['user_id'] = get_userid($_SESSION['username']);
if (!$_SESSION['authenticated']) {

View File

@ -0,0 +1,307 @@
<?php
// easier to rewrite for Active Directory than to bash it into existing LDAP implementation
// disable certificate checking before connect if required
if (isset($config['auth_ad_check_certificates']) &&
$config['auth_ad_check_certificates'] == 0) {
putenv('LDAPTLS_REQCERT=never');
};
$ds = @ldap_connect($config['auth_ad_url']);
// disable referrals and force ldap version to 3
ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
function authenticate($username, $password) {
global $config, $ds;
if ($username && $ds) {
// bind with sAMAccountName instead of full LDAP DN
if (ldap_bind($ds, "{$username}@{$config['auth_ad_domain']}", $password)) {
// group membership in one of the configured groups is required
if (isset($config['auth_ad_require_groupmembership']) &&
$config['auth_ad_require_groupmembership'] > 0) {
$search = ldap_search($ds, $config['auth_ad_base_dn'],
"(samaccountname={$username})", array('memberOf'));
$entries = ldap_get_entries($ds, $search);
$user_authenticated = 0;
foreach ($entries[0]['memberof'] as $entry) {
$group_cn = get_cn($entry);
if (isset($config['auth_ad_groups'][$group_cn]['level'])) {
// user is in one of the defined groups
$user_authenticated = 1;
adduser($username);
}
}
return $user_authenticated;
}
else {
// group membership is not required and user is valid
adduser($username);
return 1;
}
}
else {
return 0;
}
}
else {
echo ldap_error($ds);
}
return 0;
}
function reauthenticate() {
// not supported so return 0
return 0;
}
function passwordscanchange() {
// not supported so return 0
return 0;
}
function changepassword() {
// not supported so return 0
return 0;
}
function auth_usermanagement() {
// not supported so return 0
return 0;
}
function adduser($username) {
// Check to see if user is already added in the database
if (!user_exists_in_db($username)) {
$userid = dbInsert(array('username' => $username, 'user_id' => get_userid($username), 'level' => "0", 'can_modify_passwd' => 0, 'twofactor' => 0), 'users');
if ($userid == false) {
return false;
}
else {
foreach (dbFetchRows('select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc',array($userid)) as $notif) {
dbInsert(array('notifications_id'=>$notif['notifications_id'],'user_id'=>$userid,'key'=>'read','value'=>1),'notifications_attribs');
}
}
return $userid;
}
else {
return false;
}
}
function user_exists_in_db($username) {
$return = dbFetchCell('SELECT COUNT(*) FROM users WHERE username = ?', array($username), true);
return $return;
}
function user_exists($username) {
global $config, $ds;
$search = ldap_search($ds, $config['auth_ad_base_dn'],
"(samaccountname={$username})",array('samaccountname'));
$entries = ldap_get_entries($ds, $search);
if ($entries['count']) {
return 1;
}
return 0;
}
function get_userlevel($username) {
global $config, $ds;
$userlevel = 0;
// Find all defined groups $username is in
$search = ldap_search($ds, $config['auth_ad_base_dn'],
"(samaccountname={$username})", array('memberOf'));
$entries = ldap_get_entries($ds, $search);
// Loop the list and find the highest level
foreach ($entries[0]['memberof'] as $entry) {
$group_cn = get_cn($entry);
if ($config['auth_ad_groups'][$group_cn]['level'] > $userlevel) {
$userlevel = $config['auth_ad_groups'][$group_cn]['level'];
}
}
return $userlevel;
}
function get_userid($username) {
global $config, $ds;
$attributes = array('objectsid');
$search = ldap_search($ds, $config['auth_ad_base_dn'],
"(samaccountname={$username})", $attributes);
$entries = ldap_get_entries($ds, $search);
if ($entries['count']) {
return preg_replace('/.*-(\d+)$/','$1',sid_from_ldap($entries[0]['objectsid'][0]));
}
return -1;
}
function deluser() {
// not supported so return 0
return 0;
}
function get_userlist() {
global $config, $ds;
$userlist = array();
$userhash = array();
$ldap_groups = get_group_list();
foreach($ldap_groups as $ldap_group) {
$group_cn = get_cn($ldap_group);
$search = ldap_search($ds, $config['auth_ad_base_dn'], "(cn={$group_cn})", array('member'));
$entries = ldap_get_entries($ds, $search);
foreach($entries[0]['member'] as $member) {
$member_cn = get_cn($member);
$search = ldap_search($ds, $config['auth_ad_base_dn'], "(cn={$member_cn})",
array('sAMAccountname', 'displayName', 'objectSID', 'mail'));
$results = ldap_get_entries($ds, $search);
foreach($results as $result) {
if(isset($result['samaccountname'][0])) {
$userid = preg_replace('/.*-(\d+)$/','$1',
sid_from_ldap($result['objectsid'][0]));
// don't make duplicates, user may be member of more than one group
$userhash[$result['samaccountname'][0]] = array(
'realname' => $result['displayName'][0],
'user_id' => $userid,
'email' => $result['mail'][0]
);
}
}
}
}
foreach(array_keys($userhash) as $key) {
$userlist[] = array(
'username' => $key,
'realname' => $userhash[$key]['realname'],
'user_id' => $userhash[$key]['user_id'],
'email' => $userhash[$key]['email']
);
}
return $userlist;
}
function can_update_users() {
// not supported so return 0
return 0;
}
function get_user($user_id) {
// not supported so return 0
return 0;
}
function update_user($user_id, $realname, $level, $can_modify_passwd, $email) {
// not supported so return 0
return 0;
}
function get_fullname($username) {
global $config, $ds;
$attributes = array('name');
$result = ldap_search($ds, $config['auth_ad_base_dn'],
"(samaccountname={$username})", $attributes);
$entries = ldap_get_entries($ds, $result);
if ($entries['count'] > 0) {
$membername = $entries[0]['name'][0];
}
else {
$membername = $username;
}
return $membername;
}
function get_group_list() {
global $config;
$ldap_groups = array();
// show all Active Directory Users by default
$default_group = 'Users';
if (isset($config['auth_ad_group'])) {
if ($config['auth_ad_group'] !== $default_group) {
$ldap_groups[] = $config['auth_ad_group'];
}
}
if (!isset($config['auth_ad_groups']) && !isset($config['auth_ad_group'])) {
$ldap_groups[] = get_dn($default_group);
}
foreach ($config['auth_ad_groups'] as $key => $value) {
$ldap_groups[] = get_dn($key);
}
return $ldap_groups;
}
function get_dn($samaccountname) {
global $config, $ds;
$attributes = array('dn');
$result = ldap_search($ds, $config['auth_ad_base_dn'],
"(samaccountname={$samaccountname})", $attributes);
$entries = ldap_get_entries($ds, $result);
if ($entries['count'] > 0) {
return $entries[0]['dn'];
}
else {
return '';
}
}
function get_cn($dn) {
preg_match('/[^,]*/', $dn, $matches, PREG_OFFSET_CAPTURE, 3);
return $matches[0][0];
}
function sid_from_ldap($sid)
{
$sidHex = unpack('H*hex', $sid);
$subAuths = unpack('H2/H2/n/N/V*', $sid);
$revLevel = hexdec(substr($sidHex, 0, 2));
$authIdent = hexdec(substr($sidHex, 4, 12));
return 'S-'.$revLevel.'-'.$authIdent.'-'.implode('-', $subAuths);
}

View File

@ -44,11 +44,20 @@ function auth_usermanagement() {
}
function adduser($username, $password, $level, $email='', $realname='', $can_modify_passwd='1') {
function adduser($username, $password, $level, $email='', $realname='', $can_modify_passwd=1, $description='', $twofactor=0) {
if (!user_exists($username)) {
$hasher = new PasswordHash(8, false);
$encrypted = $hasher->HashPassword($password);
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname), 'users');
$userid = dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users');
if ($userid == false) {
return false;
}
else {
foreach (dbFetchRows('select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc',array($userid)) as $notif) {
dbInsert(array('notifications_id'=>$notif['notifications_id'],'user_id'=>$userid,'key'=>'read','value'=>1),'notifications_attribs');
}
}
return $userid;
}
else {
return false;

View File

@ -104,7 +104,16 @@ function adduser($username, $password, $level, $email='', $realname='', $can_mod
if (!user_exists($username)) {
$hasher = new PasswordHash(8, false);
$encrypted = $hasher->HashPassword($password);
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users');
$userid = dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users');
if ($userid == false) {
return false;
}
else {
foreach (dbFetchRows('select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc',array($userid)) as $notif) {
dbInsert(array('notifications_id'=>$notif['notifications_id'],'user_id'=>$userid,'key'=>'read','value'=>1),'notifications_attribs');
}
}
return $userid;
}
else {
return false;

View File

@ -0,0 +1,120 @@
<?php
require_once $config['install_dir'].'/lib/pure_php_radius/radius.class.php';
$radius = new Radius($config['radius']['hostname'], $config['radius']['secret'], $config['radius']['suffix'], $config['radius']['timeout'], $config['radius']['port']);
function authenticate($username, $password) {
global $config, $radius, $debug;
if (empty($username)) {
return 0;
}
else {
if ($debug) {
$radius->SetDebugMode(TRUE);
}
$rad = $radius->AccessRequest($username,$password);
if($rad === true) {
adduser($username);
return 1;
}
else {
return 0;
}
}
}
function reauthenticate() {
return 0;
}
function passwordscanchange() {
// not supported so return 0
return 0;
}
function changepassword() {
// not supported so return 0
return 0;
}
function auth_usermanagement() {
// not supported so return 0
return 1;
}
function adduser($username, $password, $level=1, $email='', $realname='', $can_modify_passwd=0, $description='', $twofactor=0) {
// Check to see if user is already added in the database
global $config;
if (!user_exists($username)) {
$hasher = new PasswordHash(8, false);
$encrypted = $hasher->HashPassword($password);
if ($config['radius']['default_level'] > 0) {
$level = $config['radius']['default_level'];
}
$userid = dbInsert(array('username' => $username, 'password' => $encrypted, 'realname' => $realname, 'email' => $email, 'descr' => $description, 'level' => $level, 'can_modify_passwd' => $can_modify_passwd, 'twofactor' => $twofactor), 'users');
if ($userid == false) {
return false;
}
else {
foreach (dbFetchRows('select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc',array($userid)) as $notif) {
dbInsert(array('notifications_id'=>$notif['notifications_id'],'user_id'=>$userid,'key'=>'read','value'=>1),'notifications_attribs');
}
}
return $userid;
}
else {
return false;
}
}
function user_exists($username) {
return dbFetchCell('SELECT COUNT(*) FROM users WHERE username = ?', array($username), true);
}
function get_userlevel($username) {
return dbFetchCell('SELECT `level` FROM `users` WHERE `username` = ?', array($username), true);
}
function get_userid($username) {
return dbFetchCell('SELECT `user_id` FROM `users` WHERE `username` = ?', array($username), true);
}
function deluser($username) {
dbDelete('bill_perms', '`user_name` = ?', array($username));
dbDelete('devices_perms', '`user_name` = ?', array($username));
dbDelete('ports_perms', '`user_name` = ?', array($username));
dbDelete('users_prefs', '`user_name` = ?', array($username));
dbDelete('users', '`user_name` = ?', array($username));
return dbDelete('users', '`username` = ?', array($username));
}
function get_userlist() {
return dbFetchRows('SELECT * FROM `users`');
}
function can_update_users() {
// supported so return 1
return 1;
}
function get_user($user_id) {
return dbFetchRow('SELECT * FROM `users` WHERE `user_id` = ?', array($user_id), true);
}
function update_user($user_id, $realname, $level, $can_modify_passwd, $email) {
dbUpdate(array('realname' => $realname, 'level' => $level, 'can_modify_passwd' => $can_modify_passwd, 'email' => $email), 'users', '`user_id` = ?', array($user_id));
}

View File

@ -0,0 +1,54 @@
<?php
/* Copyright (C) 2015 Daniel Preussker, QuxLabs UG <preussker@quxlabs.com>
* 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/>. */
/**
* Generic Image Widget
* @author Daniel Preussker
* @copyright 2015 Daniel Preussker, QuxLabs UG
* @license GPL
* @package LibreNMS
* @subpackage Widgets
*/
if( defined('show_settings') || empty($widget_settings) ) {
$common_output[] = '
<form class="form" onsubmit="widget_settings(this); return false;">
<div class="form-group input_'.$unique_id.'" id="input_'.$unique_id.'">
<div class="col-sm-2">
<label for="image_url" class="control-label">Title: </label>
</div>
<div class="col-sm-10">
<input type="text" class="form-control input_'.$unique_id.'" name="image_title" placeholder="Title" value="'.htmlspecialchars($widget_settings['image_title']).'">
</div>
</div>
<div class="form-group input_'.$unique_id.'" id="input_'.$unique_id.'">
<div class="col-sm-2">
<label for="image_url" class="control-label">Image URL: </label>
</div>
<div class="col-sm-10">
<input type="text" class="form-control input_'.$unique_id.'" name="image_url" placeholder="Image URL" value="'.htmlspecialchars($widget_settings['image_url']).'">
</div>
</div>
<div class="form-group">
<div class="col-sm-2">
<button type="submit" class="btn btn-default">Set</button>
</div>
</div>
</form>';
}
else {
$widget_settings['title'] = $widget_settings['image_title'];
$common_output[] = '<img class="minigraph-image" width="'.$widget_dimensions['x'].'" height="'.$widget_dimensions['y'].'" src="'.$widget_settings['image_url'].'"/>';
}

View File

@ -0,0 +1,39 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2015 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
if( defined('show_settings') || empty($widget_settings) ) {
$common_output[] = '
<form class="form-horizontal" onsubmit="widget_settings(this); return false;">
<div class="form-group">
<div class="col-sm-12">
html is supported here. If you want just text then wrap in &lt;pre&gt;&lt;/pre&gt;
</div>
</div>
<div class="form-group">
<label for="'.$unique_id.'_notes" class="col-sm-1" control-label"></label>
<div class="col-sm-11">
<textarea name="notes" id="'.$unique_id.'_notes" rows="3" class="form-control">'.htmlspecialchars($widget_settings['notes']).'</textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-1">
<button type="submit" class="btn btn-sm btn-primary">Set</button>
</div>
</div>
</form>';
}
else {
$common_output[] = stripslashes(nl2br($widget_settings['notes']));
}

View File

@ -30,7 +30,7 @@ if ($config['map']['engine'] == 'leaflet') {
<div class="col-sm-4">
<label for="init_lat" class="control-label">Initial Latitude: </label>
</div>
<div class="col-sm-6">
<div class="col-sm-8">
<input class="form-control" name="init_lat" id="input_lat_'.$unique_id.'" value="'.$widget_settings['init_lat'].'" placeholder="ie. 51.4800 for Greenwich">
</div>
</div>
@ -46,7 +46,7 @@ if ($config['map']['engine'] == 'leaflet') {
<div class="col-sm-4">
<label for="init_zoom" class="control-label">Initial Zoom: </label>
</div>
<div class="col-sm-6">
<div class="col-sm-8">
<select class="form-control" name="init_zoom" id="select_zoom'.$unique_id.'">
';
for ($i=0; $i<19; $i++) {
@ -65,10 +65,35 @@ if ($config['map']['engine'] == 'leaflet') {
<div class="col-sm-4">
<label for="group_radius" class="control-label">Grouping radius: </label>
</div>
<div class="col-sm-4">
<div class="col-sm-8">
<input class="form-control" name="group_radius" id="input_radius_'.$unique_id.'" value="'.$widget_settings['group_radius'].'" placeholder="default 80">
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<label for="status" class="control-label">Show devices: </label>
</div>
<div class="col-sm-8">
<select class="form-control" name="status" id="status_'.$unique_id.'">';
$temp_output .= '<option value="0,1"';
if ($widget_settings['status'] == '0,1') {
$temp_output .= ' selected';
}
$temp_output .= '>Up + Down</option>
<option value="1"';
if ($widget_settings['status'] == '1') {
$temp_output .= ' selected';
}
$temp_output .= '>Up</option>
<option value="0"';
if ($widget_settings['status'] == '0') {
$temp_output .= ' selected';
}
$temp_output .= '>Down</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-2">
<button type="submit" class="btn btn-default">Set</button>
@ -101,6 +126,9 @@ if ($config['map']['engine'] == 'leaflet') {
else {
$group_radius = 80;
}
if (empty($widget_settings['status']) && $widget_settings['status'] != '0') {
$widget_settings['status'] = '0,1';
}
$map_init = "[" . $init_lat . ", " . $init_lng . "], " . sprintf("%01.0f", $init_zoom);
$temp_output .= 'var map = L.map(\'leaflet-map\').setView('.$map_init.');
L.tileLayer(\'//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\', {
@ -109,6 +137,17 @@ L.tileLayer(\'//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\', {
var markers = L.markerClusterGroup({
maxClusterRadius: ' . $group_radius . ',
iconCreateFunction: function (cluster) {
var markers = cluster.getAllChildMarkers();
var n = 0;
newClass = "greenCluster marker-cluster marker-cluster-small leaflet-zoom-animated leaflet-clickable";
for (var i = 0; i < markers.length; i++) {
if (markers[i].options.icon.options.markerColor == "red") {
newClass = "redCluster marker-cluster marker-cluster-small leaflet-zoom-animated leaflet-clickable";
}
}
return L.divIcon({ html: cluster.getChildCount(), className: newClass, iconSize: L.point(40, 40) });
},
});
var redMarker = L.AwesomeMarkers.icon({
icon: \'server\',
@ -122,24 +161,31 @@ var greenMarker = L.AwesomeMarkers.icon({
// Checking user permissions
if (is_admin() || is_read()) {
// Admin or global read-only - show all devices
$sql = "SELECT DISTINCT(`device_id`),`hostname`,`os`,`status`,`lat`,`lng` FROM `devices`
$sql = "SELECT DISTINCT(`device_id`),`devices`.`location`,`hostname`,`os`,`status`,`lat`,`lng` FROM `devices`
LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location`
WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != ''
WHERE `disabled`=0 AND `ignore`=0 AND ((`lat` != '' AND `lng` != '') OR (`devices`.`location` REGEXP '\[[0-9\.\, ]+\]'))
AND `status` IN (".$widget_settings['status'].")
ORDER BY `status` ASC, `hostname`";
}
else {
// Normal user - grab devices that user has permissions to
$sql = "SELECT DISTINCT(`devices`.`device_id`) as `device_id`,`hostname`,`os`,`status`,`lat`,`lng`
$sql = "SELECT DISTINCT(`devices`.`device_id`) as `device_id`,`devices`.`location`,`hostname`,`os`,`status`,`lat`,`lng`
FROM `devices_perms`, `devices`
LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location`
WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != ''
WHERE `disabled`=0 AND `ignore`=0 AND ((`lat` != '' AND `lng` != '') OR (`devices`.`location` REGEXP '\[[0-9\.\, ]+\]'))
AND `devices`.`device_id` = `devices_perms`.`device_id`
AND `devices_perms`.`user_id` = ?
AND `devices_perms`.`user_id` = ? AND `status` IN (".$widget_settings['status'].")
ORDER BY `status` ASC, `hostname`";
$param[] = $_SESSION['user_id'];
}
foreach (dbFetchRows($sql, array($_SESSION['user_id'])) as $map_devices) {
foreach (dbFetchRows($sql, $param) as $map_devices) {
$icon = 'greenMarker';
$z_offset = 0;
$tmp_loc = parse_location($map_devices['location']);
if (!empty($tmp_loc['lat']) && !empty($tmp_loc['lng'])) {
$map_devices['lat'] = $tmp_loc['lat'];
$map_devices['lng'] = $tmp_loc['lng'];
}
if ($map_devices['status'] == 0) {
$icon = 'redMarker';
$z_offset = 10000; // move marker to foreground

View File

@ -78,7 +78,10 @@ if ($device['location']) {
}
}
$loc = dbFetchRow("SELECT `lat`,`lng` FROM `locations` WHERE `location`=? LIMIT 1", array($device['location']));
$loc = parse_location($device['location']);
if (!is_array($loc)) {
$loc = dbFetchRow("SELECT `lat`,`lng` FROM `locations` WHERE `location`=? LIMIT 1", array($device['location']));
}
if (is_array($loc)) {
echo '<tr>
<td>Lat / Lng</td>

View File

@ -24,9 +24,9 @@ $image = getImage($device);
echo '
<tr bgcolor="'.$device_colour.'" class="alert '.$class.'">
<td width="40" align=center valign=middle style="padding: 21px;">'.$image.'</td>
<td width="40" align=center valign=middle style="padding: 21px;"><span class="device_icon">'.$image.'</span></td>
<td valign=middle style="padding: 0 15px;"><span style="font-size: 20px;">'.generate_device_link($device).'</span>
<br />'.$device['location'].'</td>
<br />'.generate_link($device['location'], array('page' => 'devices', 'location' => $device['location'])).'</td>
<td>';
if (isset($config['os'][$device['os']]['over'])) {

View File

@ -30,10 +30,13 @@ $config_extra = mres($_POST['config_extra']);
$config_room_id = mres($_POST['config_room_id']);
$config_from = mres($_POST['config_from']);
$config_userkey = mres($_POST['config_userkey']);
$config_user = mres($_POST['config_user']);
$config_to = mres($_POST['config_to']);
$config_token = mres($_POST['config_token']);
$status = 'error';
$message = 'Error with config';
if ($action == 'remove' || $action == 'remove-slack' || $action == 'remove-hipchat' || $action == 'remove-pushover' || $action == 'remove-boxcar') {
if ($action == 'remove' || $action == 'remove-slack' || $action == 'remove-hipchat' || $action == 'remove-pushover' || $action == 'remove-boxcar' || $action == 'remove-clickatell' || $action == 'remove-playsms') {
$config_id = mres($_POST['config_id']);
if (empty($config_id)) {
$message = 'No config id passed';
@ -52,6 +55,12 @@ if ($action == 'remove' || $action == 'remove-slack' || $action == 'remove-hipch
elseif ($action == 'remove-boxcar') {
dbDelete('config', "`config_name` LIKE 'alert.transports.boxcar.$config_id.%'");
}
elseif ($action == 'remove-clickatell') {
dbDelete('config', "`config_name` LIKE 'alert.transports.clickatell.$config_id.%'");
}
elseif ($action == 'remove-playsms') {
dbDelete('config', "`config_name` LIKE 'alert.transports.playsms.$config_id.%'");
}
$status = 'ok';
$message = 'Config item removed';
@ -156,6 +165,66 @@ else if ($action == 'add-boxcar') {
}
}
}
else if ($action == 'add-clickatell') {
if (empty($config_value)) {
$message = 'No Clickatell token provided';
}
elseif (empty($config_to)) {
$message = 'No mobile numbers provided';
}
else {
$config_id = dbInsert(array('config_name' => 'alert.transports.clickatell.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_value, 'config_descr' => 'Clickatell Transport'), 'config');
if ($config_id > 0) {
dbUpdate(array('config_name' => 'alert.transports.clickatell.'.$config_id.'.token'), 'config', 'config_id=?', array($config_id));
$status = 'ok';
$message = 'Config item created';
$mobiles = explode('\n', $config_to);
$x=0;
foreach ($mobiles as $mobile) {
if (!empty($mobile)) {
dbInsert(array('config_name' => 'alert.transports.clickatell.'.$config_id.'.to.'.$x, 'config_value' => $mobile, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $v, 'config_descr' => 'Clickatell mobile'), 'config');
$x++;
}
}
}
else {
$message = 'Could not create config item';
}
}
}
elseif ($action == 'add-playsms') {
if (empty($config_value)) {
$message = 'No PlaySMS URL provided';
}
elseif (empty($config_user)) {
$message = 'No PlaySMS User provided';
}
elseif (empty($config_to)) {
$message = 'No mobile numbers provided';
}
else {
$config_id = dbInsert(array('config_name' => 'alert.transports.playsms.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_value, 'config_descr' => 'PlaySMS Transport'), 'config');
if ($config_id > 0) {
dbUpdate(array('config_name' => 'alert.transports.playsms.'.$config_id.'.url'), 'config', 'config_id=?', array($config_id));
$additional_id['from'] = dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.from', 'config_value' => $config_from, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_from, 'config_descr' => 'PlaySMS From'), 'config');
$additional_id['user'] = dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.user', 'config_value' => $config_user, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_user, 'config_descr' => 'PlaySMS User'), 'config');
$additional_id['token'] = dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.token', 'config_value' => $config_token, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_token, 'config_descr' => 'PlaySMS Token'), 'config');
$status = 'ok';
$message = 'Config item created';
$mobiles = explode('\n', $config_to);
$x=0;
foreach ($mobiles as $mobile) {
if (!empty($mobile)) {
dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.to.'.$x, 'config_value' => $mobile, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $v, 'config_descr' => 'PlaySMS mobile'), 'config');
$x++;
}
}
}
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';

View File

@ -0,0 +1,56 @@
<?php
/* Copyright (C) 2015 Daniel Preussker, QuxLabs UG <preussker@quxlabs.com>
* 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/>. */
/**
* Notification Page
* @author Daniel Preussker
* @copyright 2015 Daniel Preussker, QuxLabs UG
* @license GPL
* @package LibreNMS
* @subpackage Notifications
*/
$status = 'error';
$message = 'unknown error';
if (isset($_REQUEST['notification_id']) && isset($_REQUEST['action'])) {
if ($_REQUEST['action'] == 'read' && dbInsert(array('notifications_id'=>$_REQUEST['notification_id'],'user_id'=>$_SESSION['user_id'],'key'=>'read','value'=>1),'notifications_attribs')) {
$status = 'ok';
$message = 'Set as Read';
}
elseif ($_SESSION['userlevel'] == 10 && $_REQUEST['action'] == 'stick' && dbInsert(array('notifications_id'=>$_REQUEST['notification_id'],'user_id'=>$_SESSION['user_id'],'key'=>'sticky','value'=>1),'notifications_attribs')) {
$status = 'ok';
$message = 'Set as Sticky';
}
elseif ($_SESSION['userlevel'] == 10 && $_REQUEST['action'] == 'unstick' && dbUpdate(array('key'=>'sticky','value'=>0),'notifications_attribs','notifications_id = ? && user_id = ?',array($_REQUEST['notification_id'],$_SESSION['user_id']))) {
$status = 'ok';
$message = 'Removed Sticky';
}
}
elseif ($_REQUEST['action'] == 'create' && $_SESSION['userlevel'] == 10 && (isset($_REQUEST['title']) && isset($_REQUEST['body']))) {
if (dbInsert(array('title'=>$_REQUEST['title'],'body'=>$_REQUEST['body'],'checksum'=>hash('sha512',$_SESSION['user_id'].'.LOCAL.'.$_REQUEST['title']),'source'=>$_SESSION['user_id']),'notifications')) {
$status = 'ok';
$message = 'Created';
}
}
else {
$status = 'error';
$message = 'ERROR: Missing Params';
}
die(json_encode(array(
'status' => $status,
'message' => $message,
)));

View File

@ -0,0 +1,32 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2015 Søren Friis Rosiak <sorenrosiak@gmail.com>
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
$status = 'error';
$message = 'unknown error';
$data_param = mres($_POST['data_param']);
$query_param = mres($_POST['query_param']);
if (isset($data_param) && isset($query_param)) {
$status = 'ok';
$message = 'Queried';
$output = get_ripe_api_whois_data_json($data_param, $query_param);
}
else {
$status = 'error';
$message = 'ERROR: Could not query';
}
die(json_encode(array(
'status' => $status,
'message' => $message,
'data_param' => $data_param,
'query_param' => $query_param,
'output' => $output
)));

View File

@ -25,23 +25,32 @@ $status = 'error';
if (!is_numeric($config_id)) {
$message = 'ERROR: No config item';
}
else if ($action == 'update-textarea') {
elseif ($action == 'update-textarea') {
$extras = explode(PHP_EOL, $_POST['config_value']);
$x=0;
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');
}
else if ($config_type == 'hipchat') {
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');
}
else if ($config_type == 'pushover') {
elseif ($config_type == 'pushover') {
$db_id[] = dbInsert(array('config_name' => 'alert.transports.pushover.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Pushover Transport'), 'config');
}
elseif ($config_type == 'boxcar') {
$db_id[] = dbInsert(array('config_name' => 'alert.transports.boxcar.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Boxcar Transport'), 'config');
}
elseif ($config_type == 'clickatell') {
$db_id[] = dbInsert(array('config_name' => 'alert.transports.clickatell.to.'.$x, 'config_value' => $k, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Clickatell Transport'), 'config');
$x++;
}
elseif ($config_type == 'playsms') {
$db_id[] = dbInsert(array('config_name' => 'alert.transports.playsms.to.'.$x, 'config_value' => $k, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'PlaySMS Transport'), 'config');
$x++;
}
}
}
@ -54,15 +63,21 @@ else if ($action == 'update-textarea') {
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))");
}
else if ($config_type == 'hipchat') {
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))");
}
else if ($config_type == 'pushover') {
elseif ($config_type == 'pushover') {
dbDelete('config', "(`config_name` LIKE 'alert.transports.pushover.$config_id.%' AND (`config_name` != 'alert.transports.pushover.$config_id.appkey' AND `config_name` != 'alert.transports.pushover.$config_id.userkey') AND `config_id` NOT IN ($db_inserts))");
}
else if ($config_type == 'boxcar') {
elseif ($config_type == 'boxcar') {
dbDelete('config', "(`config_name` LIKE 'alert.transports.boxcar.$config_id.%' AND (`config_name` != 'alert.transports.boxcar.$config_id.access_token' AND `config_name` != 'alert.transports.boxcar.$config_id.userkey') AND `config_id` NOT IN ($db_inserts))");
}
elseif ($config_type == 'clickatell') {
dbDelete('config', "(`config_name` LIKE 'alert.transports.clickatell.to.%' AND `config_id` NOT IN ($db_inserts))");
}
elseif ($config_type == 'playsms') {
dbDelete('config', "(`config_name` LIKE 'alert.transports.playsms.to.%' AND `config_id` NOT IN ($db_inserts))");
}
}
$message = 'Config item has been updated:';

View File

@ -461,6 +461,7 @@ function generate_graph_tag($args) {
}//end generate_graph_tag()
function generate_lazy_graph_tag($args) {
global $config;
$urlargs = array();
$w = 0;
$h = 0;
@ -476,7 +477,12 @@ function generate_lazy_graph_tag($args) {
$urlargs[] = $key."=".urlencode($arg);
}
return '<img class="lazy" width="'.$w.'" height="'.$h.'" data-original="graph.php?' . implode('&amp;',$urlargs).'" border="0" />';
if ($config['enable_lazy_load'] === true) {
return '<img class="lazy graphs" width="'.$w.'" height="'.$h.'" data-original="graph.php?' . implode('&amp;',$urlargs).'" border="0" />';
}
else {
return '<img class="graphs" width="'.$w.'" height="'.$h.'" src="graph.php?' . implode('&amp;',$urlargs).'" border="0" />';
}
}//end generate_lazy_graph_tag()
@ -1097,7 +1103,7 @@ 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;
$items[$config_item['config_id']] = $config_item;
}
return $items;
@ -1178,6 +1184,9 @@ function dynamic_override_config($type, $name, $device) {
if ($type == 'checkbox') {
return '<input type="checkbox" id="override_config" name="override_config" data-attrib="'.$name.'" data-device_id="'.$device['device_id'].'" data-size="small" '.$checked.'>';
}
elseif ($type == 'text') {
return '<input type="text" id="override_config_text" name="override_config_text" data-attrib="'.$name.'" data-device_id="'.$device['device_id'].'" value="'.$attrib_val.'">';
}
}//end dynamic_override_config()
function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$items=array(),$transport='') {
@ -1186,7 +1195,7 @@ function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$it
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#'.$anchor.'">'.$title.'</a>
<a data-toggle="collapse" data-parent="#accordion" href="#'.$anchor.'"><i class="fa fa-caret-down"></i> '.$title.'</a>
';
if (!empty($transport)) {
$output .= '<button name="test-alert" id="test-alert" type="button" data-transport="'.$transport.'" class="btn btn-primary btn-xs pull-right">Test transport</button>';
@ -1249,3 +1258,9 @@ function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$it
}
return $output;
}//end generate_dynamic_config_panel()
function get_ripe_api_whois_data_json($ripe_data_param, $ripe_query_param) {
$ripe_whois_url = 'https://stat.ripe.net/data/'. $ripe_data_param . '/data.json?resource=' . $ripe_query_param;
return json_decode(file_get_contents($ripe_whois_url) , true);
}//end get_ripe_api_whois_data_json()

View File

@ -39,7 +39,7 @@ $rrd_options .= ' GPRINT:availreal:LAST:\ \ \ %7.2lf%sB';
$rrd_options .= ' GPRINT:availreal:AVERAGE:%7.2lf%sB';
$rrd_options .= " GPRINT:availreal:MAX:%7.2lf%sB\\\\n";
$rrd_options .= ' LINE1:usedreal#d0b080:';
$rrd_options .= ' AREA:shared#afeced::';
$rrd_options .= ' AREA:shared#afeced:';
$rrd_options .= ' AREA:buffered#cc0000::STACK';
$rrd_options .= ' AREA:cached#ffaa66::STACK';
$rrd_options .= ' LINE1.25:shared#008fea:shared';

View File

@ -0,0 +1,25 @@
<?php
$ds_in = 'apply_ms';
$ds_out = 'commit_ms';
$in_text = 'Apply';
$out_text = 'Commit';
$ceph_osd_rrd = ceph_rrd('osd');
if (is_file($ceph_osd_rrd)) {
$rrd_filename = $ceph_osd_rrd;
}
$colour_area_in = 'FF3300';
$colour_line_in = 'FF0000';
$colour_area_out = 'FF6633';
$colour_line_out = 'CC3300';
$colour_area_in_max = 'FF6633';
$colour_area_out_max = 'FF9966';
$unit_text = 'Miliseconds';
require 'includes/graphs/generic_duplex.inc.php';

View File

@ -0,0 +1,56 @@
<?php
require 'includes/graphs/common.inc.php';
$ceph_pool_rrd = ceph_rrd('df');
if (is_file($ceph_pool_rrd)) {
$rrd_filename = $ceph_pool_rrd;
}
$rrd_options .= ' -l 0 -b 1024 ';
$rrd_options .= " 'COMMENT:Bytes Min Cur Max\\n'";
$usedc = 'CC0000';
$availc = '008C00';
$totalc = 'e5e5e5';
if ($vars['pool'] != "c") {
$rrd_options .= " DEF:poolfree=$rrd_filename:avail:AVERAGE ";
$rrd_options .= " DEF:poolused=$rrd_filename:used:AVERAGE ";
$rrd_options .= " CDEF:pooltotal=poolused,poolfree,+ ";
$rrd_options .= " LINE1:poolused#".$usedc;
$rrd_options .= " LINE1:poolfree#".$availc.'::STACK';
$rrd_options .= " AREA:poolused#".$usedc.'30:Used ';
$rrd_options .= " GPRINT:poolused:MIN:%7.2lf%sB";
$rrd_options .= ' GPRINT:poolused:LAST:%7.2lf%sB';
$rrd_options .= ' GPRINT:poolused:MAX:%7.2lf%sB\n';
$rrd_options .= " AREA:poolfree#".$availc.'30:Free:STACK';
$rrd_options .= " GPRINT:poolfree:MIN:%7.2lf%sB";
$rrd_options .= ' GPRINT:poolfree:LAST:%7.2lf%sB';
$rrd_options .= ' GPRINT:poolfree:MAX:%7.2lf%sB\n';
$rrd_options .= " LINE1:pooltotal#000000:Total";
$rrd_options .= " GPRINT:pooltotal:MIN:%6.2lf%sB";
$rrd_options .= " GPRINT:pooltotal:LAST:%7.2lf%sB";
$rrd_options .= ' GPRINT:pooltotal:MAX:%7.2lf%sB\n';
} else {
$rrd_options .= " DEF:poolsize=$rrd_filename:avail:AVERAGE ";
$rrd_options .= " DEF:poolused=$rrd_filename:used:AVERAGE ";
$rrd_options .= " DEF:poolfree=$rrd_filename:objects:AVERAGE ";
$rrd_options .= " LINE1:poolused#".$usedc;
$rrd_options .= " AREA:poolused#".$usedc.'30:Used';
$rrd_options .= " GPRINT:poolused:MIN:%7.2lf%sB";
$rrd_options .= ' GPRINT:poolused:LAST:%7.2lf%sB';
$rrd_options .= ' GPRINT:poolused:MAX:%7.2lf%sB\n';
$rrd_options .= " AREA:poolfree#".$availc.'30:Free:STACK';
$rrd_options .= " GPRINT:poolfree:MIN:%7.2lf%sB";
$rrd_options .= ' GPRINT:poolfree:LAST:%7.2lf%sB';
$rrd_options .= ' GPRINT:poolfree:MAX:%7.2lf%sB\n';
$rrd_options .= " LINE1:poolsize#000000:Total";
$rrd_options .= " GPRINT:poolsize:MIN:%6.2lf%sB";
$rrd_options .= ' GPRINT:poolsize:LAST:%7.2lf%sB';
$rrd_options .= ' GPRINT:poolsize:MAX:%7.2lf%sB\n';
}

View File

@ -0,0 +1,26 @@
<?php
$ds_in = 'rbytes';
$in_text = 'Read';
$ds_out = 'wrbytes';
$out_text = 'Write';
$format = 'bytes';
$ceph_pool_rrd = ceph_rrd('pool');
if (is_file($ceph_pool_rrd)) {
$rrd_filename = $ceph_pool_rrd;
}
$colour_area_in = 'FF3300';
$colour_line_in = 'FF0000';
$colour_area_out = 'FF6633';
$colour_line_out = 'CC3300';
$colour_area_in_max = 'FF6633';
$colour_area_out_max = 'FF9966';
$unit_text = 'Bytes I/O';
require 'includes/graphs/generic_duplex.inc.php';

View File

@ -0,0 +1,24 @@
<?php
$scale_min = 0;
require 'includes/graphs/common.inc.php';
$ceph_pool_rrd = ceph_rrd('pool');
if (is_file($ceph_pool_rrd)) {
$rrd_filename = $ceph_pool_rrd;
}
$ds = 'ops';
$colour_area = 'EEEEEE';
$colour_line = '36393D';
$colour_area_max = 'FFEE99';
$graph_max = 1;
$unit_text = 'Operations';
require 'includes/graphs/generic_simplex.inc.php';

View File

@ -0,0 +1,22 @@
<?php
$scale_min = 0;
require 'includes/graphs/common.inc.php';
$ceph_pool_rrd = ceph_rrd('df');
if (is_file($ceph_pool_rrd)) {
$rrd_filename = $ceph_pool_rrd;
}
$ds = 'objects';
$colour_area = 'EEEEEE';
$colour_line = '36393D';
$colour_area_max = 'FFEE99';
$unit_text = 'Objects';
require 'includes/graphs/generic_simplex.inc.php';

View File

@ -53,14 +53,14 @@ else {
foreach ($rrd_list as $rrd) {
$colours = (isset($rrd['colour']) ? $rrd['colour'] : 'default');
$strlen = ((strlen($rrd['descr']) < $descr_len) ? ($descr_len - strlen($rrd['descr'])) : '0');
$descr = (isset($rrd['descr']) ? rrdtool_escape($rrd['descr'], ($desc_len + $strlen)) : 'Unkown');
$descr = (isset($rrd['descr']) ? rrdtool_escape($rrd['descr'], ($desc_len + $strlen)) : 'Unknown');
for ($z = 0; $z < $strlen;
$z++) {
$descr .= ' ';
}
if ($i) {
$stack = 'STACK';
$stack = ':STACK';
}
$colour = $config['graph_colours'][$colours][$x];
@ -68,7 +68,7 @@ foreach ($rrd_list as $rrd) {
$rrd_options .= ' DEF:peak'.$x.'='.$rrd['filename'].':peak:MAX';
$rrd_options .= ' DEF:unique'.$x.'='.$rrd['filename'].':unique:AVERAGE';
$rrd_options .= ' VDEF:avg'.$x.'=cur'.$x.',AVERAGE';
$rrd_options .= ' AREA:cur'.$x.'#'.$colour.':"'.$descr."\":$stack";
$rrd_options .= ' AREA:cur'.$x.'#'.$colour.":'".$descr."'$stack";
$rrd_options .= ' GPRINT:cur'.$x.':LAST:"%6.2lf"';
$rrd_options .= ' GPRINT:unique'.$x.':LAST:"%6.2lf%s"';
$rrd_options .= ' GPRINT:avg'.$x.':"%6.2lf"';
@ -97,7 +97,7 @@ if (!$nototal) {
$rrd_options .= ' CDEF:totunique=unique0'.$totunique;
$rrd_options .= ' CDEF:totpeak=peak0'.$totpeak;
$rrd_options .= ' VDEF:totavg=totcur,AVERAGE';
$rrd_options .= ' LINE2:totcur#'.$colour.':"'.$descr.'"';
$rrd_options .= ' LINE2:totcur#'.$colour.":'".$descr."'";
$rrd_options .= ' GPRINT:totcur:LAST:"%6.2lf"';
$rrd_options .= ' GPRINT:totunique:LAST:"%6.2lf%s"';
$rrd_options .= ' GPRINT:totavg:"%6.2lf"';

View File

@ -46,7 +46,7 @@ foreach (dbFetchRows('SELECT * FROM `mempools` where `device_id` = ?', array($de
$rrd_optionsb .= " LINE1:mempooltotal$i#".$colour.":'".$descr."' ";
$rrd_optionsb .= " GPRINT:mempooltotal$i:MIN:%3.0lf%%";
$rrd_optionsb .= " GPRINT:mempooltotal$i:LAST:%3.0lf%%";
$rrd_optionsb .= " GPRINT:mempooltotal$i:MAX:%3.0lf%%\\\l ";
$rrd_optionsb .= " GPRINT:mempooltotal$i:MAX:%3.0lf%%\\l ";
$iter++;
$i++;
}

View File

@ -37,6 +37,7 @@ foreach ($smokeping_files[$direction][$device['hostname']] as $source => $filena
$colour = $config['graph_colours'][$colourset][$iter];
$iter++;
// FIXME: $descr unused? -- PDG 2015-11-14
$descr = rrdtool_escape($source, $descr_len);
$filename = generate_smokeping_file($device,$filename);

View File

@ -42,6 +42,6 @@ foreach (dbFetchRows('SELECT * FROM storage where device_id = ?', array($device[
$rrd_options .= " LINE1.25:$storage[storage_id]perc#".$colour.":'$descr'";
$rrd_options .= " GPRINT:$storage[storage_id]size:LAST:%6.2lf%sB";
$rrd_options .= " GPRINT:$storage[storage_id]used:LAST:%6.2lf%sB";
$rrd_options .= " GPRINT:$storage[storage_id]perc:LAST:%5.2lf%%\\\\l";
$rrd_options .= " GPRINT:$storage[storage_id]perc:LAST:%5.2lf%%\\l";
$iter++;
}//end foreach

View File

@ -14,12 +14,12 @@ $rrd_options .= ' CDEF:b=5min,100,/';
$rrd_options .= ' CDEF:c=15min,100,/';
$rrd_options .= ' CDEF:cdefd=a,b,c,+,+';
$rrd_options .= " COMMENT:'Load Average Current Average Maximum\\n'";
$rrd_options .= " AREA:a#ffeeaa:'1 Min':";
$rrd_options .= " AREA:a#ffeeaa:'1 Min'";
$rrd_options .= ' LINE1:a#c5aa00:';
$rrd_options .= " GPRINT:a:LAST:' %7.2lf'";
$rrd_options .= " GPRINT:a:AVERAGE:' %7.2lf'";
$rrd_options .= " GPRINT:a:MAX:' %7.2lf\\n'";
$rrd_options .= " LINE1.25:b#ea8f00:'5 Min':";
$rrd_options .= " LINE1.25:b#ea8f00:'5 Min'";
$rrd_options .= " GPRINT:b:LAST:' %7.2lf'";
$rrd_options .= " GPRINT:b:AVERAGE:' %7.2lf'";
$rrd_options .= " GPRINT:b:MAX:' %7.2lf\\n'";

View File

@ -73,7 +73,7 @@ $rrd_options .= " 'COMMENT: \\n'";
$rrd_options .= " 'LINE1:usedreal#d0b080:'";
$rrd_options .= " 'AREA:shared#afeced::'";
$rrd_options .= " 'AREA:shared#afeced:'";
$rrd_options .= " 'AREA:buffered#cc0000::STACK'";
$rrd_options .= " 'AREA:cached#ffaa66::STACK'";

View File

@ -87,7 +87,7 @@ $rrd_options .= ' VDEF:tot=octets,TOTAL';
$rrd_options .= ' VDEF:95thin=inbits,95,PERCENT';
$rrd_options .= ' VDEF:95thout=outbits,95,PERCENT';
$rrd_options .= ' VDEF:d95thout=doutbits,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutn=doutbits,-1,* VDEF:d95thoutn95=d95thoutn,95,PERCENT CDEF:d95thoutn95n=doutbits,doutbits,-,d95thoutn95,-1,*,+ VDEF:d95thout=d95thoutn95n,FIRST';
if ($format == 'octets' || $format == 'bytes') {
$units = 'Bps';
@ -107,7 +107,7 @@ $rrd_options .= ' LINE:in'.$format."#608720:'In '";
$rrd_options .= ' GPRINT:in'.$format.':LAST:%6.2lf%s';
$rrd_options .= ' GPRINT:in'.$format.':AVERAGE:%6.2lf%s';
$rrd_options .= ' GPRINT:in'.$format.'_max:MAX:%6.2lf%s';
$rrd_options .= " GPRINT:95thin:%6.2lf%s\\\\n";
$rrd_options .= " GPRINT:95thin:%6.2lf%s\\n";
$rrd_options .= ' AREA:dout'.$format.'_max#E0E0FF:';
$rrd_options .= ' AREA:dout'.$format.'#8080C0:';
@ -116,7 +116,7 @@ $rrd_options .= ' LINE:dout'.$format."#606090:'Out'";
$rrd_options .= ' GPRINT:out'.$format.':LAST:%6.2lf%s';
$rrd_options .= ' GPRINT:out'.$format.':AVERAGE:%6.2lf%s';
$rrd_options .= ' GPRINT:out'.$format.'_max:MAX:%6.2lf%s';
$rrd_options .= " GPRINT:95thout:%6.2lf%s\\\\n";
$rrd_options .= " GPRINT:95thout:%6.2lf%s\\n";
if ($config['rrdgraph_real_95th']) {
$rrd_options .= ' HRULE:95thhigh#FF0000:"Highest"';
@ -125,7 +125,7 @@ if ($config['rrdgraph_real_95th']) {
$rrd_options .= " GPRINT:tot:'Total %6.2lf%s'";
$rrd_options .= " GPRINT:totin:'(In %6.2lf%s'";
$rrd_options .= " GPRINT:totout:'Out %6.2lf%s)\\\\l'";
$rrd_options .= " GPRINT:totout:'Out %6.2lf%s)\\l'";
$rrd_options .= ' LINE1:95thin#aa0000';
$rrd_options .= ' LINE1:d95thout#aa0000';

View File

@ -11,7 +11,7 @@ else {
}
if ($nototal) {
$descrlen += '2';
$descr_len += '2';
$unitlen += '2';
}
@ -57,16 +57,16 @@ foreach ($rrd_list as $rrd) {
if ($rrd['invert']) {
$rrd_options .= ' CDEF:'.$id.'i='.$id.',-1,*';
$rrd_optionsc .= ' AREA:'.$id.'i#'.$colour.":'$descr':".$cstack;
$rrd_optionsc .= ' AREA:'.$id.'i#'.$colour.":'$descr'".$cstack;
$rrd_optionsc .= ' GPRINT:'.$id.':LAST:%5.1lf%s GPRINT:'.$id.'min:MIN:%5.1lf%s';
$rrd_optionsc .= ' GPRINT:'.$id.'max:MAX:%5.1lf%s GPRINT:'.$id.":AVERAGE:'%5.1lf%s\\n'";
$cstack = 'STACK';
$cstack = ':STACK';
}
else {
$rrd_optionsb .= ' AREA:'.$id.'#'.$colour.":'$descr':".$bstack;
$rrd_optionsb .= ' AREA:'.$id.'#'.$colour.":'$descr'".$bstack;
$rrd_optionsb .= ' GPRINT:'.$id.':LAST:%5.1lf%s GPRINT:'.$id.'min:MIN:%5.1lf%s';
$rrd_optionsb .= ' GPRINT:'.$id.'max:MAX:%5.1lf%s GPRINT:'.$id.":AVERAGE:'%5.1lf%s\\n'";
$bstack = 'STACK';
$bstack = ':STACK';
}
$i++;

View File

@ -57,7 +57,7 @@ if ($i) {
$rrd_options .= ' CDEF:doutbits=doutoctets,8,*';
$rrd_options .= ' VDEF:95thin=inbits,95,PERCENT';
$rrd_options .= ' VDEF:95thout=outbits,95,PERCENT';
$rrd_options .= ' VDEF:d95thout=doutbits,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutn=doutbits,-1,* VDEF:d95thoutn95=d95thoutn,95,PERCENT CDEF:d95thoutn95n=doutbits,doutbits,-,d95thoutn95,-1,*,+ VDEF:d95thout=d95thoutn95n,FIRST';
if ($_GET['previous'] == 'yes') {
$rrd_options .= ' CDEF:'.$in.'octetsX='.$in_thingX.$pluses;
@ -68,7 +68,7 @@ if ($i) {
$rrd_options .= ' CDEF:doutbitsX=doutoctetsX,8,*';
$rrd_options .= ' VDEF:95thinX=inbitsX,95,PERCENT';
$rrd_options .= ' VDEF:95thoutX=outbitsX,95,PERCENT';
$rrd_options .= ' VDEF:d95thoutX=doutbitsX,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutXn=doutbitsX,-1,* VDEF:d95thoutXn95=d95thoutXn,95,PERCENT CDEF:d95thoutXn95n=doutbitsX,doutbitsX,-,d95thoutXn95,-1,*,+ VDEF:d95thoutX=d95thoutXn95n,FIRST';
}
if ($legend == 'no' || $legend == '1') {

View File

@ -49,9 +49,6 @@ foreach ($rrd_list as $rrd) {
}
$descr_out = rrdtool_escape($rrd['descr_out'], $descr_len).' Out';
$descr = str_replace("'", '', $descr);
// FIXME does this mean ' should be filtered in rrdtool_escape? probably...
$descr_out = str_replace("'", '', $descr_out);
}
$rrd_options .= ' DEF:'.$in.$i.'='.$rrd['filename'].':'.$ds_in.':AVERAGE ';
@ -68,10 +65,10 @@ foreach ($rrd_list as $rrd) {
}
if ($i) {
$stack = 'STACK';
$stack = ':STACK';
}
$rrd_options .= ' AREA:inB'.$i.'#'.$colour_in.":'".$descr."':$stack";
$rrd_options .= ' AREA:inB'.$i.'#'.$colour_in.":'".$descr."'$stack";
if (!$nodetails) {
$rrd_options .= ' GPRINT:inB'.$i.":LAST:%6.2lf%s$units";
$rrd_options .= ' GPRINT:inB'.$i.":AVERAGE:%6.2lf%s$units";
@ -84,7 +81,7 @@ foreach ($rrd_list as $rrd) {
}
$rrd_options .= " 'HRULE:0#".$colour_out.':'.$descr_out."'";
$rrd_optionsb .= " 'AREA:outB".$i.'_neg#'.$colour_out."::$stack'";
$rrd_optionsb .= " 'AREA:outB".$i.'_neg#'.$colour_out.":$stack'";
if (!$nodetails) {
$rrd_options .= ' GPRINT:outB'.$i.":LAST:%6.2lf%s$units";

View File

@ -66,7 +66,7 @@ if ($i) {
$rrd_options .= ' CDEF:doutbits=doutoctets,8,*';
$rrd_options .= ' VDEF:95thin=inbits,95,PERCENT';
$rrd_options .= ' VDEF:95thout=outbits,95,PERCENT';
$rrd_options .= ' VDEF:d95thout=doutbits,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutn=doutbits,-1,* VDEF:d95thoutn95=d95thoutn,95,PERCENT CDEF:d95thoutn95n=doutbits,doutbits,-,d95thoutn95,-1,*,+ VDEF:d95thout=d95thoutn95n,FIRST';
if ($_GET['previous'] == 'yes') {
$rrd_options .= ' CDEF:'.$in.'octetsX='.$in_thingX.$pluses;
@ -77,7 +77,7 @@ if ($i) {
$rrd_options .= ' CDEF:doutbitsX=doutoctetsX,8,*';
$rrd_options .= ' VDEF:95thinX=inbitsX,95,PERCENT';
$rrd_options .= ' VDEF:95thoutX=outbitsX,95,PERCENT';
$rrd_options .= ' VDEF:d95thoutX=doutbitsX,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutXn=doutbitsX,-1,* VDEF:d95thoutXn95=d95thoutXn,95,PERCENT CDEF:d95thoutXn95n=doutbitsX,doutbitsX,-,d95thoutXn95,-1,*,+ VDEF:d95thoutX=d95thoutXn95n,FIRST';
}
if ($legend == 'no' || $legend == '1') {

View File

@ -45,9 +45,6 @@ foreach ($rrd_list as $rrd) {
}
$descr_out = rrdtool_escape($rrd['descr_out'], $descr_len).' Out';
$descr = str_replace("'", '', $descr);
// FIXME does this mean ' should be filtered in rrdtool_escape? probably...
$descr_out = str_replace("'", '', $descr_out);
$rrd_options .= ' DEF:'.$in.$i.'='.$rrd['filename'].':'.$ds_in.':AVERAGE ';
$rrd_options .= ' DEF:'.$out.$i.'='.$rrd['filename'].':'.$ds_out.':AVERAGE ';
@ -69,10 +66,10 @@ foreach ($rrd_list as $rrd) {
}
if ($i) {
$stack = 'STACK';
$stack = ':STACK';
}
$rrd_options .= ' AREA:inB'.$i.'#'.$colour_in.":'".$descr."':$stack";
$rrd_options .= ' AREA:inB'.$i.'#'.$colour_in.":'".$descr."'$stack";
$rrd_options .= ' GPRINT:inB'.$i.":LAST:%6.2lf%s$units";
$rrd_options .= ' GPRINT:inB'.$i.":AVERAGE:%6.2lf%s$units";
$rrd_options .= ' GPRINT:inB'.$i.":MAX:%6.2lf%s$units\l";
@ -82,7 +79,7 @@ foreach ($rrd_list as $rrd) {
}
$rrd_options .= " 'HRULE:0#".$colour_out.':'.$descr_out."'";
$rrd_optionsb .= " 'AREA:outB".$i.'_neg#'.$colour_out."::$stack'";
$rrd_optionsb .= " 'AREA:outB".$i.'_neg#'.$colour_out.":$stack'";
$rrd_options .= ' GPRINT:outB'.$i.":LAST:%6.2lf%s$units";
$rrd_options .= ' GPRINT:outB'.$i.":AVERAGE:%6.2lf%s$units";
$rrd_options .= ' GPRINT:outB'.$i.":MAX:%6.2lf%s$units\l";
@ -111,13 +108,13 @@ if (!$nototal) {
$rrd_options .= ' VDEF:95thin=inbits,95,PERCENT';
$rrd_options .= ' VDEF:95thout=outbits,95,PERCENT';
$rrd_options .= ' VDEF:d95thout=doutbits,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutn=doutbits,-1,* VDEF:d95thoutn95=d95thoutn,95,PERCENT CDEF:d95thoutn95n=doutbits,doutbits,-,d95thoutn95,-1,*,+ VDEF:d95thout=d95thoutn95n,FIRST';
$rrd_options .= ' VDEF:totin=inoctets,TOTAL';
$rrd_options .= ' VDEF:totout=outoctets,TOTAL';
$rrd_options .= ' VDEF:tot=octets,TOTAL';
// $rrd_options .= " AREA:totin#" . $colour_in . ":'" . $descr . "':$stack";
// $rrd_options .= " AREA:totin#" . $colour_in . ":'" . $descr . "'$stack";
// $rrd_options .= " GPRINT:totin:LAST:%6.2lf%s$units";
// $rrd_options .= " GPRINT:totin:AVERAGE:%6.2lf%s$units";
// $rrd_options .= " GPRINT:totin:MAX:%6.2lf%s$units\l";

View File

@ -11,7 +11,7 @@ else {
}
if ($nototal) {
$descrlen += '2';
$descr_len += '2';
$unitlen += '2';
}

View File

@ -71,7 +71,7 @@ foreach ($rrd_list as $rrd) {
}
if ($i) {
$stack = 'STACK';
$stack = ':STACK';
}
$rrd_options .= ' AREA:inbits'.$i.'#'.$colour_in.":'".rrdtool_escape($rrd['descr'], 9)."In '$stack";
@ -84,7 +84,7 @@ foreach ($rrd_list as $rrd) {
}
$rrd_options .= " COMMENT:'\\n'";
$rrd_optionsb .= ' AREA:outbits'.$i.'_neg#'.$colour_out.":$stack";
$rrd_optionsb .= ' AREA:outbits'.$i.'_neg#'.$colour_out."$stack";
$rrd_options .= ' HRULE:999999999999999#'.$colour_out.":'".str_pad('', 10)."Out'";
$rrd_options .= ' GPRINT:outbits'.$i.':LAST:%6.2lf%s';
$rrd_options .= ' GPRINT:outbits'.$i.':AVERAGE:%6.2lf%s';
@ -111,7 +111,7 @@ if ($_GET['previous'] == 'yes') {
$rrd_options .= ' CDEF:doutbitsX=doutBX,8,*';
$rrd_options .= ' VDEF:95thinX=inbitsX,95,PERCENT';
$rrd_options .= ' VDEF:95thoutX=outbitsX,95,PERCENT';
$rrd_options .= ' VDEF:d95thoutX=doutbitsX,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutXn=doutbitsX,-1,* VDEF:d95thoutXn95=d95thoutXn,95,PERCENT CDEF:d95thoutXn95n=doutbitsX,doutbitsX,-,d95thoutXn95,-1,*,+ VDEF:d95thoutX=d95thoutXn95n,FIRST';
}
if ($_GET['previous'] == 'yes') {
@ -132,7 +132,7 @@ if (!$args['nototal']) {
$rrd_options .= ' CDEF:doutbits=doutB,8,*';
$rrd_options .= ' VDEF:95thin=inbits,95,PERCENT';
$rrd_options .= ' VDEF:95thout=outbits,95,PERCENT';
$rrd_options .= ' VDEF:d95thout=doutbits,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutn=doutbits,-1,* VDEF:d95thoutn95=d95thoutn,95,PERCENT CDEF:d95thoutn95n=doutbits,doutbits,-,d95thoutn95,-1,*,+ VDEF:d95thout=d95thoutn95n,FIRST';
$rrd_options .= ' VDEF:totin=inB,TOTAL';
$rrd_options .= ' VDEF:avein=inbits,AVERAGE';
$rrd_options .= ' VDEF:totout=outB,TOTAL';

View File

@ -12,7 +12,7 @@ else {
}
if ($nototal) {
$descrlen += '2';
$descr_len += '2';
$unitlen += '2';
}
@ -32,7 +32,7 @@ else {
$unitlen = '10';
if ($nototal) {
$descrlen += '2';
$descr_len += '2';
$unitlen += '2';
}
@ -81,7 +81,7 @@ foreach ($rrd_list as $i => $rrd) {
// This this not the first entry?
if ($i) {
$stack = 'STACK';
$stack = ':STACK';
}
// if we've been passed a multiplier we must make a CDEF based on it!
@ -109,13 +109,13 @@ foreach ($rrd_list as $i => $rrd) {
$t_defname = $g_defname;
}
$rrd_options .= ' AREA:'.$g_defname.$i.'#'.$colour.":'".$descr."':$stack";
$rrd_options .= ' AREA:'.$g_defname.$i.'#'.$colour.":'".$descr."'$stack";
$rrd_options .= ' GPRINT:'.$t_defname.$i.':LAST:%5.2lf%s GPRINT:'.$t_defname.$i.'min:MIN:%5.2lf%s';
$rrd_options .= ' GPRINT:'.$t_defname.$i.'max:MAX:%5.2lf%s GPRINT:'.$t_defname.$i.":AVERAGE:'%5.2lf%s\\n'";
if (!$nototal) {
$rrd_options .= ' GPRINT:tot'.$rrd['ds'].$i.':%6.2lf%s'.rrdtool_escape($total_units).'';
$rrd_options .= ' GPRINT:tot'.$rrd['ds'].$i.":%6.2lf%s'".rrdtool_escape($total_units)."'";
}
$rrd_options .= " COMMENT:'\\n'";

View File

@ -50,7 +50,7 @@ foreach ($dbq as $ds) {
$descr = rrdtool_escape($ds['ds_label'], $descr_len);
$cmd_graph .= ' '.$ds['ds_draw'].':'.$ds_name.'#'.$colour.':"'.$descr.'"';
$cmd_graph .= ' '.$ds['ds_draw'].':'.$ds_name.'#'.$colour.":'".$descr."'";
$cmd_graph .= ' GPRINT:'.$ds_name.':LAST:"%6.2lf%s"';
$cmd_graph .= ' GPRINT:'.$ds_name.':AVERAGE:"%6.2lf%s"';
$cmd_graph .= ' GPRINT:'.$ds_name.':MAX:"%6.2lf%s\\n"';

View File

@ -20,7 +20,7 @@ else {
}
if ($print_total) {
$rrd_options .= ' VDEF:'.$ds.'_total=ds,TOTAL';
$rrd_options .= ' VDEF:'.$ds.'_total='.$ds.',TOTAL';
}
if ($percentile) {
@ -43,7 +43,7 @@ if ($_GET['previous'] == 'yes') {
}
if ($print_total) {
$rrd_options .= ' VDEF:'.$ds.'_totalX=ds,TOTAL';
$rrd_options .= ' VDEF:'.$ds.'_totalX='.$ds.',TOTAL';
}
if ($percentile) {
@ -74,11 +74,11 @@ if ($percentile) {
$rrd_options .= ' GPRINT:'.$ds.'_percentile:%6.2lf%s';
}
$rrd_options .= "\\\\n";
$rrd_options .= " COMMENT:\\\\n";
$rrd_options .= "\\n";
$rrd_options .= " COMMENT:\\n";
if ($print_total) {
$rrd_options .= ' GPRINT:'.$ds.'_tot:Total\ %6.2lf%s\)\\\\l';
$rrd_options .= ' GPRINT:'.$ds.'_total:Total" %6.2lf%s"\\l';
}
if ($percentile) {
@ -86,6 +86,6 @@ if ($percentile) {
}
if ($_GET['previous'] == 'yes') {
$rrd_options .= ' LINE1.25:'.$ds."X#666666:'Prev \\\\n'";
$rrd_options .= ' LINE1.25:'.$ds."X#666666:'Prev \\n'";
$rrd_options .= ' AREA:'.$ds.'X#99999966:';
}

View File

@ -5,6 +5,7 @@ $scale_max = '100';
$ds = 'usage';
// FIXME: As far as I can tell, $descr is never mentioned in includes/graphs/generic_simplex.inc.php -- PDG 2015-11-14
$descr = rrdtool_escape(short_hrDeviceDescr($proc['processor_descr']), 28);
$colour_line = 'cc0000';

View File

@ -19,7 +19,7 @@ $rrd_options .= ' AREA:sensor_diff#c5c5c5::STACK';
$rrd_options .= " LINE1.5:sensor#cc0000:'".rrdtool_escape($sensor['sensor_descr'], 21)."'";
$rrd_options .= ' GPRINT:sensor_min:MIN:%4.1lfC';
$rrd_options .= ' GPRINT:sensor:LAST:%4.1lfC';
$rrd_options .= ' GPRINT:sensor_max:MAX:%4.1lfC\\\\l';
$rrd_options .= ' GPRINT:sensor_max:MAX:%4.1lfC\\l';
if (is_numeric($sensor['sensor_limit'])) {
$rrd_options .= ' HRULE:'.$sensor['sensor_limit'].'#999999::dashes';

View File

@ -222,21 +222,16 @@ if (!defined('MBTTF_DIR')) {
}
}
//
// Check minimum PHP version
//
/*
* Check minimum PHP version
* @author f0o <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Billing
*/
function CheckPHPVersion($aMinVersion) {
list($majorC, $minorC, $editC) = preg_split('/[\/.-]/', PHP_VERSION);
list($majorR, $minorR, $editR) = preg_split('/[\/.-]/', $aMinVersion);
if ($majorC != $majorR) return false;
if ($majorC < $majorR) return false;
// same major - check minor
if ($minorC > $minorR) return true;
if ($minorC < $minorR) return false;
// and same minor
if ($editC >= $editR) return true;
return true;
return version_compare(PHP_VERSION, $aMinVersion, '>=');
}
//

View File

@ -132,7 +132,6 @@ foreach ($result_options as $option) {
echo '</select></td>';
$rulei = 1;
$count_query = 'SELECT COUNT(id)';
$full_query = 'SELECT *';
$sql = '';
@ -142,7 +141,7 @@ if (isset($device['device_id']) && $device['device_id'] > 0) {
$param = array($device['device_id']);
}
$query = " FROM alert_rules $sql ORDER BY device_id,id";
$query = " FROM alert_rules $sql ORDER BY id ASC";
$count_query = $count_query.$query;
$count = dbFetchCell($count_query, $param);
if (!isset($_POST['page_number']) && $_POST['page_number'] < 1) {
@ -199,7 +198,7 @@ foreach (dbFetchRows($full_query, $param) as $rule) {
$popover_msg = 'Device specific rule';
}
echo "<tr class='".$extra."' id='row_".$rule['id']."'>";
echo '<td><i>#'.((int) $rulei++).'</i></td>';
echo '<td><i>#'.((int) $rule['id']).'</i></td>';
echo '<td>'.$rule['name'].'</td>';
echo "<td class='col-sm-4'>";
if ($rule_extra['invert'] === true) {

View File

@ -37,6 +37,22 @@ else {
);
}//end if
if($_SESSION['screen_width']) {
if($_SESSION['screen_width'] < 1024 && $_SESSION['screen_width'] > 700) {
$graph_array['width'] = round(($_SESSION['screen_width'] - 90 )/2,0);
}
else {
if($_SESSION['screen_width'] > 1024) {
$graph_array['width'] = round(($_SESSION['screen_width'] - 90 )/count($periods)+1,0);
}
else {
$graph_array['width'] = $_SESSION['screen_width'] - 70;
}
}
}
$graph_array['height'] = round($graph_array['width'] /2.15);
$graph_array['to'] = $config['time']['now'];
$graph_data = array();

View File

@ -36,11 +36,20 @@ else {
$mac = '';
}
echo "<tr style=\"background-color: $row_colour;\" valign=top onmouseover=\"this.style.backgroundColor='$list_highlight';\" onmouseout=\"this.style.backgroundColor='$row_colour';\" onclick=\"location.href='".generate_port_url($port)."'\" style='cursor: pointer;'>
<td valign=top width=350>";
echo ' <span class=list-large>
echo "<tr style=\"background-color: $row_colour;\" valign=top onmouseover=\"this.style.backgroundColor='$list_highlight';\" onmouseout=\"this.style.backgroundColor='$row_colour';\" style='cursor: pointer;'>
<td valign=top width=350 onclick=\"location.href='".generate_port_url($port)."'\">";
// Don't echo out ports ifIndex if it's a NOS device since their ifIndex is, for lack of better words....different
if ($device['os'] == 'nos') {
echo ' <span class=list-large>
'.generate_port_link($port, $port['label'])." $error_img $mac
</span><br /><span class=interface-desc>".$port['ifAlias'].'</span>';
}
else {
echo ' <span class=list-large>
'.generate_port_link($port, $port['ifIndex'].'. '.$port['label'])." $error_img $mac
</span><br /><span class=interface-desc>".$port['ifAlias'].'</span>';
}
if ($port['ifAlias']) {
echo '<br />';
@ -50,19 +59,19 @@ unset($break);
if ($port_details) {
foreach (dbFetchRows('SELECT * FROM `ipv4_addresses` WHERE `port_id` = ?', array($port['port_id'])) as $ip) {
echo "$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&amp;query=$ip[ipv4_address]')\">".$ip['ipv4_address'].'/'.$ip['ipv4_prefixlen'].'</a>';
echo "$break <a class=interface-desc href=\"javascript:popUp('netcmd.php?cmd=whois&amp;query=$ip[ipv4_address]')\">".$ip['ipv4_address'].'/'.$ip['ipv4_prefixlen'].'</a>';
$break = '<br />';
}
foreach (dbFetchRows('SELECT * FROM `ipv6_addresses` WHERE `port_id` = ?', array($port['port_id'])) as $ip6) {
echo "$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&amp;query=".$ip6['ipv6_address']."')\">".Net_IPv6::compress($ip6['ipv6_address']).'/'.$ip6['ipv6_prefixlen'].'</a>';
echo "$break <a class=interface-desc href=\"javascript:popUp('netcmd.php?cmd=whois&amp;query=".$ip6['ipv6_address']."')\">".Net_IPv6::compress($ip6['ipv6_address']).'/'.$ip6['ipv6_prefixlen'].'</a>';
$break = '<br />';
}
}
echo '</span>';
echo '</td><td width=100>';
echo "</td><td width=100 onclick=\"location.href='".generate_port_url($port)."'\" >";
if ($port_details) {
$port['graph_type'] = 'port_bits';
@ -73,7 +82,7 @@ if ($port_details) {
echo generate_port_link($port, "<img src='graph.php?type=port_errors&amp;id=".$port['port_id'].'&amp;from='.$config['time']['day'].'&amp;to='.$config['time']['now'].'&amp;width=100&amp;height=20&amp;legend=no&amp;bg='.str_replace('#', '', $row_colour)."'>");
}
echo '</td><td width=120>';
echo "</td><td width=120 onclick=\"location.href='".generate_port_url($port)."'\" >";
if ($port['ifOperStatus'] == 'up') {
$port['in_rate'] = ($port['ifInOctets_rate'] * 8);
@ -86,7 +95,7 @@ if ($port['ifOperStatus'] == 'up') {
<img src='images/icons/arrow_pps_out.png' align=absmiddle> ".format_bi($port['ifOutUcastPkts_rate']).'pps</span>';
}
echo '</td><td width=75>';
echo "</td><td width=75 onclick=\"location.href='".generate_port_url($port)."'\" >";
if ($port['ifSpeed']) {
echo '<span class=box-desc>'.humanspeed($port['ifSpeed']).'</span>';
}
@ -130,19 +139,19 @@ if ($device['os'] == 'ios' || $device['os'] == 'iosxe') {
}//end if
if ($port_adsl['adslLineCoding']) {
echo '</td><td width=150>';
echo "</td><td width=150 onclick=\"location.href='".generate_port_url($port)."'\" >";
echo $port_adsl['adslLineCoding'].'/'.rewrite_adslLineType($port_adsl['adslLineType']);
echo '<br />';
echo 'Sync:'.formatRates($port_adsl['adslAtucChanCurrTxRate']).'/'.formatRates($port_adsl['adslAturChanCurrTxRate']);
echo '<br />';
echo 'Max:'.formatRates($port_adsl['adslAtucCurrAttainableRate']).'/'.formatRates($port_adsl['adslAturCurrAttainableRate']);
echo '</td><td width=150>';
echo "</td><td width=150 onclick=\"location.href='".generate_port_url($port)."'\" >";
echo 'Atten:'.$port_adsl['adslAtucCurrAtn'].'dB/'.$port_adsl['adslAturCurrAtn'].'dB';
echo '<br />';
echo 'SNR:'.$port_adsl['adslAtucCurrSnrMgn'].'dB/'.$port_adsl['adslAturCurrSnrMgn'].'dB';
}
else {
echo '</td><td width=150>';
echo "</td><td width=150 onclick=\"location.href='".generate_port_url($port)."'\" >";
if ($port['ifType'] && $port['ifType'] != '') {
echo '<span class=box-desc>'.fixiftype($port['ifType']).'</span>';
}
@ -158,7 +167,7 @@ else {
echo '-';
}
echo '</td><td width=150>';
echo "</td><td width=150 onclick=\"location.href='".generate_port_url($port)."'\" >";
if ($port['ifPhysAddress'] && $port['ifPhysAddress'] != '') {
echo '<span class=box-desc>'.formatMac($port['ifPhysAddress']).'</span>';
}
@ -176,13 +185,17 @@ else {
}//end if
echo '</td>';
echo '<td width=375 valign=top class=interface-desc>';
echo '<td width=375 valign=top class="interface-desc">';
$neighborsCount=0;
$nbLinks=0;
if (strpos($port['label'], 'oopback') === false && !$graph_type) {
foreach (dbFetchRows('SELECT * FROM `links` AS L, `ports` AS I, `devices` AS D WHERE L.local_port_id = ? AND L.remote_port_id = I.port_id AND I.device_id = D.device_id', array($if_id)) as $link) {
// echo("<img src='images/16/connect.png' align=absmiddle alt='Directly Connected' /> " . generate_port_link($link, makeshortif($link['label'])) . " on " . generate_device_link($link, shorthost($link['hostname'])) . "</a><br />");
// $br = "<br />";
$int_links[$link['port_id']] = $link['port_id'];
$int_links_phys[$link['port_id']] = 1;
$nbLinks++;
}
unset($br);
@ -233,10 +246,23 @@ if (strpos($port['label'], 'oopback') === false && !$graph_type) {
}//end foreach
}//end if
if(count($int_links) > 3)
{
echo '<div class="collapse-neighbors"><span class="neighbors-button glyphicon glyphicon-plus" aria-hidden="true"></span>
<span class="neighbors-interface-list-firsts" style="display: inline;">';
}
if ($port_details && $config['enable_port_relationship'] === true && port_permitted($int_link,$device['device_id'])) {
foreach ($int_links as $int_link) {
$neighborsCount++;
if($neighborsCount == 4)
{
echo '<span class="neighbors-list-continued" style="display: inline;"></br>[...]</span>';
echo '</span>';
echo '<span class="neighbors-interface-list" style="display: none;">';
}
$link_if = dbFetchRow('SELECT * from ports AS I, devices AS D WHERE I.device_id = D.device_id and I.port_id = ?', array($int_link));
echo "$br";
if ($int_links_phys[$int_link]) {
@ -304,6 +330,10 @@ if ($port_details && $config['enable_port_relationship'] === true && port_permit
unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
if($nbLinks > 3)
{
echo '</span></div>';
}
echo '</td></tr>';
// If we're showing graphs, generate the graph and print the img tags

View File

@ -132,10 +132,10 @@ foreach ($list as $items) {
if (!in_array($items['local_device_id'],$tmp_ids)) {
$tmp_devices[] = array('id'=>$items['local_device_id'],'label'=>$items['local_hostname'],'title'=>generate_device_link($local_device,'',array(),'','','',0),'shape'=>'box');
}
array_push($tmp_ids,$items['local_device_id']);
if (!in_array($items['remote_device_id'],$tmp_ids)) {
$tmp_devices[] = array('id'=>$items['remote_device_id'],'label'=>$items['remote_hostname'],'title'=>generate_device_link($remote_device,'',array(),'','','',0),'shape'=>'box');
}
array_push($tmp_ids,$items['local_device_id']);
array_push($tmp_ids,$items['remote_device_id']);
$speed = $items['local_ifspeed']/1000/1000;
if ($speed == 100) {
@ -218,7 +218,7 @@ echo $edges;
var network = new vis.Network(container, data, options);
network.on('click', function (properties) {
if (properties.nodes > 0) {
window.location.href = "/device/device="+properties.nodes+"/tab=map/"
window.location.href = "device/device="+properties.nodes+"/tab=map/"
}
});
</script>

View File

@ -47,7 +47,7 @@ else {
<div class="collapse navbar-collapse" id="navHeaderCollapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-lightbulb-o fa-fw fa-lg fa-nav-icons"></i> Overview</a>
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-lightbulb-o fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Overview</span></a>
<ul class="dropdown-menu">
<li><a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-lightbulb-o fa-fw fa-lg"></i> Overview</a></li>
<li class="dropdown-submenu">
@ -74,6 +74,12 @@ if ($_SESSION['userlevel'] >= '10') {
<li><a href="<?php echo(generate_url(array('page'=>'availability-map'))); ?>"><i class="fa fa-arrow-circle-up fa-fw fa-lg"></i> Availability</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'map'))); ?>"><i class="fa fa-desktop fa-fw fa-lg"></i> Network</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-wrench fa-fw fa-lg"></i> Tools</a>
<ul class="dropdown-menu scrollable-menu">
<li><a href="<?php echo(generate_url(array('page'=>'ripenccapi'))); ?>"><i class="fa fa-arrow-circle-up fa-fw fa-lg"></i> RIPE NCC API</a></li>
</ul>
</li>
<li role="presentation" class="divider"></li>
<li><a href="<?php echo(generate_url(array('page'=>'eventlog'))); ?>"><i class="fa fa-book fa-fw fa-lg"></i> Eventlog</a></li>
@ -107,7 +113,7 @@ if ( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) {
</ul>
</li>
<li class="dropdown">
<a href="devices/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-server fa-fw fa-lg fa-nav-icons"></i> Devices</a>
<a href="devices/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-server fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Devices</span></a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a href="devices/"><i class="fa fa-server fa-fw fa-lg"></i> All Devices</a>
@ -181,7 +187,7 @@ if ($_SESSION['userlevel'] >= '10') {
if ($config['show_services']) {
?>
<li class="dropdown">
<a href="services/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-cogs fa-fw fa-lg fa-nav-icons"></i> Services</a>
<a href="services/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-cogs fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Services</span></a>
<ul class="dropdown-menu">
<li><a href="services/"><i class="fa fa-cogs fa-fw fa-lg"></i> All Services </a></li>
@ -210,7 +216,7 @@ if ($_SESSION['userlevel'] >= '10') {
<!-- PORTS -->
<li class="dropdown">
<a href="ports/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-link fa-fw fa-lg fa-nav-icons"></i> Ports</a>
<a href="ports/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-link fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Ports</span></a>
<ul class="dropdown-menu">
<li><a href="ports/"><i class="fa fa-link fa-fw fa-lg"></i> All Ports</a></li>
@ -269,7 +275,7 @@ if ($_SESSION['userlevel'] >= '5') {
}
foreach ($config['custom_descr'] as $custom_type) {
if (!empty($custom_type)) {
echo ' <li><a href="iftype/type=' . strtolower($custom_type) . '"><i class="fa fa-connectdevelop fa-fw fa-lg"></i> ' . ucfirst($custom_type) . '</a></li>';
echo ' <li><a href="iftype/type=' . urlencode(strtolower($custom_type)) . '"><i class="fa fa-connectdevelop fa-fw fa-lg"></i> ' . ucfirst($custom_type) . '</a></li>';
$ifbreak = 1;
}
}
@ -316,7 +322,7 @@ $menu_sensors = $used_sensors;
?>
<li class="dropdown">
<a href="health/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-heartbeat fa-fw fa-lg fa-nav-icons"></i> Health</a>
<a href="health/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-heartbeat fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Health</span></a>
<ul class="dropdown-menu">
<li><a href="health/metric=mempool/"><i class="fa fa-gears fa-fw fa-lg"></i> Memory</a></li>
<li><a href="health/metric=processor/"><i class="fa fa-desktop fa-fw fa-lg"></i> Processor</a></li>
@ -367,7 +373,7 @@ $app_list = dbFetchRows("SELECT DISTINCT(`app_type`) AS `app_type` FROM `applica
if ($_SESSION['userlevel'] >= '5' && count($app_list) > "0") {
?>
<li class="dropdown">
<a href="apps/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-tasks fa-fw fa-lg fa-nav-icons"></i> Apps</a>
<a href="apps/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-tasks fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Apps</span></a>
<ul class="dropdown-menu">
<?php
@ -405,7 +411,7 @@ if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf
?>
<li class="dropdown">
<a href="routing/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-arrows fa-fw fa-lg fa-nav-icons"></i> Routing</a>
<a href="routing/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-arrows fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Routing</span></a>
<ul class="dropdown-menu">
<?php
$separator = 0;
@ -452,7 +458,7 @@ if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf
?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-plug fa-fw fa-lg fa-nav-icons"></i> <span class="hidden-md hidden-sm">Plugins</span></a>
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-plug fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Plugins</span></a>
<ul class="dropdown-menu">
<?php
Plugins::call('menu');
@ -483,7 +489,33 @@ if(is_file("includes/print-menubar-custom.inc.php")) {
</form>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-cog fa-fw fa-lg fa-nav-icons"></i></a>
<?php
$notifications = new ObjCache('notifications');
$style = '';
if (empty($notifications['count']) && empty($notifications['sticky_count'])) {
$style = 'style="background-color:grey; color:white;"';
}
echo('<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-user fa-fw fa-lg fa-nav-icons"></i><span class="badge badge-navbar-user" '.$style.'>'.($notifications['sticky_count']+$notifications['count']).'</span></a>');
?>
<ul class="dropdown-menu">
<li role="presentation" class="dropdown-header"> Settings</li>
<li><a href="preferences/"><i class="fa fa-cog fa-fw fa-lg"></i> My Settings</a></li>
<?php
$notifications = new ObjCache('notifications');
echo ('<li><a href="notifications/"><span class="badge count-notif">'.($notifications['sticky_count']+$notifications['count']).'</span> Notifications</a></li>');
?>
<li role="presentation" class="divider"></li>
<?php
if ($_SESSION['authenticated']) {
echo('
<li><a href="logout/"><i class="fa fa-sign-out fa-fw fa-lg"></i> Logout</a></li>');
}
?>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown" style="margin-left:5px"><i class="fa fa-cog fa-fw fa-lg fa-nav-icons"></i></a>
<ul class="dropdown-menu">
<li role="presentation" class="dropdown-header"> Settings</li>
<?php
@ -492,7 +524,6 @@ if ($_SESSION['userlevel'] >= '10') {
}
?>
<li><a href="preferences/"><i class="fa fa-cog fa-fw fa-lg"></i> My Settings</a></li>
<li role="presentation" class="divider"></li>
<li role="presentation" class="dropdown-header"> Users</li>
@ -540,8 +571,7 @@ if ($_SESSION['authenticated']) {
<ul class="dropdown-menu scrollable-menu">
<li><a href="#"><span class="countdown_timer_status" id="countdown_timer_status"></span></a></li>
</ul>
</li>
<li><a href="logout/"><i class="fa fa-sign-out fa-fw fa-lg"></i> Logout</a></li>');
</li>');
}
?>

View File

@ -47,6 +47,7 @@ echo "
<input name='params' id='params' class='form-control input-sm'>
</div>
<div class='col-sm-5'>
This may be required based on the service check.
</div>
</div>
<button type='submit' name='Submit' class='btn btn-success input-sm'>Add Service</button>

View File

@ -26,6 +26,9 @@ if (isset($_POST['service']) && is_numeric($_POST['service'])) {
<div class='col-sm-5'>
<input name='params' id='params' value='".$service['service_param']."' class='form-control input-sm'>
</div>
<div class='col-sm-5'>
This may be required based on the service check.
</div>
</div>
<button type='submit' id='confirm-editsrv' name='confirm-editsrv' value='yes' class='btn btn-primary input-sm'>Edit Service</button>
</div>

View File

@ -24,6 +24,9 @@ else if ($service[service_status] == '2') {
$message = trim($service['service_message']);
$message = str_replace("\n", '<br />', $message);
$desc = trim($service['service_desc']);
$desc = str_replace("\n", '<br />', $desc);
$since = (time() - $service['service_changed']);
$since = formatUptime($since);
@ -42,11 +45,11 @@ $popup .= "</div><img src=\'graph.php?id=".$service['service_id'].'&amp;type=ser
$popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"';
echo "
<tr style=\"background-color: $bg; padding: 5px;\">";
<tr>";
if ($device_id) {
if (!$samehost) {
echo "<td valign=top width=250><span style='font-weight:bold;'>".generate_device_link($device).'</span></td>';
echo "<td>".generate_device_link($device).'</span></td>';
}
else {
echo '<td></td>';
@ -54,16 +57,18 @@ if ($device_id) {
}
echo "
<td valign=top class=list-bold>
<td>
$status
</td>
<td valign=top><a $popup><img src='$mini_url'></a></td>
<td valign=top width=175>
<td>
$since
</td>
<td valign=top>
<td>
<span class=box-desc>$message</span>
</td>
<td>
<span class=box-desc>$desc</span>
</td>
</tr>";
$i++;

View File

@ -1,7 +1,5 @@
<?php
echo '<tr class="list">';
echo '<td class="list">';
if (getidbyname($vm['vmwVmDisplayName'])) {
@ -12,7 +10,13 @@ else {
}
echo '</td>';
echo '<td class="list">'.$vm['vmwVmState'].'</td>';
if ($vm['vmwVmState'] == 'powered off') {
echo '<td class="list"><span style="min-width:40px; display:inline-block;" class="label label-default">OFF</span></td>';
}
else {
echo '<td class="list"><span style="min-width:40px; display:inline-block;" class="label label-success">ON</span></td>';
}
if ($vm['vmwVmGuestOS'] == 'E: tools not installed') {
echo '<td class="box-desc">Unknown (VMware Tools not installed)</td>';

View File

@ -12,20 +12,35 @@ if (is_admin() === false && is_read() === false) {
$sql .= " WHERE M.port_id = P.port_id AND P.device_id = D.device_id $where ";
if (isset($_POST['searchby']) && $_POST['searchby'] == 'ip') {
$sql .= ' AND `ipv4_address` LIKE ?';
$param[] = '%'.trim($_POST['address']).'%';
}
else if (isset($_POST['searchby']) && $_POST['searchby'] == 'mac') {
$sql .= ' AND `mac_address` LIKE ?';
$param[] = '%'.str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address'])).'%';
}
if (is_numeric($_POST['device_id'])) {
$sql .= ' AND P.device_id = ?';
$param[] = $_POST['device_id'];
}
if (is_numeric($_POST['port_id'])) {
$sql .= ' AND P.port_id = ?';
$param[] = $_POST['port_id'];
}
if (isset($_POST['searchPhrase']) && !empty($_POST['searchPhrase'])) {
$ip_search = '%'.mres(trim($_POST['searchPhrase'])).'%';
$mac_search = '%'.str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['searchPhrase'])).'%';
if (isset($_POST['searchby']) && $_POST['searchby'] == 'ip') {
$sql .= ' AND `ipv4_address` LIKE ?';
$param[] = $ip_search;
}
else if (isset($_POST['searchby']) && $_POST['searchby'] == 'mac') {
$sql .= ' AND `mac_address` LIKE ?';
$param[] = $mac_search;
}
else {
$sql .= ' AND (`ipv4_address` LIKE ? OR `mac_address` LIKE ?)';
$param[] = $ip_search;
$param[] = $mac_search;
}
}
$count_sql = "SELECT COUNT(`M`.`port_id`) $sql";
$total = dbFetchCell($count_sql, $param);

View File

@ -54,17 +54,22 @@ foreach (dbFetchRows($sql, $param) as $port) {
$isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0;
$dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad;
$outofsync = $dowecare ? " class='red'" : '';
$checked = '';
if (get_dev_attrib($device_id, 'ifName_tune:'.$port['ifName']) == "true") {
$checked = 'checked';
}
$response[] = array(
'ifIndex' => $port['ifIndex'],
'ifName' => $port['label'],
'ifAdminStatus' => $port['ifAdminStatus'],
'ifOperStatus' => '<span name="operstatus_'.$port['port_id'].'"'.$outofsync.'>'.$port['ifOperStatus'].'</span>',
'disabled' => '<input type="checkbox" class="disable-check" name="disabled_'.$port['port_id'].'"'.($port['disabled'] ? 'checked' : '').'>
<input type="hidden" name="olddis_'.$port['port_id'].'" value="'.($port['disabled'] ? 1 : 0).'"">',
'ignore' => '<input type="checkbox" class="ignore-check" name="ignore_'.$port['port_id'].'"'.($port['ignore'] ? 'checked' : '').'>
<input type="hidden" name="oldign_'.$port['port_id'].'" value="'.($port['ignore'] ? 1 : 0).'"">',
'ifAlias' => '<div class="form-group"><input class="form-control input-sm" id="if-alias" name="if-alias" data-device_id="'.$port['device_id'].'" data-port_id="'.$port['port_id'].'" data-ifName="'.$port['ifName'].'" value="'.$port['ifAlias'].'"><span class="glyphicon form-control-feedback" aria-hidden="true"></span></div>'
'ifIndex' => $port['ifIndex'],
'ifName' => $port['label'],
'ifAdminStatus' => $port['ifAdminStatus'],
'ifOperStatus' => '<span name="operstatus_'.$port['port_id'].'"'.$outofsync.'>'.$port['ifOperStatus'].'</span>',
'disabled' => '<input type="checkbox" class="disable-check" name="disabled_'.$port['port_id'].'"'.($port['disabled'] ? 'checked' : '').'>
<input type="hidden" name="olddis_'.$port['port_id'].'" value="'.($port['disabled'] ? 1 : 0).'"">',
'ignore' => '<input type="checkbox" class="ignore-check" name="ignore_'.$port['port_id'].'"'.($port['ignore'] ? 'checked' : '').'>
<input type="hidden" name="oldign_'.$port['port_id'].'" value="'.($port['ignore'] ? 1 : 0).'"">',
'port_tune' => '<input type="checkbox" id="override_config" name="override_config" data-attrib="ifName_tune:'.$port['ifName'].'" data-device_id="'.$port['device_id'].'" data-size="small" '.$checked.'>',
'ifAlias' => '<div class="form-group"><input class="form-control input-sm" id="if-alias" name="if-alias" data-device_id="'.$port['device_id'].'" data-port_id="'.$port['port_id'].'" data-ifName="'.$port['ifName'].'" value="'.$port['ifAlias'].'"><span class="glyphicon form-control-feedback" aria-hidden="true"></span></div>',
);
}//end foreach

View File

@ -29,7 +29,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) {
$sql .= " AND (`D`.`hostname` LIKE '%$searchPhrase%' OR `E`.`datetime` LIKE '%$searchPhrase%' OR `E`.`message` LIKE '%$searchPhrase%' OR `E`.`type` LIKE '%$searchPhrase%')";
}
$count_sql = "SELECT COUNT(datetime) $sql";
$count_sql = "SELECT COUNT(event_id) $sql";
$total = dbFetchCell($count_sql, $param);
if (empty($total)) {
$total = 0;

View File

@ -0,0 +1,144 @@
<?php
$graph_type = mres($_POST['graph_type']);
$unit = mres($_POST['unit']);
$class = mres($_POST['class']);
$sql = ' FROM `sensors` AS S, `devices` AS D';
if (is_admin() === false && is_read() === false) {
$sql .= ', devices_perms as P';
}
$sql .= " WHERE S.sensor_class=? AND S.device_id = D.device_id ";
$param[] = mres($_POST['class']);
if (is_admin() === false && is_read() === false) {
$sql .= " AND D.device_id = P.device_id AND P.user_id = ?";
$param[] = $_SESSION['user_id'];
}
if (isset($searchPhrase) && !empty($searchPhrase)) {
$sql .= " AND (`D`.`hostname` LIKE '%$searchPhrase%' OR `sensor_descr` LIKE '%$searchPhrase%' OR `sensor_current` LIKE '%searchPhrase')";
}
$count_sql = "SELECT COUNT(`sensor_id`) $sql";
$count = dbFetchCell($count_sql, $param);
if (empty($count)) {
$count = 0;
}
if (!isset($sort) || empty($sort)) {
$sort = '`D`.`hostname`, `S`.`sensor_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 $sensor) {
if (empty($sensor['sensor_current'])) {
$sensor['sensor_current'] = 'NaN';
}
else {
if ($sensor['sensor_current'] >= $sensor['sensor_limit']) {
$alert = '<img src="images/16/flag_red.png" alt="alert" />';
}
else {
$alert = '';
}
}
// FIXME - make this "four graphs in popup" a function/include and "small graph" a function.
// FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"?
// FIXME - DUPLICATED IN device/overview/sensors
$graph_colour = str_replace('#', '', $row_colour);
$graph_array = array();
$graph_array['height'] = '100';
$graph_array['width'] = '210';
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $sensor['sensor_id'];
$graph_array['type'] = $graph_type;
$graph_array['from'] = $config['time']['day'];
$graph_array['legend'] = 'no';
$link_array = $graph_array;
$link_array['page'] = 'graphs';
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link_graph = generate_url($link_array);
$link = generate_url(array('page' => 'device', 'device' => $sensor['device_id'], 'tab' => 'health', 'metric' => $sensor['sensor_class']));
$overlib_content = '<div style="width: 580px;"><h2>'.$device['hostname'].' - '.$sensor['sensor_descr'].'</h1>';
foreach (array('day', 'week', 'month', 'year') as $period) {
$graph_array['from'] = $config['time'][$period];
$overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array));
}
$overlib_content .= '</div>';
$graph_array['width'] = 80;
$graph_array['height'] = 20;
$graph_array['bg'] = 'ffffff00';
// the 00 at the end makes the area transparent.
$graph_array['from'] = $config['time']['day'];
$sensor_minigraph = generate_lazy_graph_tag($graph_array);
$sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, '');
$response[] = array(
'hostname' => generate_device_link($sensor),
'sensor_descr' => overlib_link($link, $sensor['sensor_descr'], $overlib_content, null),
'graph' => overlib_link($link_graph, $sensor_minigraph, $overlib_content, null),
'alert' => $alert,
'sensor_current' => $sensor['sensor_current'].$unit,
'sensor_range' => round($sensor['sensor_limit_low'], 2).$unit.' - '.round($sensor['sensor_limit'], 2).$unit,
);
if ($_POST['view'] == 'graphs') {
$daily_graph = 'graph.php?id='.$sensor['sensor_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='.$sensor['sensor_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='.$sensor['sensor_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='.$sensor['sensor_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='.$sensor['sensor_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='.$sensor['sensor_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='.$sensor['sensor_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='.$sensor['sensor_id'].'&amp;type='.$graph_type.'&amp;from='.$config['time']['year'].'&amp;to='.$config['time']['now'].'&amp;width=400&amp;height=150';
$response[] = array(
'hostname' => "<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$daily_graph' border=0></a> ",
'sensor_descr' => "<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$weekly_graph' border=0></a> ",
'graph' => "<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$monthly_graph' border=0></a>",
'alert' => '',
'sensor_current' => "<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$yearly_graph' border=0></a>",
'sensor_range' => '',
);
} //end if
}//end foreach
$output = array(
'current' => $current,
'rowCount' => $rowCount,
'rows' => $response,
'total' => $count,
);
echo _json_encode($output);

View File

@ -12,11 +12,13 @@
*
*/
if( strstr($_SERVER['SERVER_SOFTWARE'],"nginx") ) {
$_SERVER['PATH_INFO'] = str_replace($_SERVER['PATH_TRANSLATED'].$_SERVER['PHP_SELF'],"",$_SERVER['ORIG_SCRIPT_FILENAME']);
}
else {
$_SERVER['PATH_INFO'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : '');
if (empty($_SERVER['PATH_INFO'])) {
if( strstr($_SERVER['SERVER_SOFTWARE'],"nginx") ) {
$_SERVER['PATH_INFO'] = str_replace($_SERVER['PATH_TRANSLATED'].$_SERVER['PHP_SELF'],"",$_SERVER['ORIG_SCRIPT_FILENAME']);
}
else {
$_SERVER['PATH_INFO'] = !empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : '';
}
}
function logErrors($errno, $errstr, $errfile, $errline) {
@ -163,8 +165,14 @@ else {
<script src="js/jquery.bootgrid.min.js"></script>
<script src="js/handlebars.min.js"></script>
<script src="js/pace.min.js"></script>
<?php
if ($config['enable_lazy_load'] === true) {
?>
<script src="js/jquery.lazyload.min.js"></script>
<script src="js/lazyload.js"></script>
<?php
}
?>
<script src="js/librenms.js"></script>
<script type="text/javascript">
@ -184,6 +192,10 @@ else {
<?php
if(empty($_SESSION['screen_width']) && empty($_SESSION['screen_height'])) {
echo "<script>updateResolution();</script>";
}
if ((isset($vars['bare']) && $vars['bare'] != "yes") || !isset($vars['bare'])) {
if ($_SESSION['authenticated']) {
require 'includes/print-menubar.php';

View File

@ -32,5 +32,5 @@ $(document).ready(function(){
function lazyload_done() {
//Since RRD takes the width and height params for only the canvas, we must unset them
//from the final (larger) image to prevent the browser from resizing them.
$(this).removeAttr('width').removeAttr('height').removeClass('lazy');
}
$(this).removeAttr('height').removeClass('lazy');
}

View File

@ -1,15 +1,47 @@
function override_config(event, state, tmp_this) {
event.preventDefault();
var $this = tmp_this;
var attrib = $this.data('attrib');
var device_id = $this.data('device_id');
$.ajax({
type: 'POST',
url: 'ajax_form.php',
data: { type: 'override-config', device_id: device_id, attrib: attrib, state: state },
dataType: 'json',
success: function(data) {
if (data.status == 'ok') {
toastr.success(data.message);
}
else {
toastr.error(data.message);
}
},
error: function() {
toastr.error('Could not set this override');
}
});
}
var oldH;
var oldW;
$(document).ready(function() {
// Device override ajax calls
$("[name='override_config']").bootstrapSwitch('offColor','danger');
$('input[name="override_config"]').on('switchChange.bootstrapSwitch', function(event, state) {
override_config(event,state,$(this));
});
// Device override for text inputs
$(document).on('blur', 'input[name="override_config_text"]', function(event) {
event.preventDefault();
var $this = $(this);
var attrib = $this.data('attrib');
var device_id = $this.data('device_id');
var value = $this.val();
$.ajax({
type: 'POST',
url: 'ajax_form.php',
data: { type: 'override-config', device_id: device_id, attrib: attrib, state: state },
data: { type: 'override-config', device_id: device_id, attrib: attrib, state: value },
dataType: 'json',
success: function(data) {
if (data.status == 'ok') {
@ -96,11 +128,14 @@ $(document).ready(function() {
}
});
});
oldW=$(window).width();
oldH=$(window).height();
});
function submitCustomRange(frmdata) {
var reto = /to=([0-9])+/g;
var refrom = /from=([0-9])+/g;
var reto = /to=([0-9a-zA-Z\-])+/g;
var refrom = /from=([0-9a-zA-Z\-])+/g;
var tsto = moment(frmdata.dtpickerto.value).unix();
var tsfrom = moment(frmdata.dtpickerfrom.value).unix();
frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto);
@ -109,3 +144,82 @@ function submitCustomRange(frmdata) {
return true;
}
function updateResolution(refresh)
{
$.post('ajax_setresolution.php',
{
width: $(window).width(),
height:$(window).height()
},
function(data) {
if(refresh == true) {
location.reload();
}
},'json'
);
}
var rtime;
var timeout = false;
var delta = 500;
var newH;
var newW;
$(window).on('resize', function(){
rtime = new Date();
if (timeout === false) {
timeout = true;
setTimeout(resizeend, delta);
}
});
function resizeend() {
if (new Date() - rtime < delta) {
setTimeout(resizeend, delta);
}
else {
newH=$(window).height();
newW=$(window).width();
timeout = false;
if(Math.abs(oldW - newW) >= 200)
{
refresh = true;
}
else {
refresh = false;
resizeGraphs();
}
updateResolution(refresh);
}
};
function resizeGraphs() {
ratioW=newW/oldW;
ratioH=newH/oldH;
$('.graphs').each(function (){
var img = jQuery(this);
img.attr('width',img.width() * ratioW);
});
oldH=newH;
oldW=newW;
}
$(document).on("click", '.collapse-neighbors', function(event)
{
var caller = $(this);
var button = caller.find('.neighbors-button');
var list = caller.find('.neighbors-interface-list');
var continued = caller.find('.neighbors-list-continued');
if(button.hasClass("glyphicon-plus")) {
button.addClass('glyphicon-minus').removeClass('glyphicon-plus');
}
else {
button.addClass('glyphicon-plus').removeClass('glyphicon-minus');
}
list.toggle();
continued.toggle();
});

View File

@ -9,7 +9,7 @@ else {
$updated = '1';
// FIXME should call add_service (needs more parameters)
$service_id = dbInsert(array('device_id' => $_POST['device'], 'service_ip' => $_POST['ip'], 'service_type' => $_POST['type'], 'service_desc' => $_POST['descr'], 'service_param' => $_POST['params'], 'service_ignore' => '0'), 'services');
$service_id = dbInsert(array('device_id' => $_POST['device'], 'service_ip' => $_POST['ip'], 'service_type' => $_POST['type'], 'service_desc' => $_POST['descr'], 'service_param' => $_POST['params'], 'service_ignore' => '0', 'service_status' => '0', 'service_checked' => '0', 'service_changed' => '0', 'service_message' => 'New check', 'service_disabled' => '0'), 'services');
if ($service_id) {
$message .= $message_break.'Service added ('.$service_id.')!';
@ -18,10 +18,11 @@ else {
}
}
if ($handle = opendir($config['install_dir'].'/includes/services/')) {
if ($handle = opendir($config['nagios_plugins'])) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && !strstr($file, '.')) {
$servicesform .= "<option value='$file'>$file</option>";
if ($file != '.' && $file != '..' && !strstr($file, '.') && strstr($file, 'check_')) {
list(,$check_name) = explode('_',$file,2);
$servicesform .= "<option value='$check_name'>$check_name</option>";
}
}

View File

@ -188,7 +188,7 @@ if (bill_permitted($bill_id)) {
$background = get_percentage_colours($percent);
echo '<p>'.print_percentage_bar(350, 20, $perc, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']).'</p>';
echo '<p>'.print_percentage_bar(350, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']).'</p>';
$type = '&amp;ave=yes';
}

View File

@ -1,6 +1,4 @@
<form name="form1" action="" method="post" class="form-horizontal">
<link rel="stylesheet" href="<?php echo $config['base_url']; ?>/css/bootstrap.min.css">
<script type="text/javascript">
function showWarning(checked) {
$('#warning').toggle();
@ -12,23 +10,25 @@
}
</script>
<input type="hidden" name="action" value="delete_bill">
<fieldset>
<legend>Delete Bill</legend>
<div class="control-group">
<label class="control-label" for="confirm"><strong>Confirm</strong></label>
<div class="controls">
<label class="checkbox">
<input type="checkbox" name="confirm" value="confirm" onchange="javascript: showWarning(this.checked);">
Yes, please delete this bill!
<h3>Delete Bill</h3>
<hr>
<div class="control-group">
<label class="control-label" for="confirm"><strong>Confirm</strong></label>
<div class="controls">
<div class="checkbox">
<label>
<input type="checkbox" name="confirm" value="confirm" onchange="javascript: showWarning(this.checked);">
Yes, please delete this bill!
</label>
</div>
</div>
<div class="alert alert-message" id="warning" style="display: none;">
<h4 class="alert-heading"><i class="icon-warning-sign"></i> Warning!</h4>
Are you sure you want to delete his bill?
</div>
</fieldset>
</div>
<br>
<div class="alert alert-danger" id="warning" style="display: none;">
<h4 class="alert-heading"><i class="fa fa-exclamation-triangle"></i> Warning</h4>
You are about to delete this bill.
</div>
<div class="form-actions">
<button id="deleteBtn" type="submit" class="btn btn-danger" disabled="disabled"><i class="icon-trash icon-white"></i> <strong>Delete Bill</strong></button>
<button id="deleteBtn" type="submit" class="btn btn-danger" disabled="disabled"><i class="fa fa-trash"></i> <strong>Delete Bill</strong></button>
</div>
</form>

View File

@ -1,123 +1,123 @@
<?php
require 'includes/javascript-interfacepicker.inc.php';
// This needs more verification. Is it already added? Does it exist?
// Calculation to extract MB/GB/TB of Kbps/Mbps/Gbps
$base = $config['billing']['base'];
if ($bill_data['bill_type'] == 'quota') {
$data = $bill_data['bill_quota'];
$tmp['mb'] = ($data / $base / $base);
$tmp['gb'] = ($data / $base / $base / $base);
$tmp['tb'] = ($data / $base / $base / $base / $base);
if ($tmp['tb'] >= 1) {
$quota = array(
'type' => 'tb',
'select_tb' => ' selected',
'data' => $tmp['tb'],
);
}
else if (($tmp['gb'] >= 1) and ($tmp['gb'] < $base)) {
$quota = array(
'type' => 'gb',
'select_gb' => ' selected',
'data' => $tmp['gb'],
);
}
else if (($tmp['mb'] >= 1) and ($tmp['mb'] < $base)) {
$quota = array(
'type' => 'mb',
'select_mb' => ' selected',
'data' => $tmp['mb'],
);
}
}//end if
if ($bill_data['bill_type'] == 'cdr') {
$data = $bill_data['bill_cdr'];
$tmp['kbps'] = ($data / $base);
$tmp['mbps'] = ($data / $base / $base);
$tmp['gbps'] = ($data / $base / $base / $base);
if ($tmp['gbps'] >= 1) {
$cdr = array(
'type' => 'gbps',
'select_gbps' => ' selected',
'data' => $tmp['gbps'],
);
}
else if (($tmp['mbps'] >= 1) and ($tmp['mbps'] < $base)) {
$cdr = array(
'type' => 'mbps',
'select_mbps' => ' selected',
'data' => $tmp['mbps'],
);
}
else if (($tmp['kbps'] >= 1) and ($tmp['kbps'] < $base)) {
$cdr = array(
'type' => 'kbps',
'select_kbps' => ' selected',
'data' => $tmp['kbps'],
);
}
}//end if
?>
require 'includes/javascript-interfacepicker.inc.php';
// This needs more verification. Is it already added? Does it exist?
// Calculation to extract MB/GB/TB of Kbps/Mbps/Gbps
$base = $config['billing']['base'];
if ($bill_data['bill_type'] == 'quota') {
$data = $bill_data['bill_quota'];
$tmp['mb'] = ($data / $base / $base);
$tmp['gb'] = ($data / $base / $base / $base);
$tmp['tb'] = ($data / $base / $base / $base / $base);
if ($tmp['tb'] >= 1) {
$quota = array(
'type' => 'tb',
'select_tb' => ' selected',
'data' => $tmp['tb'],
);
}
else if (($tmp['gb'] >= 1) and ($tmp['gb'] < $base)) {
$quota = array(
'type' => 'gb',
'select_gb' => ' selected',
'data' => $tmp['gb'],
);
}
else if (($tmp['mb'] >= 1) and ($tmp['mb'] < $base)) {
$quota = array(
'type' => 'mb',
'select_mb' => ' selected',
'data' => $tmp['mb'],
);
}
}//end if
if ($bill_data['bill_type'] == 'cdr') {
$data = $bill_data['bill_cdr'];
$tmp['kbps'] = ($data / $base);
$tmp['mbps'] = ($data / $base / $base);
$tmp['gbps'] = ($data / $base / $base / $base);
if ($tmp['gbps'] >= 1) {
$cdr = array(
'type' => 'gbps',
'select_gbps' => ' selected',
'data' => $tmp['gbps'],
);
}
else if (($tmp['mbps'] >= 1) and ($tmp['mbps'] < $base)) {
$cdr = array(
'type' => 'mbps',
'select_mbps' => ' selected',
'data' => $tmp['mbps'],
);
}
else if (($tmp['kbps'] >= 1) and ($tmp['kbps'] < $base)) {
$cdr = array(
'type' => 'kbps',
'select_kbps' => ' selected',
'data' => $tmp['kbps'],
);
}
}//end if
?>
<form id="edit" name="edit" method="post" action="" class="form-horizontal" role="form">
<input type=hidden name="action" value="update_bill">
<script type="text/javascript">
function billType() {
$('#cdrDiv').toggle();
$('#quotaDiv').toggle();
}
</script>
<script type="text/javascript">
function billType() {
$('#cdrDiv').toggle();
$('#quotaDiv').toggle();
}
</script>
<h3>Bill Properties</h3>
<hr>
<div class="form-group">
<label class="col-sm-2 control-label" for="bill_name"><strong>Description</strong></label>
<div class="col-sm-4">
<label class="control-label" for="bill_name">
<h5><strong>Description</strong></h5>
</label>
<input class="form-control input-sm" name="bill_name" value="<?php echo $bill_data['bill_name']; ?>" />
</div>
<div class="col-sm-6">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="bill_type"><strong>Billing Type</strong></label>
<div class="col-sm-10">
<div class="col-sm-4">
<label class="control-label" for="bill_type">
<h5><strong>Billing Type</strong></h5>
</label>
<br>
<div class="radio">
<label>
<input type="radio" name="bill_type" value="cdr" onchange="javascript: billType();"
<?php
if ($bill_data['bill_type'] == 'cdr') {
echo 'checked ';
};
?>
/> CDR 95th
<input type="radio" name="bill_type" value="cdr" onchange="javascript: billType();"
<?php
if ($bill_data['bill_type'] == 'cdr') {
echo 'checked ';
};
?>
/> CDR 95th
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="bill_type" value="quota" onchange="javascript: billType();"
<?php
if ($bill_data['bill_type'] == 'quota') {
echo 'checked ';
};
?>
/> Quota
<input type="radio" name="bill_type" value="quota" onchange="javascript: billType();"
<?php
if ($bill_data['bill_type'] == 'quota') {
echo 'checked ';
};
?>
/> Quota
</label>
</div>
</div>
</div>
<div id="cdrDiv"
<?php
if ($bill_data['bill_type'] == 'quota') {
echo ' style="display: none"';
};
?>
>
<?php
if ($bill_data['bill_type'] == 'quota') {
echo ' style="display: none"';
};
?>
>
<div class="form-group">
<div class="col-sm-2">
</div>
<div class="col-sm-2">
<input class="form-control input-sm" type="text" name="bill_cdr" value="<?php echo $cdr['data']; ?>">
</div>
@ -133,15 +133,13 @@ if ($bill_data['bill_type'] == 'quota') {
</div>
</div>
<div id="quotaDiv"
<?php
if ($bill_data['bill_type'] == 'cdr') {
echo ' style="display: none"';
};
?>
>
<?php
if ($bill_data['bill_type'] == 'cdr') {
echo ' style="display: none"';
};
?>
>
<div class="form-group">
<div class="col-sm-2">
</div>
<div class="col-sm-2">
<input class="form-control input-sm" type="text" name="bill_quota" value="<?php echo $quota['data']; ?>">
</div>
@ -157,132 +155,145 @@ if ($bill_data['bill_type'] == 'cdr') {
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="bill_day"><strong>Billing Day</strong></label>
<div class="col-sm-2">
<label class="control-label" for="bill_day">
<h5><strong>Billing Day</strong></h5>
</label>
<select name="bill_day" class="form-control input">
<?php
for ($x = 1; $x < 32; $x++) {
$select = (($bill_data['bill_day'] == $x) ? ' selected' : '');
echo ' <option value="'.$x.'"'.$select.'>'.$x."</option>\n";
}
?>
<?php
for ($x = 1; $x < 32; $x++) {
$select = (($bill_data['bill_day'] == $x) ? ' selected' : '');
echo ' <option value="'.$x.'"'.$select.'>'.$x."</option>\n";
}
?>
</select>
</div>
</div>
<br>
<h3>Optional Information</h3>
<hr>
<div class="form-group">
<label class="col-sm-2 control-label" for="bill_custid"><strong>Customer&nbsp;Reference</strong></label>
<div class="col-sm-4">
<label class="control-label" for="bill_custid">
<h5><strong>Customer&nbsp;Reference</strong></h5>
</label>
<input class="form-control input-sm" type="text" name="bill_custid" value="<?php echo $bill_data['bill_custid']; ?>" />
</div>
<div class="col-sm-6">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="bill_ref"><strong>Billing Reference</strong></label>
<div class="col-sm-4">
<label class="control-label" for="bill_ref">
<h5><strong>Billing Reference</strong></h5>
</label>
<input class="form-control input-sm" type="text" name="bill_ref" value="<?php echo $bill_data['bill_ref']; ?>" />
</div>
<div class="col-sm-6">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="bill_notes"><strong>Notes</strong></label>
<div class="col-sm-4">
<label class="control-label" for="bill_notes">
<h5><strong>Notes</strong></h5>
</label>
<textarea rows="3" class="form-control input-sm" name="bill_notes" value="<?php echo $bill_data['bill_notes']; ?>"></textarea>
</div>
</div>
<button type="submit" class="btn btn-success" name="Submit" value="Save" /><i class="icon-ok icon-white"></i> <strong>Save Properties</strong></button>
<button type="submit" class="btn btn-success" name="Submit" value="Save" /><i class="fa fa-check"></i> <strong>Save Properties</strong></button>
</form>
<h3>Billed Ports</h3>
<div class="form-group">
<?php
$ports = dbFetchRows(
'SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D
WHERE B.bill_id = ? AND P.port_id = B.port_id
AND D.device_id = P.device_id ORDER BY D.device_id',
array($bill_data['bill_id'])
);
if (is_array($ports)) {
foreach ($ports as $port) {
$emptyCheck = true;
$devicebtn = str_replace('list-device', 'btn', generate_device_link($port));
$devicebtn = str_replace("overlib('", "overlib('<div style=\'border: 5px solid #e5e5e5; background: #fff; padding: 10px;\'>", $devicebtn);
$devicebtn = str_replace("<div>',;", "</div></div>',", $devicebtn);
$portbtn = str_replace('interface-upup', 'btn', generate_port_link($port));
$portbtn = str_replace('interface-updown', 'btn btn-warning', $portbtn);
$portbtn = str_replace('interface-downdown', 'btn btn-warning', $portbtn);
$portbtn = str_replace('interface-admindown', 'btn btn-warning disabled', $portbtn);
$portbtn = str_replace("overlib('", "overlib('<div style=\'border: 5px solid #e5e5e5; background: #fff; padding: 10px;\'>", $portbtn);
$portbtn = str_replace("<div>',;", "</div></div>',", $portbtn);
$portalias = (empty($port['ifAlias']) ? '' : ' - '.$port['ifAlias'].'');
$devicebtn = str_replace('">'.$port['hostname'], '" style="color: #000;"><i class="glyphicon glyphicon-asterisk"></i> '.$port['hostname'], $devicebtn);
$portbtn = str_replace('">'.strtolower($port['ifName']), '" style="color: #000;"><i class="glyphicon glyphicon-random"></i> '.$port['ifName'].''.$portalias, $portbtn);
echo ' <form action="" class="form-inline" method="post" name="delete'.$port['port_id']."\" style=\"display: none;\">\n";
echo " <input type=\"hidden\" name=\"action\" value=\"delete_bill_port\" />\n";
echo ' <input type="hidden" name="port_id" value="'.$port['port_id']."\" />\n";
echo " </form>\n";
echo " <div class=\"btn-toolbar\">\n";
echo " <div class=\"btn-group\" style=\"width: 600px;\">\n";
// echo(" <a class=\"btn btn-danger\" href=\"javascript:;\" onclick=\"document.delete".$port['port_id'].".submit();\" style=\"color: #fff;\"><i class=\"icon-trash icon-white\"></i></a>\n");
echo ' '.$devicebtn."\n";
echo ' '.$portbtn."\n";
echo " </div>\n";
echo " <div class=\"btn-group\">\n";
echo ' <a class="btn btn-danger btn-mini" href="javascript:;" onclick="document.delete'.$port['port_id'].".submit();\" style=\"color: #fff;\"><i class=\"icon-minus-sign icon-white\"></i> <strong>Remove Interface</strong></a>\n";
echo " </div>\n";
echo " </div>\n";
}//end foreach
if (!$emptyCheck) {
echo " <div class=\"alert alert-info\">\n";
echo " <i class=\"icon-info-sign\"></i> <strong>There are no ports assigned to this bill</strong>\n";
echo " </div>\n";
<br>
<h3>Billed Ports</h3>
<hr>
<div class="form-group">
<?php
//This needs a proper cleanup
$ports = dbFetchRows(
'SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D
WHERE B.bill_id = ? AND P.port_id = B.port_id
AND D.device_id = P.device_id ORDER BY D.device_id',
array($bill_data['bill_id'])
);
if (is_array($ports)) {
foreach ($ports as $port) {
$emptyCheck = true;
$devicebtn = str_replace('list-device', 'btn', generate_device_link($port));
$devicebtn = str_replace("overlib('", "overlib('<div style=\'border: 5px solid #e5e5e5; background: #fff; padding: 10px;\'>", $devicebtn);
$devicebtn = str_replace("<div>',;", "</div></div>',", $devicebtn);
$portbtn = str_replace('interface-upup', 'btn', generate_port_link($port));
$portbtn = str_replace('interface-updown', 'btn btn-warning', $portbtn);
$portbtn = str_replace('interface-downdown', 'btn btn-warning', $portbtn);
$portbtn = str_replace('interface-admindown', 'btn btn-warning disabled', $portbtn);
$portbtn = str_replace("overlib('", "overlib('<div style=\'border: 5px solid #e5e5e5; background: #fff; padding: 10px;\'>", $portbtn);
$portbtn = str_replace("<div>',;", "</div></div>',", $portbtn);
$portalias = (empty($port['ifAlias']) ? '' : ' - '.$port['ifAlias'].'');
$devicebtn = str_replace('">'.$port['hostname'], '" style="color: #000;"><i class="fa fa-asterisk"></i> '.$port['hostname'], $devicebtn);
$portbtn = str_replace('">'.strtolower($port['ifName']), '" style="color: #000;"><i class="fa fa-random"></i> '.$port['ifName'].''.$portalias, $portbtn);
echo ' <form action="" class="form-inline" method="post" name="delete'.$port['port_id']."\" style=\"display: none;\">\n";
echo " <input type=\"hidden\" name=\"action\" value=\"delete_bill_port\" />\n";
echo ' <input type="hidden" name="port_id" value="'.$port['port_id']."\" />\n";
echo " </form>\n";
echo " <div class=\"btn-toolbar\">\n";
echo " <div class=\"btn-group\" style=\"width: 600px;\">\n";
echo ' '.$devicebtn."\n";
echo ' '.$portbtn."\n";
echo " </div>\n";
echo " <div class=\"btn-group\">\n";
echo ' <a class="btn btn-danger btn-mini" href="javascript:;" onclick="document.forms[\'delete'.$port['port_id']."'].submit();\" style=\"color: #fff;\"><i class=\"fa fa-minus\"></i> <strong>Remove Interface</strong></a>\n";
echo " </div>\n";
echo " </div>\n";
}
if (!$emptyCheck) {
echo " <div class=\"alert alert-info\">\n";
echo " <i class=\"fa fa-info\"></i> <strong>There are no ports assigned to this bill</strong>\n";
echo " </div>\n";
}
}
}//end if
?>
</div>
</fieldset>
?>
</div>
</fieldset>
<form action="" method="post" class="form-horizontal" role="form">
<input type="hidden" name="action" value="add_bill_port" />
<input type="hidden" name="bill_id" value="<?php echo $bill_id; ?>" />
<br>
<h3>Add Port</h3>
<hr>
<div class="form-group">
<label class="col-sm-2 control-label" for="device"><strong>Device</strong></label>
<div class="col-sm-4">
<label class="control-label" for="device">
<h5><strong>Device</strong></h5>
</label>
<select class="form-control input-sm" id="device" name="device" onchange="getInterfaceList(this)">
<option value=''>Select a device</option>
<?php
$devices = dbFetchRows('SELECT * FROM `devices` ORDER BY hostname');
foreach ($devices as $device) {
unset($done);
foreach ($access_list as $ac) {
if ($ac == $device['device_id']) {
$done = 1;
}
}
if (!$done) {
echo " <option value='".$device['device_id']."'>".$device['hostname']."</option>\n";
}
}
?>
<?php
$devices = dbFetchRows('SELECT * FROM `devices` ORDER BY hostname');
foreach ($devices as $device) {
unset($done);
foreach ($access_list as $ac) {
if ($ac == $device['device_id']) {
$done = 1;
}
}
if (!$done) {
echo " <option value='".$device['device_id']."'>".$device['hostname']."</option>\n";
}
}
?>
</select>
</div>
<div class="col-sm-6">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="port_id"><strong>Interface</strong></label>
<div class="col-sm-4">
<label class="control-label" for="port_id">
<h5><strong>Port</strong></h5>
</label>
<select class="form-control input-sm" id="port_id" name="port_id"></select>
</div>
<div class="col-sm-6">
<div>
</div>
<button type="submit" class="btn btn-primary" name="Submit" value=" Add " /><i class="icon-plus-sign icon-white"></i> <strong>Add Interface</strong></button>
<button type="submit" class="btn btn-primary" name="Submit" value=" Add " /><i class="fa fa-plus"></i> <strong>Add Port</strong></button>
</form>

View File

@ -101,7 +101,7 @@ foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY
<td>$total_data</td>
<td>$rate_95th</td>
<td style=\"text-align: center;\">$overuse</td>
<td width=\"250\">".print_percentage_bar(250, 20, $perc, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']).'</td>
<td width=\"250\">".print_percentage_bar(250, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']).'</td>
<td>
<a href="'.$url.'"><img src="images/16/chart_curve.png" border="0" align="absmiddle" alt="Show details" title="Show details"/></a>
</td>

View File

@ -1,5 +1,4 @@
<form name="form1" action="" method="post" class="form-horizontal">
<link rel="stylesheet" href="<?php echo $config['base_url']; ?>/css/bootstrap.min.css">
<script type="text/javascript">
function showWarning() {
var checked = $('input:checked').length;
@ -13,27 +12,31 @@
}
</script>
<input type="hidden" name="action" value="reset_bill">
<fieldset>
<legend>Reset Bill</legend>
<div class="control-group">
<label class="control-label" for="confirm"><strong>Confirm</strong></label>
<div class="controls">
<label class="checkbox">
<input type="checkbox" name="confirm" value="mysql" onchange="javascript: showWarning();">
Yes, please reset MySQL data for all interfaces on this bill!
<h3>Reset Bill</h3>
<hr>
<div class="control-group">
<label class="control-label" for="confirm"><strong>Confirm</strong></label>
<div class="controls">
<div class="checkbox">
<label>
<input type="checkbox" name="confirm" value="mysql" onchange="javascript: showWarning();">
Yes, please reset MySQL data for all interfaces on this bill!
</label>
<label class="checkbox">
<input disabled type="checkbox" name="confirm" value="rrd" onchange="javascript: showWarning();">
Yes, please reset RRD data for all interfaces on this bill!
</div>
<div class="checkbox">
<label>
<input disabled type="checkbox" name="confirm" value="rrd" onchange="javascript: showWarning();">
Yes, please reset RRD data for all interfaces on this bill!
</label>
</div>
</div>
<div class="alert alert-message" id="warning" style="display: none;">
<h4 class="alert-heading"><i class="icon-warning-sign"></i> Warning!</h4>
Are you sure you want to reset all <strong>MySQL</strong> and/or <strong>RRD</strong> data for all interface on this bill?
</div>
</fieldset>
<div class="form-actions">
<button id="resetBtn" type="submit" class="btn btn-danger" disabled="disabled"><i class="icon-refresh icon-white"></i> <strong>Reset Bill</strong></button>
</div>
</form>
<br>
<div class="alert alert-danger" id="warning" style="display: none;">
<h4 class="alert-heading"><i class="fa fa-exclamation-triangle"></i> Warning</h4>
Are you sure you want to reset all <strong>MySQL</strong> and/or <strong>RRD</strong> data for all interface on this bill?
</div>
<div class="form-actions">
<button id="resetBtn" type="submit" class="btn btn-danger" disabled="disabled"><i class="fa fa-refresh"></i> <strong>Reset Bill</strong></button>
</div>
</form>

View File

@ -52,6 +52,18 @@ if ($_POST['addbill'] == 'yes') {
'bill_custid' => $_POST['bill_custid'],
'bill_ref' => $_POST['bill_ref'],
'bill_notes' => $_POST['bill_notes'],
'rate_95th_in' => 0,
'rate_95th_out' => 0,
'rate_95th' => 0,
'dir_95th' => 'in',
'total_data' => 0,
'total_data_in' => 0,
'total_data_out' => 0,
'rate_average' => 0,
'rate_average_in' => 0,
'rate_average_out' => 0,
'bill_last_calc' => array('NOW()'),
'bill_autoadded' => 0,
);
$bill_id = dbInsert($insert, 'bills');
@ -64,7 +76,7 @@ if ($_POST['addbill'] == 'yes') {
$message .= $message_break.'Port '.mres($_POST['port']).' added!';
$message_break .= '<br />';
}
}//end if
}
$pagetitle[] = 'Billing';
@ -118,10 +130,10 @@ else if ($vars['view'] == 'add') {
$devicebtn = str_replace('list-device', 'btn', generate_device_link($port));
$portbtn = str_replace('interface-upup', 'btn', generate_port_link($port));
$portalias = (empty($port['ifAlias']) ? '' : ' - '.$port['ifAlias'].'');
$devicebtn = str_replace('">'.$port['hostname'], '" style="color: #000;"><i class="icon-asterisk"></i> '.$port['hostname'], $devicebtn);
$devicebtn = str_replace('">'.$port['hostname'], '" style="color: #000;"><i class="fa fa-asterisk"></i> '.$port['hostname'], $devicebtn);
$devicebtn = str_replace("overlib('", "overlib('<div style=\'border: 5px solid #e5e5e5; background: #fff; padding: 10px;\'>", $devicebtn);
$devicebtn = str_replace("<div>',;", "</div></div>',", $devicebtn);
$portbtn = str_replace('">'.strtolower($port['ifName']), '" style="color: #000;"><i class="icon-random"></i> '.$port['ifName'].''.$portalias, $portbtn);
$portbtn = str_replace('">'.strtolower($port['ifName']), '" style="color: #000;"><i class="fa fa-random"></i> '.$port['ifName'].''.$portalias, $portbtn);
$portbtn = str_replace("overlib('", "overlib('<div style=\'border: 5px solid #e5e5e5; background: #fff; padding: 10px;\'>", $portbtn);
$portbtn = str_replace("<div>',;", "</div></div>',", $portbtn);
echo " <fieldset>\n";
@ -136,7 +148,7 @@ else if ($vars['view'] == 'add') {
echo " </div>\n";
echo " </div>\n";
echo " </fieldset>\n";
}//end if
}
?>
<div class="form-group">
@ -228,7 +240,7 @@ else if ($vars['view'] == 'add') {
<div class="col-sm-6">
</div>
</div>
<button type="submit" class="btn btn-default"><i class="icon-ok-sign icon-white"></i> <strong>Add Bill</strong></button>
<button type="submit" class="btn btn-success"><i class="fa fa-check"></i> <strong>Add Bill</strong></button>
</form>
<?php
@ -254,7 +266,6 @@ else {
$day_data = getDates($bill['bill_day']);
$datefrom = $day_data['0'];
$dateto = $day_data['1'];
// $rate_data = getRates($bill['bill_id'],$datefrom,$dateto);
$rate_data = $bill;
$rate_95th = $rate_data['rate_95th'];
$dir_95th = $rate_data['dir_95th'];
@ -304,10 +315,8 @@ else {
";
$i++;
} //end if
}//end foreach
}
}
echo '</table>';
}//end if
// echo("</td></tr></table>");
}

View File

@ -60,7 +60,7 @@ foreach (dbFetchRows('SELECT * FROM `bills` ORDER BY `bill_name`') as $bill) {
<td>$total_data</td>
<td>$rate_95th</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>
</tr>';
$i++;

Some files were not shown because too many files have changed in this diff Show More