Rebased + added OS Tests

This commit is contained in:
Neil Lathwood 2016-09-27 18:05:42 +01:00
commit ef59d5110f
628 changed files with 4214 additions and 2574 deletions

1
.gitignore vendored
View File

@ -23,3 +23,4 @@ patches
rrd
/vendor
composer.phar
librenms_theme

View File

@ -1,3 +1,4 @@
sudo: required
language: php
matrix:
fast_finish: true
@ -24,17 +25,29 @@ matrix:
- php: hhvm
cache:
directories:
- pip
- directories:
- vendor
- $HOME/.composer/cache
before_script:
before_install:
- sudo apt-get -qq update
- sudo apt-get install -y snmp
install:
- composer install --prefer-dist --no-interaction
- pip install --user snmpsim
before_script:
- python2 $HOME/.local/bin/snmpsimd.py --data-dir=$TRAVIS_BUILD_DIR/tests/snmpsim --agent-udpv4-endpoint=127.0.0.1:11161 --logging-method=file:/tmp/snmpsimd.log --daemon --pid-file=/tmp/snmpsimd.pid
after_success:
- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && test $EXECUTE_BUILD_DOCS == "true" && bash scripts/deploy-docs.sh
after_failure:
- cat /tmp/snmpsimd.log
script:
- php scripts/pre-commit.php -p -l
- php scripts/pre-commit.php -p -s
- phpunit
- php scripts/pre-commit.php -l
- php scripts/pre-commit.php -s
- SNMPSIM=1 phpunit --stop-on-failure

View File

@ -134,6 +134,7 @@ LibreNMS contributors:
- Konrad Bechler <konrad@bechler.pl> (kbechler)
- Florent Bruchez <ftbz@me.com> (ftbz)
- Bartosz Radwan <b.radwan@citypartner.pl> (bartoszradwan)
- Kate Gerry <kate@fansubber.com> (kate66)
[1]: http://observium.org/ "Observium web site"
Observium was written by:

View File

@ -54,8 +54,18 @@ class Proc
* @param bool $blocking set the output pipes to blocking (default: false)
* @throws Exception the command was unable to execute
*/
public function __construct($cmd, $descriptorspec, $cwd = null, $env = null, $blocking = false)
{
public function __construct(
$cmd,
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
),
$cwd = null,
$env = null,
$blocking = false
) {
d_echo("Starting process: $cmd");
$this->_process = proc_open($cmd, $descriptorspec, $this->_pipes, $cwd, $env);
if (!is_resource($this->_process)) {
throw new Exception("Command failed: $cmd");
@ -102,10 +112,7 @@ class Proc
*/
public function sendCommand($command)
{
if (!ends_with($command, PHP_EOL)) {
$command .= PHP_EOL;
}
$this->sendInput($command);
$this->sendInput($this->checkAddEOL($command));
return $this->getOutput();
}
@ -139,23 +146,36 @@ class Proc
return array(stream_get_contents($this->_pipes[1]), stream_get_contents($this->_pipes[2]));
}
/**
* Close all pipes for this process
*/
private function closePipes()
{
foreach ($this->_pipes as $pipe) {
if (is_resource($pipe)) {
fclose($pipe);
}
}
}
/**
* Attempt to gracefully close this process
* optionally send one last piece of input
* such as a quit command
*
* @param string $cmd the final command to send
* ** Warning: this will block until the process closes.
* Some processes might not close on their own.
*
* @param string $command the final command to send (appends newline if one is ommited)
* @return int the exit status of this process (-1 means error)
*/
public function close($cmd = null)
public function close($command = null)
{
if (isset($cmd)) {
$this->sendInput($cmd);
if (isset($command)) {
$this->sendInput($this->checkAddEOL($command));
}
fclose($this->_pipes[0]);
fclose($this->_pipes[1]);
fclose($this->_pipes[2]);
$this->closePipes();
return proc_close($this->_process);
}
@ -172,8 +192,7 @@ class Proc
{
$status = $this->getStatus();
fclose($this->_pipes[1]);
fclose($this->_pipes[2]);
$this->closePipes();
$closed = proc_terminate($this->_process, $signal);
@ -234,4 +253,19 @@ class Proc
{
$this->_synchronous = $synchronous;
}
/**
* Add and end of line character to a string if
* it doesn't already end with one
*
* @param $string
* @return string
*/
private function checkAddEOL($string)
{
if (!ends_with($string, PHP_EOL)) {
$string .= PHP_EOL;
}
return $string;
}
}

View File

@ -96,9 +96,9 @@ Output
Input to the API is done in three different ways, sometimes a combination two or three of these.
- Passing parameters via the api route. For example when obtaining a devices details you will pass the hostname of the device in the route: `/api/v0/devices/:hostname`.
- Passing parameters via the query string. For example you can list all devices on your install but limit the output to devices that are currently down: `/api/v0/devices?type=down`
- Passing data in via JSON, this will mainly be used when adding or updating information via the API, for instance adding a new device:
- Passing parameters via the api route. For example when obtaining a devices details you will pass the hostname of the device in the route: `/api/v0/devices/:hostname`.
- Passing parameters via the query string. For example you can list all devices on your install but limit the output to devices that are currently down: `/api/v0/devices?type=down`
- Passing data in via JSON, this will mainly be used when adding or updating information via the API, for instance adding a new device:
```curl
curl -X POST -d '{"hostname":"localhost.localdomain","version":"v1","community":"public"}'-H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/devices
```
@ -107,8 +107,8 @@ curl -X POST -d '{"hostname":"localhost.localdomain","version":"v1","community":
Output from the API currently is via two output types.
- JSON Most API responses will output json. As show in the example for calling the API endpoint.
- PNG This is for when the request is for an image such as a graph for a switch port.
- JSON Most API responses will output json. As show in the example for calling the API endpoint.
- PNG This is for when the request is for an image such as a graph for a switch port.
# <a name="api-endpoints">`Endpoints`</a> [`top`](#top)
@ -120,11 +120,11 @@ Delete a given device.
Route: /api/v0/devices/:hostname
- hostname can be either the device hostname or id
- hostname can be either the device hostname or id
Input:
-
-
Example:
```curl
@ -154,11 +154,11 @@ Get details of a given device.
Route: /api/v0/devices/:hostname
- hostname can be either the device hostname or id
- hostname can be either the device hostname or id
Input:
-
-
Example:
```curl
@ -187,11 +187,11 @@ Get a list of available graphs for a device, this does not include ports.
Route: /api/v0/devices/:hostname/graphs
- hostname can be either the device hostname or id
- hostname can be either the device hostname or id
Input:
-
-
Example:
```curl
@ -227,15 +227,15 @@ Get a specific graph for a device, this does not include ports.
Route: /api/v0/devices/:hostname/:type
- hostname can be either the device hostname or id
- type is the type of graph you want, use [`get_graphs`](#api-route-5) to see the graphs available. Defaults to device_uptime.
- hostname can be either the device hostname or id
- type is the type of graph you want, use [`get_graphs`](#api-route-5) to see the graphs available. Defaults to device_uptime.
Input:
- from: This is the date you would like the graph to start - See http://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html for more information.
- 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.
- from: This is the date you would like the graph to start - See http://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html for more information.
- 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.
Example:
```curl
@ -252,11 +252,11 @@ Get a list of ports for a particular device.
Route: /api/v0/devices/:hostname/ports
- hostname can be either the device hostname or id
- hostname can be either the device hostname or id
Input:
- columns: Comma separated list of columns you want returned.
- columns: Comma separated list of columns you want returned.
Example:
```curl
@ -290,11 +290,11 @@ Get a list of port mappings for a device. This is useful for showing physical p
Route: /api/v0/devices/:hostname/port_stack
- hostname can be either the device hostname or id
- hostname can be either the device hostname or id
Input:
- valid_mappings: Filter the result by only showing valid mappings ("0" values not shown).
- valid_mappings: Filter the result by only showing valid mappings ("0" values not shown).
Example:
```curl
@ -331,16 +331,16 @@ Get a list of components for a particular device.
Route: /api/v0/devices/:hostname/components
- hostname can be either the device hostname or id
- hostname can be either the device hostname or id
Input:
- type: Filter the result by type (Equals).
- id: Filter the result by id (Equals).
- label: Filter the result by label (Contains).
- status: Filter the result by status (Equals).
- disabled: Filter the result by disabled (Equals).
- ignore: Filter the result by ignore (Equals).
- type: Filter the result by type (Equals).
- id: Filter the result by id (Equals).
- label: Filter the result by label (Contains).
- status: Filter the result by status (Equals).
- disabled: Filter the result by disabled (Equals).
- ignore: Filter the result by ignore (Equals).
Example:
```curl
@ -395,8 +395,8 @@ Create a new component of a type on a particular device.
Route: /api/v0/devices/:hostname/components/:type
- hostname can be either the device hostname or id
- type is the type of component to add
- hostname can be either the device hostname or id
- type is the type of component to add
Example:
```curl
@ -429,7 +429,7 @@ Edit an existing component on a particular device.
Route: /api/v0/devices/:hostname/components
- hostname can be either the device hostname or id
- hostname can be either the device hostname or id
In this example we set the label and add a new field: TestField:
```curl
@ -454,8 +454,8 @@ Delete an existing component on a particular device.
Route: /api/v0/devices/:hostname/components/:component
- hostname can be either the device hostname or id
- component is the component ID to be deleted.
- hostname can be either the device hostname or id
- component is the component ID to be deleted.
Example:
```curl
@ -477,12 +477,12 @@ Get information about a particular port for a device.
Route: /api/v0/devices/:hostname/ports/:ifname
- hostname can be either the device hostname or id
- ifname can be any of the interface names for the device which can be obtained using [`get_port_graphs`](#api-route-7). Please ensure that the ifname is urlencoded if it needs to be (i.e Gi0/1/0 would need to be urlencoded.
- hostname can be either the device hostname or id
- ifname can be any of the interface names for the device which can be obtained using [`get_port_graphs`](#api-route-7). Please ensure that the ifname is urlencoded if it needs to be (i.e Gi0/1/0 would need to be urlencoded.
Input:
- columns: Comma separated list of columns you want returned.
- columns: Comma separated list of columns you want returned.
Example:
```curl
@ -510,17 +510,17 @@ Get a graph of a port for a particular device.
Route: /api/v0/devices/:hostname/ports/:ifname/:type
- hostname can be either the device hostname or id
- ifname can be any of the interface names for the device which can be obtained using [`get_port_graphs`](#api-route-7). Please ensure that the ifname is urlencoded if it needs to be (i.e Gi0/1/0 would need to be urlencoded.
- type is the port type you want the graph for, you can request a list of ports for a device with [`get_port_graphs`](#api-route-7).
- hostname can be either the device hostname or id
- ifname can be any of the interface names for the device which can be obtained using [`get_port_graphs`](#api-route-7). Please ensure that the ifname is urlencoded if it needs to be (i.e Gi0/1/0 would need to be urlencoded.
- type is the port type you want the graph for, you can request a list of ports for a device with [`get_port_graphs`](#api-route-7).
Input:
- from: This is the date you would like the graph to start - See http://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html for more information.
- 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.
- from: This is the date you would like the graph to start - See http://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html for more information.
- 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
@ -539,17 +539,17 @@ Route: /api/v0/devices
Input:
- order: How to order the output, default is by hostname. Can be prepended by DESC or ASC to change the order.
- type: can be one of the following to filter or search by:
- all: All devices
- ignored: Only ignored devices
- up: Only devices that are up
- down: Only devices that are down
- disabled: Disabled devices
- mac: search by mac address
- ipv4: search by IPv4 address
- ipv6: search by IPv6 address (compressed or uncompressed)
- query: If searching by, then this will be used as the input.
- order: How to order the output, default is by hostname. Can be prepended by DESC or ASC to change the order.
- type: can be one of the following to filter or search by:
- all: All devices
- ignored: Only ignored devices
- up: Only devices that are up
- down: Only devices that are down
- disabled: Disabled devices
- mac: search by mac address
- ipv4: search by IPv4 address
- ipv6: search by IPv6 address (compressed or uncompressed)
- query: If searching by, then this will be used as the input.
Example:
```curl
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/devices?order=hostname%20DESC&type=down
@ -604,25 +604,25 @@ Route: /api/v0/devices
Input (JSON):
- hostname: device hostname
- port: SNMP port (defaults to port defined in config).
- transport: SNMP protocol (defaults to transport defined in config).
- version: SNMP version to use, v1, v2c or v3. Defaults to v2c.
- poller_group: This is the poller_group id used for distributed poller setup. Defaults to 0.
- force_add: Force the device to be added regardless of it being able to respond to snmp or icmp.
- hostname: device hostname
- port: SNMP port (defaults to port defined in config).
- transport: SNMP protocol (defaults to transport defined in config).
- version: SNMP version to use, v1, v2c or v3. Defaults to v2c.
- poller_group: This is the poller_group id used for distributed poller setup. Defaults to 0.
- force_add: Force the device to be added regardless of it being able to respond to snmp or icmp.
For SNMP v1 or v2c
For SNMP v1 or v2c
- community: Required for SNMP v1 or v2c.
- community: Required for SNMP v1 or v2c.
For SNMP v3
For SNMP v3
- authlevel: SNMP authlevel (NoAuthNoPriv, AuthNoPriv, AuthPriv).
- authname: SNMP Auth username
- authpass: SNMP Auth password
- authalgo: SNMP Auth algorithm (MD5, SHA)
- cryptopass: SNMP Crypto Password
- cryptoalgo: SNMP Crypto algorithm (AES, DES)
- authlevel: SNMP authlevel (NoAuthNoPriv, AuthNoPriv, AuthPriv).
- authname: SNMP Auth username
- authpass: SNMP Auth password
- authalgo: SNMP Auth algorithm (MD5, SHA)
- cryptopass: SNMP Crypto Password
- cryptoalgo: SNMP Crypto algorithm (AES, DES)
Example:
```curl
@ -646,7 +646,7 @@ Route: /api/v0/oxidized
Input (JSON):
-
-
Examples:
```curl
@ -674,7 +674,7 @@ Update devices field in the database.
Route: /api/v0/devices/:hostname
- hostname can be either the device hostname or id
- hostname can be either the device hostname or id
Input (JSON):
@ -703,7 +703,7 @@ 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
- hostname can be either the device hostname or id
Input (JSON):
@ -775,7 +775,7 @@ 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.
- 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):
@ -818,7 +818,7 @@ Route: /api/v0/bgp
Input:
- hostname = either the devices hostname or id.
- hostname = either the devices hostname or id.
Example:
```curl
@ -843,11 +843,11 @@ List the current IPSec tunnels which are active.
Route: /api/v0/routing/ipsec/data/:hostname
- hostname can be either the device hostname or id
- hostname can be either the device hostname or id
Input:
-
-
Example:
```curl
@ -882,11 +882,11 @@ Get a list of all VLANs for a given device.
Route: /api/v0/devices/:hostname/vlans
- hostname can be either the device hostname or id
- hostname can be either the device hostname or id
Input:
-
-
Example:
```curl
@ -918,11 +918,11 @@ Get details of an alert
Route: /api/v0/alerts/:id
- id is the alert id, you can obtain a list of alert ids from [`list_alerts`](#api-route-14).
- id is the alert id, you can obtain a list of alert ids from [`list_alerts`](#api-route-14).
Input:
-
-
Example:
```curl
@ -955,11 +955,11 @@ Acknowledge an alert
Route: /api/v0/alerts/:id
- id is the alert id, you can obtain a list of alert ids from [`list_alerts`](#api-route-14).
- id is the alert id, you can obtain a list of alert ids from [`list_alerts`](#api-route-14).
Input:
-
-
Example:
```curl
@ -981,11 +981,11 @@ Unmute an alert
Route: /api/v0/alerts/unmute/:id
- id is the alert id, you can obtain a list of alert ids from [`list_alerts`](#api-route-14).
- id is the alert id, you can obtain a list of alert ids from [`list_alerts`](#api-route-14).
Input:
-
-
Example:
```curl
@ -1010,7 +1010,7 @@ Route: /api/v0/alerts
Input:
- state: Filter the alerts by state, 0 = ok, 1 = alert, 2 = ack
- state: Filter the alerts by state, 0 = ok, 1 = alert, 2 = ack
Example:
```curl
@ -1044,11 +1044,11 @@ Get the alert rule details.
Route: /api/v0/rules/:id
- id is the rule id.
- id is the rule id.
Input:
-
-
Example:
```curl
@ -1081,11 +1081,11 @@ Delete an alert rule by id
Route: /api/v0/rules/:id
- id is the rule id.
- id is the rule id.
Input:
-
-
Example:
```curl
@ -1107,11 +1107,11 @@ List the alert rules.
Route: /api/v0/rules
-
-
Input:
-
-
Example:
```curl
@ -1143,20 +1143,19 @@ Add a new alert rule.
Route: /api/v0/rules
-
-
Input (JSON):
- device_id: This is either the device id or -1 for a global rule
- rule: The rule which should be in the format %entity $condition $value (i.e %devices.status != 0 for devices marked as down).
- severity: The severity level the alert will be raised against, Ok, Warning, Critical.
- disabled: Whether the rule will be disabled or not, 0 = enabled, 1 = disabled
- count: This is how many polling runs before an alert will trigger and the frequency.
- delay: Delay is when to start alerting and how frequently. The value is stored in seconds but you can specify minutes, hours or days by doing 5 m, 5 h, 5 d for each one.
- mute: If mute is enabled then an alert will never be sent but will show up in the Web UI (true or false).
- invert: This would invert the rules check.
- name: This is the name of the rule and is mandatory.
- device_id: This is either the device id or -1 for a global rule
- rule: The rule which should be in the format %entity $condition $value (i.e %devices.status != 0 for devices marked as down).
- severity: The severity level the alert will be raised against, Ok, Warning, Critical.
- disabled: Whether the rule will be disabled or not, 0 = enabled, 1 = disabled
- count: This is how many polling runs before an alert will trigger and the frequency.
- delay: Delay is when to start alerting and how frequently. The value is stored in seconds but you can specify minutes, hours or days by doing 5 m, 5 h, 5 d for each one.
- mute: If mute is enabled then an alert will never be sent but will show up in the Web UI (true or false).
- invert: This would invert the rules check.
- name: This is the name of the rule and is mandatory.
Example:
```curl
@ -1178,20 +1177,20 @@ Edit an existing alert rule
Route: /api/v0/rules
-
-
Input (JSON):
- rule_id: You must specify the rule_id to edit an existing rule, if this is absent then a new rule will be created.
- device_id: This is either the device id or -1 for a global rule
- rule: The rule which should be in the format %entity $condition $value (i.e %devices.status != 0 for devices marked as down).
- severity: The severity level the alert will be raised against, Ok, Warning, Critical.
- disabled: Whether the rule will be disabled or not, 0 = enabled, 1 = disabled
- count: This is how many polling runs before an alert will trigger and the frequency.
- delay: Delay is when to start alerting and how frequently. The value is stored in seconds but you can specify minutes, hours or days by doing 5 m, 5 h, 5 d for each one.
- mute: If mute is enabled then an alert will never be sent but will show up in the Web UI (true or false).
- invert: This would invert the rules check.
- name: This is the name of the rule and is mandatory.
- rule_id: You must specify the rule_id to edit an existing rule, if this is absent then a new rule will be created.
- device_id: This is either the device id or -1 for a global rule
- rule: The rule which should be in the format %entity $condition $value (i.e %devices.status != 0 for devices marked as down).
- severity: The severity level the alert will be raised against, Ok, Warning, Critical.
- disabled: Whether the rule will be disabled or not, 0 = enabled, 1 = disabled
- count: This is how many polling runs before an alert will trigger and the frequency.
- delay: Delay is when to start alerting and how frequently. The value is stored in seconds but you can specify minutes, hours or days by doing 5 m, 5 h, 5 d for each one.
- mute: If mute is enabled then an alert will never be sent but will show up in the Web UI (true or false).
- invert: This would invert the rules check.
- name: This is the name of the rule and is mandatory.
Example:
```curl
@ -1215,12 +1214,12 @@ Retrieve the inventory for a device. If you call this without any parameters the
Route: /api/v0/inventory/:hostname
- hostname can be either the device hostname or the device id
- hostname can be either the device hostname or the device id
Input:
- entPhysicalClass: This is used to restrict the class of the inventory, for example you can specify chassis to only return items in the inventory that are labelled as chassis.
- entPhysicalContainedIn: This is used to retrieve items within the inventory assigned to a previous component, for example specifying the chassis (entPhysicalIndex) will retrieve all items where the chassis is the parent.
- entPhysicalClass: This is used to restrict the class of the inventory, for example you can specify chassis to only return items in the inventory that are labelled as chassis.
- entPhysicalContainedIn: This is used to retrieve items within the inventory assigned to a previous component, for example specifying the chassis (entPhysicalIndex) will retrieve all items where the chassis is the parent.
Example:
```curl
@ -1321,9 +1320,9 @@ Route: /api/v0/bills/:id
/api/v0/bills?ref=:ref
/api/v0/bills?custid=:custid
- id is the specific bill id
- ref is the billing reference
- custid is the customer reference
- id is the specific bill id
- ref is the billing reference
- custid is the customer reference
Input:
@ -1379,11 +1378,11 @@ Retrieve a specific ARP entry or all ARP enties for a device
Route: /api/v0/resources/ip/arp/:ip
- ip is the specific IP you would like to query, if this is all then you need to pass ?device=_hostname_ (or device id)
- ip is the specific IP you would like to query, if this is all then you need to pass ?device=_hostname_ (or device id)
Input:
- device if you specify all for the IP then you need to populate this with the hostname or id of the device.
- device if you specify all for the IP then you need to populate this with the hostname or id of the device.
Example:
```curl
@ -1416,8 +1415,8 @@ Route: /api/v0/services
Input:
- state: only which have a certain state (valid options are 0=Ok, 1=Warning, 2=Critical).
- type: service type, used sql LIKE to find services, so for tcp, use type=tcp for http use type=http
- state: only which have a certain state (valid options are 0=Ok, 1=Warning, 2=Critical).
- type: service type, used sql LIKE to find services, so for tcp, use type=tcp for http use type=http
Example:
```curl
@ -1474,12 +1473,12 @@ Retrieve services for device
Route: /api/v0/services/:hostname
- id or hostname is the specific device
- id or hostname is the specific device
Input:
- state: only which have a certain state (valid options are 0=Ok, 1=Warning, 2=Critical).
- type: service type, used sql LIKE to find services, so for tcp, use type=tcp for http use type=http
- state: only which have a certain state (valid options are 0=Ok, 1=Warning, 2=Critical).
- type: service type, used sql LIKE to find services, so for tcp, use type=tcp for http use type=http
Example:
```curl

View File

@ -0,0 +1,476 @@
source: Developing/Support-New-OS.md
This document will explain how to add basic and full support for a new OS. **Some knowledge in PHP is needed for the full support.**
#### BASIC SUPPORT FOR A NEW OS
### MIB
If we have the MIB, we can copy the file into the default directory:
```bash
/opt/librenms/mibs
```
#### New OS definition
Let's begin to declare the new OS in LibreNMS. At first we modify the definition file located here:
```bash
includes/definitions.inc.php
```
```php
// Pulse Secure OS definition
$os = 'pulse';
$config['os'][$os]['text'] = 'Pulse Secure';
$config['os'][$os]['type'] = 'firewall';
$config['os'][$os]['icon'] = 'junos';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Device Traffic';
$config['os'][$os]['over'][1]['graph'] = 'device_processor';
$config['os'][$os]['over'][1]['text'] = 'CPU Usage';
$config['os'][$os]['over'][2]['graph'] = 'device_mempool';
$config['os'][$os]['over'][2]['text'] = 'Memory Usage';
//The icon described before is the image we have to create and put in the directory html/images/os
```
#### Discovery OS
We create a new file named as our OS definition and in this directory:
```bash
includes/discovery/os/pulse.inc.php
```
This file just sets the $os variable, done by checking the SNMP tree for a particular value that matches the OS you are adding. Typically, this will come from the presence of specific values in sysObjectID or sysDescr, or the existence of a particular enterprise tree.
Look at other files to get help in the code structure.
```php
<?php
if (!$os) {
if (str_contains($sysDescr, 'Pulse Connect Secure')) {
$os = 'pulse';
}
}
```
Here is the file location for polling the new OS within a vendor MIB or a standard one:
```bash
includes/polling/os/pulse.inc.php
```
This file will usually set the variables for $version, $hardware and $hostname retrieved from an snmp lookup.
```php
<?php
$version = trim(snmp_get($device, "productVersion.0", "-OQv", "PULSESECURE-PSG-MIB"),'"');
$hardware = "Juniper " . trim(snmp_get($device, "productName.0", "-OQv", "PULSESECURE-PSG-MIB"),'"');
$hostname = trim(snmp_get($device, "sysName.0", "-OQv", "SNMPv2-MIB"),'"');
```
Quick explanation and examples :
```bash
snmpwalk -v2c -c public -m SNMPv2-MIB -M mibs
//will give the overall OIDs that can be retrieve with this standard MIB. OID on the left side and the result on the right side
//Then we have just to pick the wanted OID and do a check
snmpget -v2c -c public -OUsb -m SNMPv2-MIB -M /opt/librenms/mibs -t 30 HOSTNAME SNMPv2-SMI::mib-2.1.1.0
//sysDescr.0 = STRING: Juniper Networks,Inc,Pulse Connect Secure,VA-DTE,8.1R1 (build 33493)
snmpget -v2c -c public -OUsb -m SNMPv2-MIB -M /opt/librenms/mibs -t 30 HOSTNAME SNMPv2-SMI::mib-2.1.5.0
//sysName.0 = STRING: pulse-secure
//Here the same with the vendor MIB and the specific OID
snmpget -v2c -c public -OUsb -m PULSESECURE-PSG-MIB -M /opt/librenms_old/mibs -t 30 HOSTNAME productName.0
//productName.0 = STRING: "Pulse Connect Secure,VA-DTE"
snmpget -v2c -c public -OUsb -m PULSESECURE-PSG-MIB -M /opt/librenms/mibs -t 30 HOSTNAME productVersion.0
//productVersion.0 = STRING: "8.1R1 (build 33493)"
```
#### The final check
Discovery
```bash
./discovery.php -h HOSTNAME
```
Polling
```bash
./poller.php -h HOSTNAME
```
At this step we should see all the values retrieved in LibreNMS.
### Full support for a new OS
#### MIB
At first we copy the MIB file into the default directory:
```bash
/opt/librenms/mibs
```
We are now ready to look at inside the file and find the OID we want to use. _For this documentation we'll use Pulse Secure devices._
Then we can test it with the snmpget command (hostname must be reachable):
```bash
//for example the OID iveCpuUtil.0:
snmpget -v2c -c public -OUsb -m PULSESECURE-PSG-MIB -M /opt/librenms/mibs -t 30 HOSTNAME iveCpuUtil.0
//quick explanation : snmpget -v2c -c COMMUNITY -OUsb -m MIBFILE -M MIB DIRECTORY HOSTNAME OID
//Result here:
iveCpuUtil.0 = Gauge32: 28
```
#### New OS definition
Let's begin to declare the new OS in LibreNMS. At first we modify the definition file located here:
```bash
includes/definitions.inc.php
```
```php
// Pulse Secure OS definition
$os = 'pulse';
$config['os'][$os]['text'] = 'Pulse Secure';
$config['os'][$os]['type'] = 'firewall';
$config['os'][$os]['icon'] = 'junos';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Device Traffic';
$config['os'][$os]['over'][1]['graph'] = 'device_processor';
$config['os'][$os]['over'][1]['text'] = 'CPU Usage';
$config['os'][$os]['over'][2]['graph'] = 'device_mempool';
$config['os'][$os]['over'][2]['text'] = 'Memory Usage';
//The icon described before is the image we have to create and put in the directory html/images/os
//Don't forget to declare the specific graphs if needed. It will be located near the end of the file.
//Pulse Secure Graphs
$config['graph_types']['device']['pulse_users']['section'] = 'firewall';
$config['graph_types']['device']['pulse_users']['order'] = '0';
$config['graph_types']['device']['pulse_users']['descr'] = 'Active Users';
$config['graph_types']['device']['pulse_sessions']['section'] = 'firewall';
$config['graph_types']['device']['pulse_sessions']['order'] = '0';
$config['graph_types']['device']['pulse_sessions']['descr'] = 'Active Sessions';
```
#### Discovery OS
We create a new file named as our OS definition and in this directory:
```bash
includes/discovery/os/pulse.inc.php
```
Look at other files to get help in the code structure. For this example, it can be like this :
```php
// Pulse Secure OS definition
<?php
if (!$os) {
if (strstr($sysDescr, 'Pulse Connect Secure')) {
$os = 'pulse';
}
}
```
As we declared Memory and CPU graphs before, we declare the OID in a PHP file :
**Memory**
```bash
includes/discovery/mempools/pulse.inc.php
```
```php
<?php
//
// Hardcoded discovery of Memory usage on Pulse Secure devices.
//
if ($device['os'] == 'pulse') {
echo 'PULSE-MEMORY-POOL: ';
$usage = str_replace('"', "", snmp_get($device, 'PULSESECURE-PSG-MIB::iveMemoryUtil.0', '-OvQ'));
if (is_numeric($usage)) {
discover_mempool($valid_mempool, $device, 0, 'pulse-mem', 'Main Memory', '100', null, null);
}
}
```
**CPU**
```bash
includes/discovery/processors/pulse.inc.php
```
```php
<?php
//
// Hardcoded discovery of CPU usage on Pulse Secure devices.
//
if ($device['os'] == 'pulse') {
echo 'Pulse Secure : ';
$descr = 'Processor';
$usage = str_replace('"', "", snmp_get($device, 'PULSESECURE-PSG-MIB::iveCpuUtil.0', '-OvQ'));
if (is_numeric($usage)) {
discover_processor($valid['processor'], $device, 'PULSESECURE-PSG-MIB::iveCpuUtil.0', '0', 'pulse-cpu', $descr,
'100', $usage, null, null);
}
}
```
_Please keep in mind that the PHP code is often different for the needs of the devices and the information we retrieve._
#### Polling OS
We will now do the same for the polling process:
**Memory**
```bash
includes/polling/mempools/pulse-mem.inc.php
```
```php
<?php
// Simple hard-coded poller for Pulse Secure
echo 'Pulse Secure MemPool'.'\n';
if ($device['os'] == 'pulse') {
$perc = str_replace('"', "", snmp_get($device, "PULSESECURE-PSG-MIB::iveMemoryUtil.0", '-OvQ'));
$memory_available = str_replace('"', "", snmp_get($device, "UCD-SNMP-MIB::memTotalReal.0", '-OvQ'));
$mempool['total'] = $memory_available;
if (is_numeric($perc)) {
$mempool['used'] = ($memory_available / 100 * $perc);
$mempool['free'] = ($memory_available - $mempool['used']);
}
echo "PERC " .$perc."%\n";
echo "Avail " .$mempool['total']."\n";
}
```
**CPU**
```bash
includes/polling/processors/pulse-cpu.inc.php
```
```php
<?php
// Simple hard-coded poller for Pulse Secure
echo 'Pulse Secure CPU Usage';
if ($device['os'] == 'pulse') {
$usage = str_replace('"', "", snmp_get($device, 'PULSESECURE-PSG-MIB::iveCpuUtil.0', '-OvQ'));
if (is_numeric($usage)) {
$proc = ($usage * 100);
}
}
```
Here is the file location for the specific graphs based on the OID in the vendor MIB:
```bash
includes/polling/os/pulse.inc.php
```
We declare two specific graphs for users and sessions numbers. Theses two graphs will be displayed on the firewall section of the graphs tab as it was written in the definition include file.
```php
<?php
$version = trim(snmp_get($device, "productVersion.0", "-OQv", "PULSESECURE-PSG-MIB"),'"');
$hardware = "Juniper " . trim(snmp_get($device, "productName.0", "-OQv", "PULSESECURE-PSG-MIB"),'"');
$hostname = trim(snmp_get($device, "sysName.0", "-OQv", "SNMPv2-MIB"),'"');
$users = snmp_get($device, 'PULSESECURE-PSG-MIB::iveConcurrentUsers.0', '-OQv');
if (is_numeric($users)) {
$rrd_def = 'DS:users:GAUGE:600:0:U';
$fields = array(
'users' => $users
)
$tags = compact('rrd_def');
data_update($device, 'pulse_users', $tags, $fields);
$graphs['pulse_users'] = true;
}
$sessions = snmp_get($device, 'PULSESECURE-PSG-MIB::iveConcurrentUsers.0', '-OQv');
if (is_numeric($sessions)) {
$rrd_def = array(
'DS:sessions:GAUGE:600:0:U',
}
$fields = array(
'sessions' => $sessions
);
$tags = compact('rrd_def');
data_update($device, 'pulse_sessions', $tags, $fields);
$graphs['pulse_sessions'] = true;
}
```
We finish in the declaration of the two graph types in the database:
We can do that within a file to share our work and contribute in the development of LibreNMS. :-)
```bash
sql-schema/xxx.sql
//check the file number in GitHub
php includes/sql-schema/update.php
```
Or put the SQL commands directly in Mysql or PhpMyadmin for our tests:
```php
INSERT INTO `graph_types`(`graph_type`, `graph_subtype`, `graph_section`, `graph_descr`, `graph_order`) VALUES ('device', 'pulse_users', 'firewall', 'Active Users', '');
INSERT INTO `graph_types`(`graph_type`, `graph_subtype`, `graph_section`, `graph_descr`, `graph_order`) VALUES ('device', 'pulse_sessions', 'firewall', 'Active Sessions', '');
```
#### Displaying
The specific graphs are not displayed automatically so we need to write the following PHP code:
**Pulse Sessions**
```bash
html/includes/graphs/device/pulse_sessions.inc.php
```
```php
<?php
$rrd_filename = rrd_name($device['hostname'], 'pulse_sessions');
require 'includes/graphs/common.inc.php';
$ds = 'sessions';
$colour_area = '9999cc';
$colour_line = '0000cc';
$colour_area_max = '9999cc';
$graph_max = 1;
$graph_min = 0;
$unit_text = 'Sessions';
require 'includes/graphs/generic_simplex.inc.php';
```
**Pulse Users**
```bash
html/includes/graphs/device/pulse_users.inc.php
```
```php
<?php
$rrd_filename = rrd_name($device['hostname'], 'pulse_users');
require 'includes/graphs/common.inc.php';
$ds = 'users';
$colour_area = '9999cc';
$colour_line = '0000cc';
$colour_area_max = '9999cc';
$graph_max = 1;
$unit_text = 'Users';
require 'includes/graphs/generic_simplex.inc.php';
```
#### The final check
Discovery
```bash
./discovery.php -h HOSTNAME
```
Polling
```bash
./poller.php -h HOSTNAME
```
At this step we should see all the values retrieved in LibreNMS.
### OS Test units
We have a testing unit for new OS', please ensure you add a test for any new OS' or updates to existing OS discovery.
The OS test unit file is located `tests/OSDiscoveryTest.php`. An example of this is as follows:
```php
public function testNios()
{
$this->checkOS('nios');
$this->checkOS('nios', 'nios-ipam');
}
```
We utilise [snmpsim](http://snmpsim.sourceforge.net/) to do unit testing for OS discovery. For this to work you need
to supply an snmprec file. This is pretty simple and using nios as the example again this would look like:
```
1.3.6.1.2.1.1.1.0|4|Linux 3.14.25 #1 SMP Thu Jun 16 18:19:37 EDT 2016 x86_64
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.7779.1.1402
```
During testing LibreNMS will use any info in the snmprec file for snmp calls. This one provides
sysDescr (`.1.3.6.1.2.1.1.1.0`, 4 = Octet String) and sysObjectID (`.1.3.6.1.2.1.1.2.0`, 6 = Object Identifier),
which is the minimum that should be provided for new snmprec files.
To look up the numeric OID and type of an string OID with snmptranslate:
```bash
snmptranslate -On -Td SNMPv2-MIB::sysDescr.0
```
Common OIDs used in discovery:
| String OID | Numeric OID |
| ----------------------------------- | --------------------------- |
| SNMPv2-MIB::sysDescr.0 | 1.3.6.1.2.1.1.1.0 |
| SNMPv2-MIB::sysObjectID.0 | 1.3.6.1.2.1.1.2.0 |
| ENTITY-MIB::entPhysicalDescr.1 | 1.3.6.1.2.1.47.1.1.1.1.2.1 |
| ENTITY-MIB::entPhysicalMfgName.1 | 1.3.6.1.2.1.47.1.1.1.1.12.1 |
| SML-MIB::product-Name.0 | 1.3.6.1.4.1.2.6.182.3.3.1.0 |
List of SNMP data types:
| Type | Value |
| ----------------- | ------------- |
| OCTET STRING | 4 |
| Integer32 | 2 |
| NULL | 5 |
| OBJECT IDENTIFIER | 6 |
| IpAddress | 64 |
| Counter32 | 65 |
| Gauge32 | 66 |
| TimeTicks | 67 |
| Opaque | 68 |
| Counter64 | 70 |
You can run `./scripts/pre-commit.php -u` to run the unit tests to check your code.
If you would like to run tests locally against a full snmpsim instance, run `./scripts/pre-commit.php -u --snmpsim`.

View File

@ -22,6 +22,7 @@ Different applications support a variety of ways collect data: by direct connect
1. [TinyDNS/djbdns](#tinydns-aka-djbdns) - Agent
1. [Unbound](#unbound) - Agent
1. [UPS-nut](#ups-nut) - SNMP extend
1. [UPS-apcups](#ups-apcups) - SNMP extend
1. [Agent Setup](#agent-setup)
@ -38,8 +39,11 @@ wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/apach
extend apache /etc/snmp/apache-stats.py
```
4. Restart snmpd on your host
5. On the device page in Librenms, edit your host and check the `Apache` under the Applications tab.
(In some cases urlgrabber needs to be installed, in Debian it can be achieved by: apt-get install python-urlgrabber)
5. Verify it is working by running /usr/lib/check_mk_agent/local/apache
6. (In some cases urlgrabber needs to be installed, in Debian it can be achieved by: apt-get install python-urlgrabber)
7. (If you get error like "Can't locate LWP/Simple.pm". libwww-perl needs to be installed, apt-get install libwww-perl)
8. On the device page in Librenms, edit your host and check the `Apache` under the Applications tab.
### BIND9 aka named
@ -323,6 +327,21 @@ extend ups-nut /etc/snmp/ups-nut.sh
### UPS-apcups
A small shell script that exports apcacess ups status.
##### SNMP Extend
1. Copy the [ups apcups](https://github.com/librenms/librenms-agent/blob/master/snmp/ups-apcups.sh) to `/etc/snmp/` on your host.
2. Make the script executable (chmod +x /etc/snmp/ups-apcups.sh)
3. Edit your snmpd.conf file (usually /etc/snmp/snmpd.conf) and add:
```
extend ups-apcups /etc/snmp/ups-apcups.sh
```
4. Restart snmpd on your host
5. On the device page in Librenms, edit your host and check the `UPS apcups` under the Applications tab.
Agent Setup
-----------

View File

@ -8,7 +8,7 @@ If you have rrdcached 1.5.5 or above, we can also tune over rrdcached.
To enable this set the following config:
```php
$config['rrdtool_version'] = 1.5.5;
$config['rrdtool_version'] = '1.5.5';
```
### Support matrix

View File

@ -1,11 +1,25 @@
source: General/Releases.md
# LibreNMS Releases
#### Introduction
We try to ensure that breaking changes aren't introduced by utilising various automated
code testing, syntax testing and unit testing along with manual code review. However
bugs can and do get introduced as well as major refactoring to improve the quality of
the code base.
#### Development branch
Our `master` branch is our dev branch, this is actively commited to and it's not uncommon
for multiple commits to be merged in daily. As such sometimes changes will be introduced
which will cause unintended issues. If this happens we are usually quick to fix or
revert those changes.
We appreciate everyone that runs this branch as you are in essence secondary testers to
the automation and manually testing that is done during the merge stages.
You can configure your install (this is the default) to use this branch by setting `$config['update_channel'] = 'master';`
in `config.php` and ensuring you switch to the master branch with `git checkout master`.
#### Stable branch
With this in mind, we provide a monthly stable release which is released on or around
the last Sunday of the month. Code pull requests (aside from Bug fixes) are stopped days
leading up to the release to ensure that we have a clean working branch at that point.
@ -14,3 +28,6 @@ The releases are titled after that month in the format `YYYYMM`, i.e `201608`. T
Changelog is also updated and will reference the release number and date so you can see
what changes have been made since the last release.
To switch to using stable branches you can set `$config['update_channel'] = 'release';`
in config.php and then switch to the latest release branch with `git fetch --tags && git checkout $(git describe --tags $(git rev-list --tags --max-count=1))`.

View File

@ -95,11 +95,11 @@ $config['sfdp'] = "/usr/bin/sfdp";
#### Memcached
[Memcached](Extensions/Memcached.md]
[Memcached](../Extensions/Memcached.md]
#### RRDCached
[RRDCached](Extensions/RRDCached.md]
[RRDCached](../Extensions/RRDCached.md]
#### WebUI Settings
@ -260,7 +260,7 @@ The default v3 snmp details to use, you can expand this array with `[1]`, `[2]`,
#### Auto discovery settings
[Auto-Discovery](Extensions/Auto-Discovery.md)
[Auto-Discovery](../Extensions/Auto-Discovery.md)
#### Email configuration
@ -284,11 +284,11 @@ The varying options after that are to support the different transports.
#### Alerting
[Alerting](Extensions/Alerting.md)
[Alerting](../Extensions/Alerting.md)
#### Billing
[Billing](Extensions/Billing-Module.md)
[Billing](../Extensions/Billing-Module.md)
#### Global module support
@ -303,7 +303,7 @@ $config['enable_sla'] = 0; # Enable Cisco SLA collection and d
#### Port extensions
[Port-Description-Parser](Extensions/Port-Description-Parser.md)
[Port-Description-Parser](../Extensions/Port-Description-Parser.md)
```php
$config['enable_ports_etherlike'] = 0;
@ -324,7 +324,7 @@ Setting `rancid_ignorecomments` will disable showing lines that start with #
#### Oxidized
[Oxidized](Extensions/Oxidized.md)
[Oxidized](../Extensions/Oxidized.md)
#### CollectD
```php
@ -339,11 +339,11 @@ Specify the location of the collectd unix socket. Using a socket allows the coll
#### Smokeping
[Smokeping](Extensions/Smokeping.md)
[Smokeping](../Extensions/Smokeping.md)
#### NFSen
[NFSen](Extensions/NFSen.md)
[NFSen](../Extensions/NFSen.md)
#### Location mapping
@ -425,11 +425,11 @@ Mounted storage / mount points to ignore in discovery and polling.
#### IRC Bot
[IRC Bot](Extensions/IRC-Bot.md)
[IRC Bot](../Extensions/IRC-Bot.md)
#### Authentication
[Authentication](Extensions/Authentication.md)
[Authentication](../Extensions/Authentication.md)
#### Cleanup options
@ -451,7 +451,7 @@ the rrd directory automatically - only enable this if you are comfortable with t
#### Syslog options
[Syslog](Extensions/Syslog.md)
[Syslog](../Extensions/Syslog.md)
#### Virtualization
@ -484,7 +484,7 @@ You can use this array to rewrite the description of ASes that you have discover
#### Auto updates
[Updating](General/Updating.md)
[Updating](../General/Updating.md)
#### IPMI
Setup the types of IPMI protocols to test a host for and it what order.
@ -499,4 +499,4 @@ $config['ipmi']['type'][] = "open";
#### Distributed poller settings
[Distributed Poller](Extensions/Distributed-Poller.md)
[Distributed Poller](../Extensions/Distributed-Poller.md)

View File

@ -15,7 +15,7 @@ We absolutely recommend running this, it will save on IO load. [RRDCached](http:
It's advisable after 24 hours of running MySQL that you run (MySQL Tuner)[https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl]
which will make suggestions on things you can change specific to your setup.
One recommendation we can make is that you set the following in my.cnf:
One recommendation we can make is that you set the following in my.cnf under a [mysqld] group:
```bash
innodb_flush_log_at_trx_commit = 0

View File

@ -0,0 +1,147 @@
source: Support/SNMP-Configuration-Examples.md
# SNMP configuration examples
Table of Content:
- [Devices](#devices)
- [Cisco](#cisco)
- [Adaptive Security Appliance (ASA)](#adaptive-security-appliance-asa)
- [IOS / IOS XE / NX-OS](#ios--ios-xe--nx-os)
- [Wireless LAN Controller (WLC)](#wireless-lan-controller-wlc)
- [Infoblox](#infoblox)
- [NIOS 7.x](#nios-7x)
- [Juniper](#juniper)
- [Junos OS](#junos-os)
- [Palo Alto](#palo-alto)
- [PANOS 6.x/7.x](#panos-6x7x)
- [Operating systems](#operating-systems)
- [Linux (snmpd)](#linux-snmpd)
- [Windows Server 2008 R2](#windows-server-2008-r2)
- [Windows Server 2012 R2](#windows-server-2012-r2)
## Devices
### Cisco
#### Adaptive Security Appliance (ASA)
1. Launch ASDM and connect to your device
2. Go to Configuration > Management Access > SNMP
3. Add your community string
4. Add in the "SNMP Host Access List" section your LibreNMS server IP address
5. Click Apply and Save
#### IOS / IOS XE / NX-OS
```
snmp-server community YOUR-COMMUNITY RO
snmp-server contact YOUR-CONTACT
snmp-server location YOUR-LOCATION
```
#### Wireless LAN Controller (WLC)
1. Access the web admin page and log in
2. If you are running version 8.1 and later, on the new dashboard click "Advanced"
3. Go to management Tab
4. On SNMP sub-menu, select "Communities"
5. Click "New..."
6. Add your community name and leave IP addresses empty
7. Click Apply and Save
### Infoblox
#### NIOS 7.x
1. Access the web admin page and log in
2. Go to Grid tab > Grid Manager
3. In the right menu select "Grid properties"
4. Select "SNMP" menu
5. Click "Enable SNMPv1/SNMPv2 Queries"
6. Add your community
7. Click Save & Close
### Juniper
#### Junos OS
```
set snmp description description
set snmp location location
set snmp contact contact
set snmp community YOUR-COMMUNITY authorization read-only
```
### Palo Alto
#### PANOS 6.x/7.x
1. Access the web admin page and log in
2. Go to Device tab > Setup
3. Go to the sub-tab "Operations"
4. Click "SNMP Setup"
5. Enter your SNMP community and then click "OK"
6. Click Apply
Note that you need to allow SNMP on the needed interfaces. To do that you need to create a network "Interface Mgmt" profile for standard interface and allow SNMP under "Device > Management > Management Interface Settings" for out of band management interface.
## Operating systems
### Linux (snmpd)
Replace your snmpd.conf file by the example below and edit it with appropriate community in "RANDOMSTRINGGOESHERE".
```
vi /etc/snmp/snmpd.conf
```
```
# Change RANDOMSTRINGGOESHERE to your preferred SNMP community string
com2sec readonly default RANDOMSTRINGGOESHERE
group MyROGroup v2c readonly
view all included .1 80
access MyROGroup "" any noauth exact all none none
syslocation Rack, Room, Building, City, Country [GPSX,Y]
syscontact Your Name <your@email.address>
#Distro Detection
extend .1.3.6.1.4.1.2021.7890.1 distro /usr/bin/distro
```
The LibreNMS server include a copy of this example here:
```
/opt/librenms/snmpd.conf.example
```
#### Restart the snmpd service:
##### CentOS 6 / Red hat 6
```
service snmpd restart
```
##### CentOS 7 / Red hat 7
```
systemctl restart snmpd
```
##### Ubuntu
```
service snmpd restart
```
### Windows Server 2008 R2
1. Log in to your Windows Server 2008 R2
2. Start "Server Manager" under "Administrative Tools"
3. Click "Features" and then click "Add Feature"
5. Check (if not checked) "SNMP Service", click "Next" until "Install"
6. Start "Services" under "Administrative Tools"
7. Edit "SNMP Service" properties
8. Go to the security tab
9. In "Accepted community name" click "Add" to add your community string and permission
10. In "Accept SNMP packets from these hosts" click "Add" and add your LibreNMS server IP address
11. Validate change by clicking "Apply"
### Windows Server 2012 R2
1. Log in to your Windows Server 2012 R2
2. Start "Server Manager" under "Administrative Tools"
3. Click "Manage" and then "Add Roles and Features"
4. Continue by pressing "Next" to the "Features" menu
5. Install (if not installed) "SNMP Service"
6. Start "Services" under "Administrative Tools"
7. Edit "SNMP Service" properties
8. Go to the security tab
9. In "Accepted community name" click "Add" to add your community string and permission
10. In "Accept SNMP packets from these hosts" click "Add" and add your LibreNMS server IP address
11. Validate change by clicking "Apply"

View File

@ -1,454 +1,2 @@
source: Support/Support-New-OS.md
This document will explain how to add basic and full support for a new OS. **Some knowledge in PHP is needed for the full support.**
#### BASIC SUPPORT FOR A NEW OS
### MIB
If we have the MIB, we can copy the file into the default directory:
```bash
/opt/librenms/mibs
```
#### New OS definition
Let's begin to declare the new OS in LibreNMS. At first we modify the definition file located here:
```bash
includes/definitions.inc.php
```
```php
// Pulse Secure OS definition
$os = 'pulse';
$config['os'][$os]['text'] = 'Pulse Secure';
$config['os'][$os]['type'] = 'firewall';
$config['os'][$os]['icon'] = 'junos';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Device Traffic';
$config['os'][$os]['over'][1]['graph'] = 'device_processor';
$config['os'][$os]['over'][1]['text'] = 'CPU Usage';
$config['os'][$os]['over'][2]['graph'] = 'device_mempool';
$config['os'][$os]['over'][2]['text'] = 'Memory Usage';
//The icon described before is the image we have to create and put in the directory html/images/os
```
#### Discovery OS
We create a new file named as our OS definition and in this directory:
```bash
includes/discovery/os/pulse.inc.php
```
This file just sets the $os variable, done by checking the SNMP tree for a particular value that matches the OS you are adding. Typically, this will come from the presence of specific values in sysObjectID or sysDescr, or the existence of a particular enterprise tree.
Look at other files to get help in the code structure.
```php
<?php
if (!$os) {
if (str_contains($sysDescr, 'Pulse Connect Secure')) {
$os = 'pulse';
}
}
```
Here is the file location for polling the new OS within a vendor MIB or a standard one:
```bash
includes/polling/os/pulse.inc.php
```
This file will usually set the variables for $version, $hardware and $hostname retrieved from an snmp lookup.
```php
<?php
$version = trim(snmp_get($device, "productVersion.0", "-OQv", "PULSESECURE-PSG-MIB"),'"');
$hardware = "Juniper " . trim(snmp_get($device, "productName.0", "-OQv", "PULSESECURE-PSG-MIB"),'"');
$hostname = trim(snmp_get($device, "sysName.0", "-OQv", "SNMPv2-MIB"),'"');
```
Quick explanation and examples :
```bash
snmpwalk -v2c -c public -m SNMPv2-MIB -M mibs
//will give the overall OIDs that can be retrieve with this standard MIB. OID on the left side and the result on the right side
//Then we have just to pick the wanted OID and do a check
snmpget -v2c -c public -OUsb -m SNMPv2-MIB -M /opt/librenms/mibs -t 30 HOSTNAME SNMPv2-SMI::mib-2.1.1.0
//sysDescr.0 = STRING: Juniper Networks,Inc,Pulse Connect Secure,VA-DTE,8.1R1 (build 33493)
snmpget -v2c -c public -OUsb -m SNMPv2-MIB -M /opt/librenms/mibs -t 30 HOSTNAME SNMPv2-SMI::mib-2.1.5.0
//sysName.0 = STRING: pulse-secure
//Here the same with the vendor MIB and the specific OID
snmpget -v2c -c public -OUsb -m PULSESECURE-PSG-MIB -M /opt/librenms_old/mibs -t 30 HOSTNAME productName.0
//productName.0 = STRING: "Pulse Connect Secure,VA-DTE"
snmpget -v2c -c public -OUsb -m PULSESECURE-PSG-MIB -M /opt/librenms/mibs -t 30 HOSTNAME productVersion.0
//productVersion.0 = STRING: "8.1R1 (build 33493)"
```
#### The final check
Discovery
```bash
./discovery.php -h HOSTNAME
```
Polling
```bash
./poller.php -h HOSTNAME
```
At this step we should see all the values retrieved in LibreNMS.
### Full support for a new OS
#### MIB
At first we copy the MIB file into the default directory:
```bash
/opt/librenms/mibs
```
We are now ready to look at inside the file and find the OID we want to use. _For this documentation we'll use Pulse Secure devices._
Then we can test it with the snmpget command (hostname must be reachable):
```bash
//for example the OID iveCpuUtil.0:
snmpget -v2c -c public -OUsb -m PULSESECURE-PSG-MIB -M /opt/librenms/mibs -t 30 HOSTNAME iveCpuUtil.0
//quick explanation : snmpget -v2c -c COMMUNITY -OUsb -m MIBFILE -M MIB DIRECTORY HOSTNAME OID
//Result here:
iveCpuUtil.0 = Gauge32: 28
```
#### New OS definition
Let's begin to declare the new OS in LibreNMS. At first we modify the definition file located here:
```bash
includes/definitions.inc.php
```
```php
// Pulse Secure OS definition
$os = 'pulse';
$config['os'][$os]['text'] = 'Pulse Secure';
$config['os'][$os]['type'] = 'firewall';
$config['os'][$os]['icon'] = 'junos';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Device Traffic';
$config['os'][$os]['over'][1]['graph'] = 'device_processor';
$config['os'][$os]['over'][1]['text'] = 'CPU Usage';
$config['os'][$os]['over'][2]['graph'] = 'device_mempool';
$config['os'][$os]['over'][2]['text'] = 'Memory Usage';
//The icon described before is the image we have to create and put in the directory html/images/os
//Don't forget to declare the specific graphs if needed. It will be located near the end of the file.
//Pulse Secure Graphs
$config['graph_types']['device']['pulse_users']['section'] = 'firewall';
$config['graph_types']['device']['pulse_users']['order'] = '0';
$config['graph_types']['device']['pulse_users']['descr'] = 'Active Users';
$config['graph_types']['device']['pulse_sessions']['section'] = 'firewall';
$config['graph_types']['device']['pulse_sessions']['order'] = '0';
$config['graph_types']['device']['pulse_sessions']['descr'] = 'Active Sessions';
```
#### Discovery OS
We create a new file named as our OS definition and in this directory:
```bash
includes/discovery/os/pulse.inc.php
```
Look at other files to get help in the code structure. For this example, it can be like this :
```php
// Pulse Secure OS definition
<?php
if (!$os) {
if (strstr($sysDescr, 'Pulse Connect Secure')) {
$os = 'pulse';
}
}
```
As we declared Memory and CPU graphs before, we declare the OID in a PHP file :
**Memory**
```bash
includes/discovery/mempools/pulse.inc.php
```
```php
<?php
//
// Hardcoded discovery of Memory usage on Pulse Secure devices.
//
if ($device['os'] == 'pulse') {
echo 'PULSE-MEMORY-POOL: ';
$usage = str_replace('"', "", snmp_get($device, 'PULSESECURE-PSG-MIB::iveMemoryUtil.0', '-OvQ'));
if (is_numeric($usage)) {
discover_mempool($valid_mempool, $device, 0, 'pulse-mem', 'Main Memory', '100', null, null);
}
}
```
**CPU**
```bash
includes/discovery/processors/pulse.inc.php
```
```php
<?php
//
// Hardcoded discovery of CPU usage on Pulse Secure devices.
//
if ($device['os'] == 'pulse') {
echo 'Pulse Secure : ';
$descr = 'Processor';
$usage = str_replace('"', "", snmp_get($device, 'PULSESECURE-PSG-MIB::iveCpuUtil.0', '-OvQ'));
if (is_numeric($usage)) {
discover_processor($valid['processor'], $device, 'PULSESECURE-PSG-MIB::iveCpuUtil.0', '0', 'pulse-cpu', $descr,
'100', $usage, null, null);
}
}
```
_Please keep in mind that the PHP code is often different for the needs of the devices and the information we retrieve._
#### Polling OS
We will now do the same for the polling process:
**Memory**
```bash
includes/polling/mempools/pulse-mem.inc.php
```
```php
<?php
// Simple hard-coded poller for Pulse Secure
echo 'Pulse Secure MemPool'.'\n';
if ($device['os'] == 'pulse') {
$perc = str_replace('"', "", snmp_get($device, "PULSESECURE-PSG-MIB::iveMemoryUtil.0", '-OvQ'));
$memory_available = str_replace('"', "", snmp_get($device, "UCD-SNMP-MIB::memTotalReal.0", '-OvQ'));
$mempool['total'] = $memory_available;
if (is_numeric($perc)) {
$mempool['used'] = ($memory_available / 100 * $perc);
$mempool['free'] = ($memory_available - $mempool['used']);
}
echo "PERC " .$perc."%\n";
echo "Avail " .$mempool['total']."\n";
}
```
**CPU**
```bash
includes/polling/processors/pulse-cpu.inc.php
```
```php
<?php
// Simple hard-coded poller for Pulse Secure
echo 'Pulse Secure CPU Usage';
if ($device['os'] == 'pulse') {
$usage = str_replace('"', "", snmp_get($device, 'PULSESECURE-PSG-MIB::iveCpuUtil.0', '-OvQ'));
if (is_numeric($usage)) {
$proc = ($usage * 100);
}
}
```
Here is the file location for the specific graphs based on the OID in the vendor MIB:
```bash
includes/polling/os/pulse.inc.php
```
We declare two specific graphs for users and sessions numbers. Theses two graphs will be displayed on the firewall section of the graphs tab as it was written in the definition include file.
```php
<?php
$version = trim(snmp_get($device, "productVersion.0", "-OQv", "PULSESECURE-PSG-MIB"),'"');
$hardware = "Juniper " . trim(snmp_get($device, "productName.0", "-OQv", "PULSESECURE-PSG-MIB"),'"');
$hostname = trim(snmp_get($device, "sysName.0", "-OQv", "SNMPv2-MIB"),'"');
$users = snmp_get($device, 'PULSESECURE-PSG-MIB::iveConcurrentUsers.0', '-OQv');
if (is_numeric($users)) {
$rrd_def = 'DS:users:GAUGE:600:0:U';
$fields = array(
'users' => $users
)
$tags = compact('rrd_def');
data_update($device, 'pulse_users', $tags, $fields);
$graphs['pulse_users'] = true;
}
$sessions = snmp_get($device, 'PULSESECURE-PSG-MIB::iveConcurrentUsers.0', '-OQv');
if (is_numeric($sessions)) {
$rrd_def = array(
'DS:sessions:GAUGE:600:0:U',
}
$fields = array(
'sessions' => $sessions
);
$tags = compact('rrd_def');
data_update($device, 'pulse_sessions', $tags, $fields);
$graphs['pulse_sessions'] = true;
}
```
We finish in the declaration of the two graph types in the database:
We can do that within a file to share our work and contribute in the development of LibreNMS. :-)
```bash
sql-schema/xxx.sql
//check the file number in GitHub
php includes/sql-schema/update.php
```
Or put the SQL commands directly in Mysql or PhpMyadmin for our tests:
```php
INSERT INTO `graph_types`(`graph_type`, `graph_subtype`, `graph_section`, `graph_descr`, `graph_order`) VALUES ('device', 'pulse_users', 'firewall', 'Active Users', '');
INSERT INTO `graph_types`(`graph_type`, `graph_subtype`, `graph_section`, `graph_descr`, `graph_order`) VALUES ('device', 'pulse_sessions', 'firewall', 'Active Sessions', '');
```
#### Displaying
The specific graphs are not displayed automatically so we need to write the following PHP code:
**Pulse Sessions**
```bash
html/includes/graphs/device/pulse_sessions.inc.php
```
```php
<?php
$rrd_filename = rrd_name($device['hostname'], 'pulse_sessions');
require 'includes/graphs/common.inc.php';
$ds = 'sessions';
$colour_area = '9999cc';
$colour_line = '0000cc';
$colour_area_max = '9999cc';
$graph_max = 1;
$graph_min = 0;
$unit_text = 'Sessions';
require 'includes/graphs/generic_simplex.inc.php';
```
**Pulse Users**
```bash
html/includes/graphs/device/pulse_users.inc.php
```
```php
<?php
$rrd_filename = rrd_name($device['hostname'], 'pulse_users');
require 'includes/graphs/common.inc.php';
$ds = 'users';
$colour_area = '9999cc';
$colour_line = '0000cc';
$colour_area_max = '9999cc';
$graph_max = 1;
$unit_text = 'Users';
require 'includes/graphs/generic_simplex.inc.php';
```
#### The final check
Discovery
```bash
./discovery.php -h HOSTNAME
```
Polling
```bash
./poller.php -h HOSTNAME
```
At this step we should see all the values retrieved in LibreNMS.
### OS Test units
We have a testing unit for new OS', please ensure you add a test for any new OS' or updates to existing OS discovery.
The OS test unit file is located `tests/OSDiscoveryTest.php`. An example of this is as follows:
```php
public function testZxr10()
{
$this->checkOS('zxr10', 'ZTE Ethernet Switch ZXR10 5250-52TM-H, Version: V2.05.11B23');
}
```
This test looks for the sysDescr of `ZTE Ethernet Switch ZXR10 5250-52TM-H, Version: V2.05.11B23` and if it matches
the `zxr10` OS discovery file then the check will pass.
A slightly more complicated test would be:
```php
public function testAiros()
{
$this->checkOS('airos', 'Linux', '.1.3.6.1.4.1.10002.1');
$this->checkOS('airos', 'Linux', '.1.3.6.1.4.1.41112.1.4');
$mockSnmp = array(
'dot11manufacturerName.5' => 'Ubiquiti',
);
$this->checkOS('airos', 'Linux', '', $mockSnmp);
}
```
The first two `$this->checkOS` calls pass on both a `sysDescr` value (`Linux`) and a `sysObjectID`.
The third call uses another snmp response (although fake) which the specific OS discovery for `airos` relies on.
You can run `scripts/pre-commit.php -u` to run the unit tests to check your code.
<meta http-equiv="refresh" content="0; url=/Developting/Support-New-OS/" />

View File

@ -18,6 +18,7 @@ require_once '../includes/definitions.inc.php';
require_once 'includes/functions.inc.php';
require_once '../includes/functions.php';
require_once 'includes/authenticate.inc.php';
require_once '../includes/alerts.inc.php';
set_debug($_REQUEST['debug']);
$id = mres($_REQUEST['id']);

View File

@ -315,6 +315,7 @@ A.purple:visited, a.purple, .purple { color: #740074; }
.bluebg { background-color: #aaaaff; }
.greenbg { background-color: #aaffaa; }
.greybg { background-color: #DEEFEF; }
.blackbg { background-color: #000000; }
.selector {
width:275px;
@ -1763,22 +1764,56 @@ label {
font-weight: normal;
}
.nav>li>a.dropdown-toggle {
padding: 15px 6px;
}
.badge-navbar-user{
background:red;
.badge-navbar-user {
border-radius: 40%;
font-size: 65%;
height: auto;
margin: 0;
padding:5px;
position:absolute;
right:-3px;
top:5px;
width: auto;
}
padding: 5px;
position: relative;
top: -10px;
left: -5px;
}
.badge-default {
background-color: #777;
}
.badge-default[href]:hover,
.badge-default[href]:focus {
background-color: #5e5e5e;
}
.badge-primary {
background-color: #337ab7;
}
.badge-primary[href]:hover,
.badge-primary[href]:focus {
background-color: #286090;
}
.badge-success {
background-color: #5cb85c;
}
.badge-success[href]:hover,
.badge-success[href]:focus {
background-color: #449d44;
}
.badge-info {
background-color: #5bc0de;
}
.badge-info[href]:hover,
.badge-info[href]:focus {
background-color: #31b0d5;
}
.badge-warning {
background-color: #f0ad4e;
}
.badge-warning[href]:hover,
.badge-warning[href]:focus {
background-color: #ec971f;
}
.badge-danger {
background-color: #d9534f;
}
.badge-danger[href]:hover,
.badge-danger[href]:focus {
background-color: #c9302c;
}
@media only screen and (max-width: 480px) {
.thumbnail_graph_table b { font-size : 6px;}
@ -1872,7 +1907,6 @@ label {
.device-availability, .service-availability {
color:#000000;
float:left;
width:163px;
height:64px;
margin:10px;
padding:8px;
@ -1893,6 +1927,14 @@ label {
border:1px solid #FFB733;
}
.device-availability.ignored, .service-availability.ignored {
border:1px solid #36393D;
}
.device-availability.disabled, .service-availability.disabled {
border:1px solid #000000;
}
.availability-label {
float:right;
margin:-8px;
@ -1916,13 +1958,13 @@ label {
}
.page-availability-title-left {
width:50%;
width:40%;
float:left;
height:40px;
}
.page-availability-title-right {
width:50%;
width:60%;
float:left;
text-align:right;
}
@ -1991,3 +2033,7 @@ label {
float:left;
background-color: #D9534F;
}
.availability-map-widget-header {
line-height:30px;
}

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

View File

@ -227,7 +227,7 @@ var alerts_grid = $("#alerts_'.$unique_id.'").bootgrid({
return "<h4><span class=\'label label-"+row.extra+" threeqtr-width\'>" + row.msg + "</span></h4>";
},
"ack": function(column,row) {
return "<button type=\'button\' class=\'btn btn-"+row.ack_col+" btn-sm command-ack-alert\' data-target=\'#ack-alert\' data-state=\'"+row.state+"\' data-alert_id=\'"+row.alert_id+"\' name=\'ack-alert\' id=\'ack-alert\' data-extra=\'"+row.extra+"\'><span class=\'glyphicon glyphicon-"+row.ack_ico+"\'aria-hidden=\'true\'></span></button>";
return "<button type=\'button\' class=\'btn btn-"+row.ack_col+" btn-sm command-ack-alert\' data-target=\'#ack-alert\' data-state=\'"+row.state+"\' data-alert_id=\'"+row.alert_id+"\' name=\'ack-alert\' id=\'ack-alert\' data-extra=\'"+row.extra+"\'><i class=\'fa fa-"+row.ack_ico+"\'aria-hidden=\'true\'></i></button>";
},
"proc": function(column,row) {
return "<button type=\'button\' class=\'btn command-open-proc\' data-alert_id=\'"+row.alert_id+"\' name=\'open-proc\' id=\'open-proc\'>Open</button>";
@ -248,7 +248,7 @@ var alerts_grid = $("#alerts_'.$unique_id.'").bootgrid({
}).on("click", function(e) {
var target = $(this).data("target");
$(target).collapse(\'toggle\');
$(this).toggleClass(\'glyphicon-plus glyphicon-minus\');
$(this).toggleClass(\'fa-plus fa-minus\');
});
alerts_grid.find(".incident").each( function() {
$(this).parent().addClass(\'col-lg-4 col-md-4 col-sm-4 col-xs-4\');
@ -258,8 +258,8 @@ var alerts_grid = $("#alerts_'.$unique_id.'").bootgrid({
$(this).find(".incident-toggle").fadeOut(200);
}).on("click", "td:not(.incident-toggle-td)", function() {
var target = $(this).parent().find(".incident-toggle").data("target");
if( $(this).parent().find(".incident-toggle").hasClass(\'glyphicon-plus\') ) {
$(this).parent().find(".incident-toggle").toggleClass(\'glyphicon-plus glyphicon-minus\');
if( $(this).parent().find(".incident-toggle").hasClass(\'fa-plus\') ) {
$(this).parent().find(".incident-toggle").toggleClass(\'fa-plus fa-minus\');
$(target).collapse(\'toggle\');
}
});

View File

@ -12,76 +12,107 @@
* the source code distribution for details.
*/
$sql = dbFetchRow('SELECT `settings` FROM `users_widgets` WHERE `user_id` = ? AND `widget_id` = ?', array($_SESSION["user_id"], '1'));
$widget_mode = json_decode($sql['settings'], true);
if (isset($_SESSION["map_view"]) && is_numeric($_SESSION["map_view"])) {
$mode = $_SESSION["map_view"];
} else {
$mode = $widget_mode['mode'];
}
$select_modes = array(
'0' => 'only devices',
'1' => 'only services',
'2' => 'devices and services',
);
if ($config['webui']['availability_map_compact'] == 1) {
$compact_tile = $widget_mode['tile_width'];
}
$show_disabled_ignored = $widget_mode['show_disabled_and_ignored'];
if (defined('SHOW_SETTINGS')) {
if (isset($widget_settings['mode'])) {
$mode = $widget_settings['mode'];
} else {
$mode = 0;
$common_output[] = '
<form class="form" onsubmit="widget_settings(this); return false;">
<div class="form-group">
<div class="col-sm-4">
<label for="title" class="control-label availability-map-widget-header">Widget title</label>
</div>
<div class="col-sm-6">
<input type="text" class="form-control" name="title" placeholder="Custom title for widget" value="'.htmlspecialchars($widget_settings['title']).'">
</div>
</div>';
if ($config['webui']['availability_map_compact'] == 1) {
$common_output[] = '
<div class="form-group">
<div class="col-sm-4">
<label for="tile_width" class="control-label availability-map-widget-header">Tile width</label>
</div>
<div class="col-sm-6">
<input type="text" class="form-control" name="tile_width" value="'.$compact_tile.'">
</div>
</div>';
}
if (isset($widget_settings['tile_width'])) {
$current_width = $widget_settings['tile_width'];
if ($show_disabled_ignored == 1) {
$selected_yes = 'selected';
$selected_no = '';
} else {
$current_width = 10;
$selected_yes = '';
$selected_no = 'selected';
}
$common_output[] = '
<form class="form-horizontal" onsubmit="return widget_settings(this)">
<div class="form-group">
<label for="tile_width" class="col-sm-4 control-label">Tile width</label>
<div class="col-sm-6">
<input class="form-control" name="tile_width" placeholder="I.e 10" value="'.$current_width.'">
<div class="col-sm-4">
<label for="show_disabled_and_ignored" class="control-label availability-map-widget-header">Disabled/ignored</label>
</div>
</div>
<div class="form-group">
<label for="show_services" class="col-sm-4 control-label">Show</label>
<div class="col-sm-6">
<select class="form-control" name="mode">';
if ($config['show_services'] == 0) {
$common_output[] = '<option value="0" selected="selected">only devices</option>';
} else {
foreach ($select_modes as $mode_select => $option) {
if ($mode_select == $mode) {
$selected = 'selected';
} else {
$selected = '';
}
$common_output[] = '<option value="'.$mode_select.'" '.$selected.'>'.$option.'</option>';
}
}
$common_output[] ='
<select class="form-control" name="show_disabled_and_ignored">
<option value="1" '.$selected_yes.'>yes</option>
<option value="0" '.$selected_no.'>no</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-6 col-sm-4"><button type="submit" class="btn btn-primary">Set</button></div>
</div>
</div>';
if ($config['webui']['availability_map_compact'] == 1) {
$common_outputp[] = '
<div class="form-group">
<div class="col-sm-4">
<label for="tile_width" class="control-label availability-map-widget-header">Tile width</label>
</div>
<div class="col-sm-6">
<input class="form-control" type="text" onkeypress="return (event.charCode == 8 || event.charCode == 0) ? null : event.charCode >= 48 && event.charCode <= 57" name="tile_width" placeholder="Tile width in px" value="'.$current_width.'">
</div>
</div>
';
}
$common_output[] = '
<br style="clear:both;">
<div class="form-group">
<div class="col-sm-2">
<button type="submit" class="btn btn-default">Set</button>
</div>
</div>
</form>';
} else {
require_once 'includes/object-cache.inc.php';
$sql = dbFetchRow('SELECT `settings` FROM `users_widgets` WHERE `user_id` = ? AND `widget_id` = ?', array($_SESSION["user_id"], '1'));
$widget_mode = json_decode($sql['settings']);
if (isset($_SESSION["map_view"])) {
$mode = $_SESSION["map_view"];
} else {
$mode = $widget_mode->{'mode'};
}
$host_up_count = 0;
$host_warn_count = 0;
$host_down_count = 0;
$host_ignored_count = 0;
$host_disabled_count = 0;
$service_up_count = 0;
$service_warn_count = 0;
$service_down_count = 0;
$service_ignored_count = 0;
$service_disabled_count = 0;
if ($config['webui']['availability_map_sort_status'] == 1) {
$deviceOrderBy = 'status';
@ -103,7 +134,11 @@ if (defined('SHOW_SETTINGS')) {
$in_devices = implode(',', $in_devices);
}
$sql = 'SELECT `D`.`hostname`, `D`.`sysName`, `D`.`device_id`, `D`.`status`, `D`.`uptime`, `D`.`os`, `D`.`icon` FROM `devices` AS `D`';
if ($show_disabled_ignored == 1) {
$disabled_ignored = ', `D`.`ignore`, `D`.`disabled`';
}
$sql = 'SELECT `D`.`hostname`, `D`.`sysName`, `D`.`device_id`, `D`.`status`, `D`.`uptime`, `D`.`os`, `D`.`icon` '.$disabled_ignored.' FROM `devices` AS `D`';
if (is_normal_user() === true) {
$sql .= ' , `devices_perms` AS P WHERE D.`device_id` = P.`device_id` AND P.`user_id` = ? AND';
@ -114,17 +149,26 @@ if (defined('SHOW_SETTINGS')) {
$sql .= ' WHERE';
}
if ($config['webui']['availability_map_use_device_groups'] != 0 && isset($in_devices)) {
$sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' AND `D`.`device_id` IN (".$in_devices.") ORDER BY `".$deviceOrderBy."`";
$sql .= " `D`.`device_id` IN (".$in_devices.")";
} else {
$sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `".$deviceOrderBy."`";
$sql .= " TRUE";
}
$sql .= " ORDER BY `".$deviceOrderBy."`";
$temp_output = array();
foreach (dbFetchRows($sql, $param) as $device) {
if ($device['status'] == '1') {
if ($device['disabled'] == '1') {
$deviceState = "disabled";
$deviceLabel = "blackbg";
$host_disabled_count++;
} elseif ($device['ignore'] == '1') {
$deviceState = "ignored";
$deviceLabel = "label-default";
$host_ignored_count++;
} elseif ($device['status'] == '1') {
if (($device['uptime'] < $config['uptime_warning']) && ($device['uptime'] != '0')) {
$deviceState = 'warn';
$deviceLabel = 'label-warning';
@ -143,25 +187,25 @@ if (defined('SHOW_SETTINGS')) {
$host_down_count++;
}
if ($config['webui']['old_availability_map'] == 0) {
if ($config['webui']['availability_map_compact'] == 0) {
if ($directpage == "yes") {
$deviceIcon = getImage($device);
$temp_output[] = '
<a href="'.generate_url(array('page' => 'device', 'device' => $device['device_id'])).'" title="'.$device['hostname']." - ".formatUptime($device['uptime']).'">
<div class="device-availability '.$deviceState.'">
<span class="availability-label label '.$deviceLabel.' label-font-border">'.$deviceState.'</span>
<span class="device-icon">'.$deviceIcon.'</span><br>
<span class="small">'.shorthost(ip_to_sysname($device, $device['hostname'])).'</span>
<a href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'])) . '" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '">
<div class="device-availability ' . $deviceState . '" style="width:' . $config['webui']['availability_map_box_size'] . 'px;">
<span class="availability-label label ' . $deviceLabel . ' label-font-border">' . $deviceState . '</span>
<span class="device-icon">' . $deviceIcon . '</span><br>
<span class="small">' . shorthost(ip_to_sysname($device, $device['hostname'])) . '</span>
</div>
</a>';
} else {
$temp_output[] = '
<a href="'.generate_url(array('page' => 'device', 'device' => $device['device_id'])).'" title="'.$device['hostname']." - ".formatUptime($device['uptime']).'">
<span class="label '.$deviceLabel.' widget-availability label-font-border">'.$deviceState.'</span>
<a href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'])) . '" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '">
<span class="label ' . $deviceLabel . ' widget-availability label-font-border">' . $deviceState . '</span>
</a>';
}
} else {
$temp_output[] = '<a href="'.generate_url(array('page' => 'device', 'device' => $device['device_id'])).'" title="'.$device['hostname']." - ".formatUptime($device['uptime']).'"><div class="'.$deviceLabelOld.'"></div></a>';
$temp_output[] = '<a href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'])) . '" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '"><div class="' . $deviceLabelOld . '" style="width:' . $compact_tile . 'px;"></div></a>';
}
}
}
@ -188,26 +232,26 @@ if (defined('SHOW_SETTINGS')) {
$service_down_count++;
}
if ($config['webui']['old_availability_map'] == 0) {
if ($config['webui']['availability_map_compact'] == 0) {
if ($directpage == "yes") {
$deviceIcon = getImage($service);
$temp_output[] = '
<a href="'.generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])).'" title="'.$service['hostname']." - ".$service['service_type']." - ".$service['service_desc'].'">
<div class="service-availability '.$serviceState.'">
<span class="service-name-label label '.$serviceLabel.' label-font-border">'.$service["service_type"].'</span>
<span class="availability-label label '.$serviceLabel.' label-font-border">'.$serviceState.'</span>
<span class="device-icon">'.$deviceIcon.'</span><br>
<span class="small">'.shorthost(ip_to_sysname($service, $service['hostname'])).'</span>
<a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '">
<div class="service-availability ' . $serviceState . '" style="width:' . $config['webui']['availability_map_box_size'] . 'px;">
<span class="service-name-label label ' . $serviceLabel . ' label-font-border">' . $service["service_type"] . '</span>
<span class="availability-label label ' . $serviceLabel . ' label-font-border">' . $serviceState . '</span>
<span class="device-icon">' . $deviceIcon . '</span><br>
<span class="small">' . shorthost(ip_to_sysname($service, $service['hostname'])) . '</span>
</div>
</a>';
} else {
$temp_output[] = '
<a href="'.generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])).'" title="'.$service['hostname']." - ".$service['service_type']." - ".$service['service_desc'].'">
<span class="label '.$serviceLabel.' widget-availability label-font-border">'.$service['service_type'].' - '.$serviceState.'</span>
<a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '">
<span class="label ' . $serviceLabel . ' widget-availability label-font-border">' . $service['service_type'] . ' - ' . $serviceState . '</span>
</a>';
}
} else {
$temp_output[] = '<a href="'.generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])).'" title="'.$service['hostname']." - ".$service['service_type']." - ".$service['service_desc'].'"><div class="'.$serviceLabelOld.'"></div></a>';
$temp_output[] = '<a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '"><div class="' . $serviceLabelOld . '" style="width:'.$compact_tile.'px;"></div></a>';
}
}
} else {
@ -230,7 +274,7 @@ if (defined('SHOW_SETTINGS')) {
} else {
$selected = '';
}
$temp_header[] = '<option value="'.$mode_select.'" '.$selected.'>'.$option.'</option>';
$temp_header[] = '<option value="' . $mode_select . '" ' . $selected . '>' . $option . '</option>';
}
}
@ -252,7 +296,7 @@ if (defined('SHOW_SETTINGS')) {
$temp_header[] = '
<span class="page-availability-title">Device group</span>
<select id="group" class="page-availability-report-select" name="group">
<option value="0" '.$selected.'>show all devices</option>';
<option value="0" ' . $selected . '>show all devices</option>';
foreach ($dev_groups as $dev_group) {
if ($_SESSION['group_view'] == $dev_group['id']) {
@ -260,7 +304,7 @@ if (defined('SHOW_SETTINGS')) {
} else {
$selected = '';
}
$temp_header[] = '<option value="'.$dev_group['id'].'" '.$selected.'>'.$dev_group['name'].'</option>';
$temp_header[] = '<option value="' . $dev_group['id'] . '" ' . $selected . '>' . $dev_group['name'] . '</option>';
}
$temp_header[] = '</select>';
}
@ -274,19 +318,26 @@ if (defined('SHOW_SETTINGS')) {
$serviceClass = 'widget-availability-service';
}
if ($show_disabled_ignored == 1) {
$disabled_ignored_header = '
<span class="label label-default label-font-border label-border">ignored: '.$host_ignored_count.'</span>
<span class="label blackbg label-font-border label-border">disabled: '.$host_disabled_count.'</span>';
}
if ($mode == 0 || $mode == 2) {
$temp_header[] = '
<div class="'.$deviceClass.'">
<div class="' . $deviceClass . '">
<span>Total hosts</span>
<span class="label label-success label-font-border label-border">up: '.$host_up_count.'</span>
<span class="label label-warning label-font-border label-border">warn: '.$host_warn_count.'</span>
<span class="label label-danger label-font-border label-border">down: '.$host_down_count.'</span>
'.$disabled_ignored_header.'
</div>';
}
if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) {
$temp_header[] = '
<div class="'.$serviceClass.'">
<div class="' . $serviceClass . '">
<span>Total services</span>
<span class="label label-success label-font-border label-border">up: '.$service_up_count.'</span>
<span class="label label-warning label-font-border label-border">warn: '.$service_warn_count.'</span>

View File

@ -17,8 +17,7 @@ if (is_admin() === false) {
}
$rule = implode(' ', $_POST['rules']);
$rule = rtrim($rule, '&&');
$rule = rtrim($rule, '||');
$rule = rtrim($rule, '&|');
$alert_id = $_POST['alert_id'];
$count = mres($_POST['count']);
$delay = mres($_POST['delay']);

View File

@ -91,6 +91,9 @@ function nicecase($item)
case 'ups-nut':
return 'UPS nut';
case 'ups-apcups':
return 'UPS apcups';
default:
return ucfirst($item);
}
@ -1209,7 +1212,7 @@ function generate_dynamic_config_panel($title, $config_groups, $items = array(),
$output .= '
<div class="form-group has-feedback">
<label for="'.$item['name'].'"" class="col-sm-4 control-label">'.$item['descr'].' </label>
<div data-toggle="tooltip" title="'.$config_groups[$item['name']]['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div data-toggle="tooltip" title="'.$config_groups[$item['name']]['config_descr'].'" class="toolTip fa fa-fw fa-lg fa-question-circle"></div>
<div class="col-sm-4">
';
if ($item['type'] == 'checkbox') {
@ -1217,6 +1220,11 @@ function generate_dynamic_config_panel($title, $config_groups, $items = array(),
} elseif ($item['type'] == 'text') {
$output .= '
<input id="'.$item['name'].'" class="form-control" type="text" name="global-config-input" value="'.$config_groups[$item['name']]['config_value'].'" data-config_id="'.$config_groups[$item['name']]['config_id'].'">
<span class="form-control-feedback"><i class="fa" aria-hidden="true"></i></span>
';
} elseif ($item['type'] == 'numeric') {
$output .= '
<input id="'.$item['name'].'" class="form-control" onkeypress="return (event.charCode == 8 || event.charCode == 0) ? null : event.charCode >= 48 && event.charCode <= 57" type="text" name="global-config-input" value="'.$config_groups[$item['name']]['config_value'].'" data-config_id="'.$config_groups[$item['name']]['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
';
} elseif ($item['type'] == 'select') {
@ -1242,7 +1250,7 @@ function generate_dynamic_config_panel($title, $config_groups, $items = array(),
}
$output .='
</select>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback"><i class="fa" aria-hidden="true"></i></span>
';
}
$output .= '
@ -1336,22 +1344,20 @@ function ipmiSensorName($hardwareId, $sensorIpmi, $rewriteArray)
}
}
function get_auth_ad_user_filter($username)
/**
* @param $filename
* @param $content
*/
function file_download($filename, $content)
{
global $config;
$user_filter = "(samaccountname=$username)";
if ($config['auth_ad_user_filter']) {
$user_filter = "(&{$config['auth_ad_user_filter']}$user_filter)";
}
return $user_filter;
}
function get_auth_ad_group_filter($groupname)
{
global $config;
$group_filter = "(samaccountname=$groupname)";
if ($config['auth_ad_group_filter']) {
$group_filter = "(&{$config['auth_ad_group_filter']}$group_filter)";
}
return $group_filter;
$length = strlen($content);
header('Content-Description: File Transfer');
header('Content-Type: text/plain');
header("Content-Disposition: attachment; filename=$filename");
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . $length);
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
header('Pragma: public');
echo $content;
}

View File

@ -0,0 +1,33 @@
<?php
/*
* 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/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 crcro
* @author Cercel Valentin <crc@nuamchefazi.ro>
*/
require 'includes/graphs/common.inc.php';
$scale_min = 0;
$ds = 'charge';
$colour_area = 'EEEEEE';
$colour_line = 'FF3300';
$colour_area_max = 'FFEE99';
$graph_max = 0;
$unit_text = 'Percent';
$ups_apcups = rrd_name($device['hostname'], array('app', 'ups-apcups', $app['app_id']));
if (rrdtool_check_rrd_exists($ups_apcups)) {
$rrd_filename = $ups_apcups;
}
require 'includes/graphs/generic_simplex.inc.php';

View File

@ -0,0 +1,33 @@
<?php
/*
* 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/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 crcro
* @author Cercel Valentin <crc@nuamchefazi.ro>
*/
require 'includes/graphs/common.inc.php';
$scale_min = 0;
$ds = 'load';
$colour_area = 'EEEEEE';
$colour_line = 'FF3300';
$colour_area_max = 'FFEE99';
$graph_max = 0;
$unit_text = 'Percent';
$ups_apcups = rrd_name($device['hostname'], array('app', 'ups-apcups', $app['app_id']));
if (rrdtool_check_rrd_exists($ups_apcups)) {
$rrd_filename = $ups_apcups;
}
require 'includes/graphs/generic_simplex.inc.php';

View File

@ -0,0 +1,33 @@
<?php
/*
* 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/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 crcro
* @author Cercel Valentin <crc@nuamchefazi.ro>
*/
require 'includes/graphs/common.inc.php';
$scale_min = 0;
$ds = 'time_remaining';
$colour_area = 'EEEEEE';
$colour_line = '36393D';
$colour_area_max = 'FFEE99';
$graph_max = 0;
$unit_text = 'Minutes';
$ups_apcups = rrd_name($device['hostname'], array('app', 'ups-apcups', $app['app_id']));
if (rrdtool_check_rrd_exists($ups_apcups)) {
$rrd_filename = $ups_apcups;
}
require 'includes/graphs/generic_simplex.inc.php';

View File

@ -0,0 +1,49 @@
<?php
/*
* 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/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 crcro
* @author Cercel Valentin <crc@nuamchefazi.ro>
*/
require 'includes/graphs/common.inc.php';
$scale_min = 0;
$colours = 'mixed';
$unit_text = 'Volts';
$unitlen = 10;
$bigdescrlen = 15;
$smalldescrlen = 15;
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 33;
$rrd_filename = rrd_name($device['hostname'], array('app', 'ups-apcups', $app['app_id']));
$array = array(
'battery_nominal' => array('descr' => 'Nominal','colour' => '630606',),
'battery_voltage' => array('descr' => 'Current','colour' => '50C150',),
);
$i = 0;
if (rrdtool_check_rrd_exists($rrd_filename)) {
foreach ($array as $ds => $vars) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $vars['descr'];
$rrd_list[$i]['ds'] = $ds;
$rrd_list[$i]['colour'] = $vars['colour'];
$i++;
}
} else {
echo "file missing: $rrd_filename";
}
require 'includes/graphs/generic_v3_multiline_float.inc.php';

View File

@ -0,0 +1,49 @@
<?php
/*
* 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/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 crcro
* @author Cercel Valentin <crc@nuamchefazi.ro>
*/
require 'includes/graphs/common.inc.php';
$scale_min = 0;
$colours = 'mixed';
$unit_text = 'Volts';
$unitlen = 10;
$bigdescrlen = 15;
$smalldescrlen = 15;
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 33;
$rrd_filename = rrd_name($device['hostname'], array('app', 'ups-apcups', $app['app_id']));
$array = array(
'input_voltage' => array('descr' => 'Input','colour' => '630606',),
'nominal_voltage' => array('descr' => 'Nominal','colour' => '50C150',),
);
$i = 0;
if (rrdtool_check_rrd_exists($rrd_filename)) {
foreach ($array as $ds => $vars) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $vars['descr'];
$rrd_list[$i]['ds'] = $ds;
$rrd_list[$i]['colour'] = $vars['colour'];
$i++;
}
} else {
echo "file missing: $rrd_filename";
}
require 'includes/graphs/generic_v3_multiline_float.inc.php';

View File

@ -31,5 +31,8 @@ $unit_text = 'Percent';
$ups_nut = rrd_name($device['hostname'], array('app', 'ups-nut', $app['app_id']));
if (rrdtool_check_rrd_exists($ups_nut)) {
$rrd_filename = $ups_nut;
} else {
echo "file missing: $rrd_filename";
}
require 'includes/graphs/generic_simplex.inc.php';

View File

@ -31,5 +31,8 @@ $unit_text = 'Percent';
$ups_nut = rrd_name($device['hostname'], array('app', 'ups-nut', $app['app_id']));
if (rrdtool_check_rrd_exists($ups_nut)) {
$rrd_filename = $ups_nut;
} else {
echo "file missing: $rrd_filename";
}
require 'includes/graphs/generic_simplex.inc.php';

View File

@ -17,6 +17,7 @@
* @link http://librenms.org
* @copyright 2016 crcro
* @author Cercel Valentin <crc@nuamchefazi.ro>
*
*/
require 'includes/graphs/common.inc.php';
@ -27,9 +28,12 @@ $colour_area = 'EEEEEE';
$colour_line = '36393D';
$colour_area_max = 'FFEE99';
$graph_max = 0;
$unit_text = 'Seconds';
$unit_text = 'Minutes';
$ups_nut = rrd_name($device['hostname'], array('app', 'ups-nut', $app['app_id']));
if (rrdtool_check_rrd_exists($ups_nut)) {
$rrd_filename = $ups_nut;
} else {
echo "file missing: $rrd_filename";
}
require 'includes/graphs/generic_simplex.inc.php';

View File

@ -17,6 +17,7 @@
* @link http://librenms.org
* @copyright 2016 crcro
* @author Cercel Valentin <crc@nuamchefazi.ro>
*
*/
require 'includes/graphs/common.inc.php';
@ -33,7 +34,6 @@ $addarea = 1;
$transparency = 33;
$rrd_filename = rrd_name($device['hostname'], array('app', 'ups-nut', $app['app_id']));
$array = array(
'battery_low' => array('descr' => 'Low','colour' => '630606',),
'battery_voltage' => array('descr' => 'Current','colour' => '50C150',),
);

View File

@ -13,34 +13,43 @@ $rrd_options .= " DEF:lb=$rrd_filename:lb:AVERAGE";
$rrd_options .= " DEF:svc=$rrd_filename:svc:AVERAGE";
$rrd_options .= " DEF:webvpn=$rrd_filename:webvpn:AVERAGE";
$rrd_options .= " COMMENT:'Sessions Current Average Maximum\\n'";
$rrd_options .= " COMMENT:'Sessions Current Average Maximum\\n'";
$rrd_options .= " AREA:svc#aa0000:'SSLVPN Tunnels'";
$rrd_options .= " GPRINT:svc:LAST:'%6.2lf%s'";
$rrd_options .= " GPRINT:svc:AVERAGE:' %6.2lf%s'";
$rrd_options .= " GPRINT:svc:MAX:' %6.2lf%s\\\\n'";
$rrd_options .= " AREA:svc#1985A1:'SSL VPN Client':STACK";
$rrd_options .= " GPRINT:svc:LAST:'%8.2lf'";
$rrd_options .= " GPRINT:svc:AVERAGE:' %8.2lf'";
$rrd_options .= " GPRINT:svc:MAX:' %8.2lf\\\\n'";
$rrd_options .= " AREA:webvpn#999999:'Clientless VPN'";
$rrd_options .= " GPRINT:webvpn:LAST:'%6.2lf%s'";
$rrd_options .= " GPRINT:webvpn:AVERAGE:' %6.2lf%s'";
$rrd_options .= " GPRINT:webvpn:MAX:' %6.2lf%s\\\\n'";
$rrd_options .= " AREA:webvpn#4C5C68:'Clientless VPN':STACK";
$rrd_options .= " GPRINT:webvpn:LAST:'%8.2lf'";
$rrd_options .= " GPRINT:webvpn:AVERAGE:' %8.2lf'";
$rrd_options .= " GPRINT:webvpn:MAX:' %8.2lf\\\\n'";
$rrd_options .= " AREA:ipsec#00aa00:'IPSEC '";
$rrd_options .= " GPRINT:ipsec:LAST:'%6.2lf%s'";
$rrd_options .= " GPRINT:ipsec:AVERAGE:' %6.2lf%s'";
$rrd_options .= " GPRINT:ipsec:MAX:' %6.2lf%s\\\\n'";
$rrd_options .= " AREA:ipsec#46494C:'IPSEC ':STACK";
$rrd_options .= " GPRINT:ipsec:LAST:'%8.2lf'";
$rrd_options .= " GPRINT:ipsec:AVERAGE:' %8.2lf'";
$rrd_options .= " GPRINT:ipsec:MAX:' %8.2lf\\\\n'";
$rrd_options .= " AREA:l2l#aaaa00:'Lan-to-Lan '";
$rrd_options .= ' GPRINT:l2l:LAST:%6.2lf%s';
$rrd_options .= " GPRINT:l2l:AVERAGE:' %6.2lf%s'";
$rrd_options .= " GPRINT:l2l:MAX:' %6.2lf%s\\\\n'";
$rrd_options .= " AREA:l2l#C5C3C6:'LAN-to-LAN ':STACK";
$rrd_options .= ' GPRINT:l2l:LAST:%8.2lf';
$rrd_options .= " GPRINT:l2l:AVERAGE:' %8.2lf'";
$rrd_options .= " GPRINT:l2l:MAX:' %8.2lf\\\\n'";
$rrd_options .= " AREA:email#0000aa:'Email '";
$rrd_options .= ' GPRINT:email:LAST:%6.2lf%s';
$rrd_options .= " GPRINT:email:AVERAGE:' %6.2lf%s'";
$rrd_options .= " GPRINT:email:MAX:' %6.2lf%s\\\\n'";
$rrd_options .= " AREA:email#DCDCDD:'Email ':STACK";
$rrd_options .= ' GPRINT:email:LAST:%8.2lf';
$rrd_options .= " GPRINT:email:AVERAGE:' %8.2lf'";
$rrd_options .= " GPRINT:email:MAX:' %8.2lf\\\\n'";
$rrd_options .= " AREA:lb#aa00aa:'Load Balancer '";
$rrd_options .= ' GPRINT:lb:LAST:%6.2lf%s';
$rrd_options .= " GPRINT:lb:AVERAGE:' %6.2lf%s'";
$rrd_options .= " GPRINT:lb:MAX:' %6.2lf%s\\\\n'";
$rrd_options .= " AREA:lb#FFFFFF:'Load Balancer ':STACK";
$rrd_options .= ' GPRINT:lb:LAST:%8.2lf';
$rrd_options .= " GPRINT:lb:AVERAGE:' %8.2lf'";
$rrd_options .= " GPRINT:lb:MAX:' %8.2lf\\\\n'";
// Total
$rrd_options .= " 'CDEF:TOTAL=email,ipsec,l2l,lb,svc,webvpn,+,+,+,+,+'";
$rrd_options .= " 'LINE1:TOTAL#000000FF:Total '";
$rrd_options .= " 'GPRINT:TOTAL:LAST:%8.2lf'";
$rrd_options .= " 'GPRINT:TOTAL:AVERAGE: %8.2lf'";
$rrd_options .= " 'GPRINT:TOTAL:MAX: %8.2lf\\\\n'";

View File

@ -0,0 +1,5 @@
<?php
$class = 'runtime';
$unit = 'Min';
$unit_long = 'Minutes';
require 'includes/graphs/device/sensor.inc.php';

View File

@ -207,9 +207,32 @@ $('#map-stub').typeahead({
$(function () {
$("#start").datetimepicker({
minDate: '<?php echo date($config['dateformat']['byminute']); ?>'
minDate: '<?php echo date($config['dateformat']['byminute']); ?>',
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-calendar-check-o',
clear: 'fa fa-trash-o',
close: 'fa fa-close'
}
});
$("#end").datetimepicker({
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-calendar-check-o',
clear: 'fa fa-trash-o',
close: 'fa fa-close'
}
});
$("#end").datetimepicker();
$("#start").on("dp.change", function (e) {
$("#end").data("DateTimePicker").minDate(e.date);
});

View File

@ -78,16 +78,5 @@ if ($_GET['format'] == 'text') {
$output = preg_replace('/\033\[[\d;]+m/', '', $output);
$length = strlen($output);
header('Content-Description: File Transfer');
header('Content-Type: text/plain');
header("Content-Disposition: attachment; filename=$filename");
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . $length);
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
header('Pragma: public');
echo $output;
file_download($filename, $output);
}

View File

@ -0,0 +1,68 @@
<?php
/**
* output.php
*
* runs the requested query and outputs as a file or text
*
* 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/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/
if (!is_admin()) {
echo("Insufficient Privileges");
exit();
}
$hostname = escapeshellcmd($_REQUEST['hostname']);
$type = $_REQUEST['type'];
switch ($type) {
case 'alerts':
$filename = "alerts-$hostname.txt";
$device_id = getidbyname($hostname);
$device = device_by_id_cache($device_id);
$rules = GetRules($device_id);
$output = '';
foreach ($rules as $rule) {
$sql = GenSQL($rule['rule']);
$qry = dbFetchRow($sql, array($device_id));
if (is_array($qry)) {
$response = 'matches';
} else {
$response = 'no match';
}
$output .= 'Rule name: ' . $rule['name'] . PHP_EOL;
$output .= 'Alert rule: ' . $rule['rule'] . PHP_EOL;
$output .= 'Rule match: ' . $response . PHP_EOL . PHP_EOL;
}
break;
default:
echo 'You must specify a valid type';
exit();
}
// ---- Output ----
if ($_GET['format'] == 'text') {
header("Content-type: text/plain");
header('X-Accel-Buffering: no');
echo $output;
} elseif ($_GET['format'] == 'download') {
file_download($filename, $output);
}

View File

@ -162,13 +162,13 @@ $full_query = $full_query.$query." LIMIT $start,$results";
foreach (dbFetchRows($full_query, $param) as $rule) {
$sub = dbFetchRows('SELECT * FROM alerts WHERE rule_id = ? ORDER BY `state` DESC, `id` DESC LIMIT 1', array($rule['id']));
$ico = 'ok';
$ico = 'check';
$col = 'success';
$extra = '';
if (sizeof($sub) == 1) {
$sub = $sub[0];
if ((int) $sub['state'] === 0) {
$ico = 'ok';
$ico = 'check';
$col = 'success';
} elseif ((int) $sub['state'] === 1 || (int) $sub['state'] === 2) {
$ico = 'remove';
@ -205,9 +205,9 @@ foreach (dbFetchRows($full_query, $param) as $rule) {
echo '<i>'.htmlentities($rule['rule']).'</i></td>';
echo '<td>'.$rule['severity'].'</td>';
echo "<td><span id='alert-rule-".$rule['id']."' class='glyphicon glyphicon-".$ico.' glyphicon-large text-'.$col."'></span> ";
echo "<td><span id='alert-rule-".$rule['id']."' class='fa fa-fw fa-2x fa-".$ico.' text-'.$col."'></span> ";
if ($rule_extra['mute'] === true) {
echo "<span class='glyphicon glyphicon-volume-off glyphicon-large text-primary' aria-hidden='true'></span></td>";
echo "<i class='fa fa-fw fa-2x fa-volume-off text-primary' aria-hidden='true'></i></td>";
}
echo '<td><small>Max: '.$rule_extra['count'].'<br />Delay: '.$rule_extra['delay'].'<br />Interval: '.$rule_extra['interval'].'</small></td>';
@ -219,8 +219,9 @@ foreach (dbFetchRows($full_query, $param) as $rule) {
echo '</td>';
echo '<td>';
if ($_SESSION['userlevel'] >= '10') {
echo "<button type='button' class='btn btn-primary btn-sm' data-toggle='modal' data-target='#create-alert' data-device_id='".$rule['device_id']."' data-alert_id='".$rule['id']."' name='edit-alert-rule' data-content='".$popover_msg."'><span class='glyphicon glyphicon-pencil' aria-hidden='true'></span></button> ";
echo "<button type='button' class='btn btn-danger btn-sm' aria-label='Delete' data-toggle='modal' data-target='#confirm-delete' data-alert_id='".$rule['id']."' name='delete-alert-rule' data-content='".$popover_msg."'><span class='glyphicon glyphicon-trash' aria-hidden='true'></span></button>";
echo "<div class='btn-group btn-group-sm' role='group'>";
echo "<button type='button' class='btn btn-primary' data-toggle='modal' data-target='#create-alert' data-device_id='".$rule['device_id']."' data-alert_id='".$rule['id']."' name='edit-alert-rule' data-content='".$popover_msg."' data-container='body'><i class='fa fa-lg fa-pencil' aria-hidden='true'></i></button> ";
echo "<button type='button' class='btn btn-danger' aria-label='Delete' data-toggle='modal' data-target='#confirm-delete' data-alert_id='".$rule['id']."' name='delete-alert-rule' data-content='".$popover_msg."' data-container='body'><i class='fa fa-lg fa-trash' aria-hidden='true'></i></button>";
}
echo '</td>';
@ -297,15 +298,15 @@ $('input[name="alert-rule"]').on('switchChange.bootstrapSwitch', function(event
success: function(msg) {
if(msg.indexOf("ERROR:") <= -1) {
if(state) {
$('#alert-rule-'+alert_id).removeClass('glyphicon-pause');
$('#alert-rule-'+alert_id).addClass('glyphicon-'+orig_state);
$('#alert-rule-'+alert_id).removeClass('fa-pause');
$('#alert-rule-'+alert_id).addClass('fa-'+orig_state);
$('#alert-rule-'+alert_id).removeClass('text-default');
$('#alert-rule-'+alert_id).addClass('text-'+orig_colour);
$('#row_'+alert_id).removeClass('active');
$('#row_'+alert_id).addClass(orig_class);
} else {
$('#alert-rule-'+alert_id).removeClass('glyphicon-'+orig_state);
$('#alert-rule-'+alert_id).addClass('glyphicon-pause');
$('#alert-rule-'+alert_id).removeClass('fa-'+orig_state);
$('#alert-rule-'+alert_id).addClass('fa-pause');
$('#alert-rule-'+alert_id).removeClass('text-'+orig_colour);
$('#alert-rule-'+alert_id).addClass('text-default');
$('#row_'+alert_id).removeClass('warning');

View File

@ -79,9 +79,11 @@ foreach (dbFetchRows($full_query, $param) as $template) {
<td>'.$template['name'].'</td>
<td>';
if ($_SESSION['userlevel'] >= '10') {
echo "<button type='button' class='btn btn-primary btn-sm' data-toggle='modal' data-target='#alert-template' data-template_id='".$template['id']."' data-template_action='edit' name='edit-alert-template'><span class='glyphicon glyphicon-pencil' aria-hidden='true'></span></button> ";
echo "<button type='button' class='btn btn-danger btn-sm' data-toggle='modal' data-target='#confirm-delete-alert-template' data-template_id='".$template['id']."' name='delete-alert-template'><span class='glyphicon glyphicon-trash' aria-hidden='true'></span></button> ";
echo "<button type='button' class='btn btn-warning btn-sm' data-toggle='modal' data-target='#attach-alert-template' data-template_id='".$template['id']."' name='attach-alert-template'><span class='glyphicon glyphicon-th-list' aria-hidden='true'></span></button>";
echo "<div class='btn-group btn-group-sm' role='group'>";
echo "<button type='button' class='btn btn-primary btn-sm' data-toggle='modal' data-target='#alert-template' data-template_id='".$template['id']."' data-template_action='edit' name='edit-alert-template'><i class='fa fa-lg fa-pencil' aria-hidden='true'></i></button> ";
echo "<button type='button' class='btn btn-danger btn-sm' data-toggle='modal' data-target='#confirm-delete-alert-template' data-template_id='".$template['id']."' name='delete-alert-template'><i class='fa fa-lg fa-trash' aria-hidden='true'></i></button> ";
echo "<button type='button' class='btn btn-warning btn-sm' data-toggle='modal' data-target='#attach-alert-template' data-template_id='".$template['id']."' name='attach-alert-template'><i class='fa fa-th-list' aria-hidden='true'></i></button>";
echo "</div>";
}
echo ' </td>

View File

@ -19,27 +19,27 @@ echo '<td>'.htmlspecialchars($alert_entry['name']).'</td>';
if ($alert_state != '') {
if ($alert_state == '0') {
$glyph_icon = 'ok';
$glyph_color = 'green';
$text = 'Ok';
$fa_icon = 'check';
$fa_color = 'success';
$text = 'Ok';
} elseif ($alert_state == '1') {
$glyph_icon = 'remove';
$glyph_color = 'red';
$text = 'Alert';
$fa_icon = 'remove';
$fa_color = 'danger';
$text = 'Alert';
} elseif ($alert_state == '2') {
$glyph_icon = 'info-sign';
$glyph_color = 'lightgrey';
$text = 'Ack';
$fa_icon = 'info-circle';
$fa_color = 'muted';
$text = 'Ack';
} elseif ($alert_state == '3') {
$glyph_icon = 'arrow-down';
$glyph_color = 'orange';
$text = 'Worse';
$fa_icon = 'arrow-down';
$fa_color = 'warning';
$text = 'Worse';
} elseif ($alert_state == '4') {
$glyph_icon = 'arrow-up';
$glyph_color = 'khaki';
$text = 'Better';
$fa_icon = 'arrow-up';
$fa_color = 'info';
$text = 'Better';
}//end if
echo "<td><b><span class='glyphicon glyphicon-".$glyph_icon."' style='color:".$glyph_color."'></span> $text</b></td>";
echo "<td><b><i class='fa fa-fw fa-".$fa_icon." text-".$fa_color."'></i> $text</b></td>";
}//end if
echo '</tr>';

View File

@ -33,8 +33,8 @@ echo '
("0"+strto.getHours()).slice(-2)+":"+
("0"+strto.getMinutes()).slice(-2)
);
$("#dtpickerfrom").datetimepicker({useCurrent: true, sideBySide: true, useStrict: false});
$("#dtpickerto").datetimepicker({useCurrent: true, sideBySide: true, useStrict: false});
$("#dtpickerfrom").datetimepicker({useCurrent: true, sideBySide: true, useStrict: false, icons: {time: "fa fa-clock-o", date: "fa fa-calendar", up: "fa fa-chevron-up", down: "fa fa-chevron-down", previous: "fa fa-chevron-left", next: "fa fa-chevron-right", today: "fa fa-calendar-check-o", clear: "fa fa-trash-o", close: "fa fa-close"}});
$("#dtpickerto").datetimepicker({useCurrent: true, sideBySide: true, useStrict: false, icons: {time: "fa fa-clock-o", date: "fa fa-calendar", up: "fa fa-chevron-up", down: "fa fa-chevron-down", previous: "fa fa-chevron-left", next: "fa fa-chevron-right", today: "fa fa-calendar-check-o", clear: "fa fa-trash-o", close: "fa fa-close"}});
});
</script></center>
';

View File

@ -232,7 +232,7 @@ if (strpos($port['label'], 'oopback') === false && !$graph_type) {
}//end if
if (count($int_links) > 3) {
echo '<div class="collapse-neighbors"><span class="neighbors-button glyphicon glyphicon-plus" aria-hidden="true"></span>
echo '<div class="collapse-neighbors"><i class="neighbors-button fa fa-plus" aria-hidden="true"></i>
<span class="neighbors-interface-list-firsts" style="display: inline;">';
}

View File

@ -48,21 +48,21 @@ if ($config['title_image']) {
<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 hidden-md"></i> <span class="hidden-sm">Overview</span></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" aria-hidden="true"></i> <span class="hidden-sm">Overview</span></a>
<ul class="dropdown-menu multi-level" role="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><a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-lightbulb-o fa-fw fa-lg" aria-hidden="true"></i> Overview</a></li>
<li class="dropdown-submenu">
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-sitemap fa-fw fa-lg"></i> Maps</a>
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-sitemap fa-fw fa-lg" aria-hidden="true"></i> Maps</a>
<ul class="dropdown-menu">
<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>
<li><a href="<?php echo(generate_url(array('page'=>'availability-map'))); ?>"><i class="fa fa-arrow-circle-up fa-fw fa-lg" aria-hidden="true"></i> Availability</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'map'))); ?>"><i class="fa fa-desktop fa-fw fa-lg" aria-hidden="true"></i> Network</a></li>
<?php
require_once '../includes/device-groups.inc.php';
$devices_groups = GetDeviceGroups();
if (count($devices_groups) > 0) {
echo '<li class="dropdown-submenu"><a href="#"><i class="fa fa-th fa-fw fa-lg"></i> Device Groups Maps</a><ul class="dropdown-menu scrollable-menu">';
echo '<li class="dropdown-submenu"><a href="#"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> Device Groups Maps</a><ul class="dropdown-menu scrollable-menu">';
foreach ($devices_groups as $group) {
echo '<li><a href="'.generate_url(array('page'=>'map','group'=>$group['id'])).'" title="'.$group['desc'].'"><i class="fa fa-th fa-fw fa-lg"></i> '.ucfirst($group['name']).'</a></li>';
echo '<li><a href="'.generate_url(array('page'=>'map','group'=>$group['id'])).'" title="'.$group['desc'].'"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> '.ucfirst($group['name']).'</a></li>';
}
unset($group);
echo '</ul></li>';
@ -71,7 +71,7 @@ if ($config['title_image']) {
</ul>
</li>
<li class="dropdown-submenu">
<a><i class="fa fa-plug fa-fw fa-lg"></i> Plugins</a>
<a><i class="fa fa-plug fa-fw fa-lg" aria-hidden="true"></i> Plugins</a>
<ul class="dropdown-menu scrollable-menu">
<?php
\LibreNMS\Plugins::call('menu');
@ -80,61 +80,61 @@ if ($config['title_image']) {
if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) {
echo('<li role="presentation" class="divider"></li>');
}
echo('<li><a href="plugin/view=admin"> <i class="fa fa-lock fa-fw fa-lg"></i>Plugin Admin</a></li>');
echo('<li><a href="plugin/view=admin"> <i class="fa fa-lock fa-fw fa-lg" aria-hidden="true"></i>Plugin Admin</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>
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-wrench fa-fw fa-lg" aria-hidden="true"></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>
<li><a href="<?php echo(generate_url(array('page'=>'ripenccapi'))); ?>"><i class="fa fa-arrow-circle-up fa-fw fa-lg" aria-hidden="true"></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>
<li><a href="<?php echo(generate_url(array('page'=>'eventlog'))); ?>"><i class="fa fa-book fa-fw fa-lg" aria-hidden="true"></i> Eventlog</a></li>
<?php
if (isset($config['enable_syslog']) && $config['enable_syslog']) {
echo ' <li><a href="'.generate_url(array('page'=>'syslog')).'"><i class="fa fa-book fa-fw fa-lg"></i> Syslog</a></li>';
echo ' <li><a href="'.generate_url(array('page'=>'syslog')).'"><i class="fa fa-book fa-fw fa-lg" aria-hidden="true"></i> Syslog</a></li>';
}
if (isset($config['graylog']['server']) && isset($config['graylog']['port'])) {
echo ' <li><a href="'.generate_url(array('page'=>'graylog')).'"><i class="fa fa-book fa-fw fa-lg"></i> Graylog</a></li>';
echo ' <li><a href="'.generate_url(array('page'=>'graylog')).'"><i class="fa fa-book fa-fw fa-lg" aria-hidden="true"></i> Graylog</a></li>';
}
?>
<li><a href="<?php echo(generate_url(array('page'=>'inventory'))); ?>"><i class="fa fa-cube fa-fw fa-lg"></i> Inventory</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'inventory'))); ?>"><i class="fa fa-cube fa-fw fa-lg" aria-hidden="true"></i> Inventory</a></li>
<?php
if (dbFetchCell("SELECT 1 from `packages` LIMIT 1")) {
?>
<li>
<a href="<?php echo(generate_url(array('page'=>'search','search'=>'packages'))); ?>"><i class="fa fa-archive fa-fw fa-lg"></i> Packages</a>
<a href="<?php echo(generate_url(array('page'=>'search','search'=>'packages'))); ?>"><i class="fa fa-archive fa-fw fa-lg" aria-hidden="true"></i> Packages</a>
</li>
<?php
} # if ($packages)
?>
<li role="presentation" class="divider"></li>
<li role="presentation" class="dropdown-header"> Search</li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'ipv4'))); ?>"><i class="fa fa-search fa-fw fa-lg"></i> IPv4 Search</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'ipv6'))); ?>"><i class="fa fa-search fa-fw fa-lg"></i> IPv6 Search</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'mac'))); ?>"><i class="fa fa-search fa-fw fa-lg"></i> MAC Search</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'arp'))); ?>"><i class="fa fa-search fa-fw fa-lg"></i> ARP Tables</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'ipv4'))); ?>"><i class="fa fa-search fa-fw fa-lg" aria-hidden="true"></i> IPv4 Search</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'ipv6'))); ?>"><i class="fa fa-search fa-fw fa-lg" aria-hidden="true"></i> IPv6 Search</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'mac'))); ?>"><i class="fa fa-search fa-fw fa-lg" aria-hidden="true"></i> MAC Search</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'arp'))); ?>"><i class="fa fa-search fa-fw fa-lg" aria-hidden="true"></i> ARP Tables</a></li>
<?php
if (is_module_enabled('poller', 'mib')) {
?>
<li role="presentation" class="divider"></li>
<li><a href="<?php echo(generate_url(array('page'=>'mibs'))); ?>"><i class="fa fa-file-text-o fa-fw fa-lg"></i> MIB definitions</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'mibs'))); ?>"><i class="fa fa-file-text-o fa-fw fa-lg" aria-hidden="true"></i> MIB definitions</a></li>
<?php
}
?>
</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 hidden-md"></i> <span class="hidden-sm">Devices</span></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" aria-hidden="true"></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>
<a href="devices/"><i class="fa fa-server fa-fw fa-lg" aria-hidden="true"></i> All Devices</a>
<ul class="dropdown-menu scrollable-menu">
<?php
@ -150,15 +150,15 @@ foreach (dbFetchRows($sql, $param) as $devtype) {
if (empty($devtype['type'])) {
$devtype['type'] = 'generic';
}
echo(' <li><a href="devices/type=' . $devtype['type'] . '/"><i class="fa fa-angle-double-right fa-fw fa-lg"></i> ' . ucfirst($devtype['type']) . '</a></li>');
echo(' <li><a href="devices/type=' . $devtype['type'] . '/"><i class="fa fa-angle-double-right fa-fw fa-lg" aria-hidden="true"></i> ' . ucfirst($devtype['type']) . '</a></li>');
}
echo ('</ul>
</li>');
if (count($devices_groups) > 0) {
echo '<li class="dropdown-submenu"><a href="#"><i class="fa fa-th fa-fw fa-lg"></i> Device Groups</a><ul class="dropdown-menu scrollable-menu">';
echo '<li class="dropdown-submenu"><a href="#"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> Device Groups</a><ul class="dropdown-menu scrollable-menu">';
foreach ($devices_groups as $group) {
echo '<li><a href="'.generate_url(array('page'=>'devices','group'=>$group['id'])).'" title="'.$group['desc'].'"><i class="fa fa-th fa-fw fa-lg"></i> '.ucfirst($group['name']).'</a></li>';
echo '<li><a href="'.generate_url(array('page'=>'devices','group'=>$group['id'])).'" title="'.$group['desc'].'"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> '.ucfirst($group['name']).'</a></li>';
}
unset($group);
echo '</ul></li>';
@ -168,12 +168,12 @@ if ($_SESSION['userlevel'] >= '10') {
echo('
<li role="presentation" class="divider"></li>
<li class="dropdown-submenu">
<a href="#"><i class="fa fa-map-marker fa-fw fa-lg"></i> Locations</a>
<a href="#"><i class="fa fa-map-marker fa-fw fa-lg" aria-hidden="true"></i> Locations</a>
<ul class="dropdown-menu scrollable-menu">
');
if ($config['show_locations_dropdown']) {
foreach (getlocations() as $location) {
echo(' <li><a href="devices/location=' . urlencode($location) . '/"><i class="fa fa-building-o fa-fw fa-lg"></i> ' . $location . ' </a></li>');
echo(' <li><a href="devices/location=' . urlencode($location) . '/"><i class="fa fa-building-o fa-fw fa-lg" aria-hidden="true"></i> ' . $location . ' </a></li>');
}
}
echo('
@ -185,18 +185,18 @@ if ($_SESSION['userlevel'] >= '10') {
<li role="presentation" class="divider"></li>';
if (is_module_enabled('poller', 'mib')) {
echo '
<li><a href='.generate_url(array('page'=>'mib_assoc')).'><i class="fa fa-file-text-o fa-fw fa-lg"></i> MIB associations</a></li>
<li><a href='.generate_url(array('page'=>'mib_assoc')).'><i class="fa fa-file-text-o fa-fw fa-lg" aria-hidden="true"></i> MIB associations</a></li>
<li role="presentation" class="divider"></li>
';
}
if ($config['navbar']['manage_groups']['hide'] === 0) {
echo '<li><a href="'.generate_url(array('page'=>'device-groups')).'"><i class="fa fa-th fa-fw fa-lg"></i> Manage Groups</a></li>';
echo '<li><a href="'.generate_url(array('page'=>'device-groups')).'"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> Manage Groups</a></li>';
}
echo '
<li><a href="addhost/"><i class="fa fa-plus fa-col-success fa-fw fa-lg"></i> Add Device</a></li>
<li><a href="delhost/"><i class="fa fa-trash fa-col-info fa-fw fa-lg"></i> Delete Device</a></li>';
<li><a href="addhost/"><i class="fa fa-plus fa-col-success fa-fw fa-lg" aria-hidden="true"></i> Add Device</a></li>
<li><a href="delhost/"><i class="fa fa-trash fa-col-info fa-fw fa-lg" aria-hidden="true"></i> Delete Device</a></li>';
}
?>
@ -208,26 +208,26 @@ 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 hidden-md"></i> <span class="hidden-sm">Services</span></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" aria-hidden="true"></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>
<li><a href="services/"><i class="fa fa-cogs fa-fw fa-lg" aria-hidden="true"></i> All Services </a></li>
<?php
if (($service_status[1] > 0) || ($service_status[2] > 0)) {
echo ' <li role="presentation" class="divider"></li>';
if ($service_status[1] > 0) {
echo ' <li><a href="services/state=warning/"><i class="fa fa-bell-o fa-col-warning fa-fw fa-lg"></i> Warning ('.$service_status[1].')</a></li>';
echo ' <li><a href="services/state=warning/"><i class="fa fa-bell-o fa-col-warning fa-fw fa-lg" aria-hidden="true"></i> Warning ('.$service_status[1].')</a></li>';
}
if ($service_status[2] > 0) {
echo ' <li><a href="services/state=critical/"><i class="fa fa-bell-o fa-col-danger fa-fw fa-lg"></i> Critical ('.$service_status[2].')</a></li>';
echo ' <li><a href="services/state=critical/"><i class="fa fa-bell-o fa-col-danger fa-fw fa-lg" aria-hidden="true"></i> Critical ('.$service_status[2].')</a></li>';
}
}
if ($_SESSION['userlevel'] >= '10') {
echo('
<li role="presentation" class="divider"></li>
<li><a href="addsrv/"><i class="fa fa-cog fa-col-success fa-fw fa-lg"></i> Add Service</a></li>');
<li><a href="addsrv/"><i class="fa fa-cog fa-col-success fa-fw fa-lg" aria-hidden="true"></i> Add Service</a></li>');
}
?>
</ul>
@ -239,28 +239,28 @@ 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 hidden-md"></i> <span class="hidden-sm">Ports</span></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" aria-hidden="true"></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>
<li><a href="ports/"><i class="fa fa-link fa-fw fa-lg" aria-hidden="true"></i> All Ports</a></li>
<?php
$ports = new ObjectCache('ports');
if ($ports['errored'] > 0) {
echo(' <li><a href="ports/errors=1/"><i class="fa fa-exclamation-circle fa-fw fa-lg"></i> Errored ('.$ports['errored'].')</a></li>');
echo(' <li><a href="ports/errors=1/"><i class="fa fa-exclamation-circle fa-fw fa-lg" aria-hidden="true"></i> Errored ('.$ports['errored'].')</a></li>');
}
if ($ports['ignored'] > 0) {
echo(' <li><a href="ports/ignore=1/"><i class="fa fa-question-circle fa-fw fa-lg"></i> Ignored ('.$ports['ignored'].')</a></li>');
echo(' <li><a href="ports/ignore=1/"><i class="fa fa-question-circle fa-fw fa-lg" aria-hidden="true"></i> Ignored ('.$ports['ignored'].')</a></li>');
}
if ($config['enable_billing']) {
echo(' <li><a href="bills/"><i class="fa fa-money fa-fw fa-lg"></i> Traffic Bills</a></li>');
echo(' <li><a href="bills/"><i class="fa fa-money fa-fw fa-lg" aria-hidden="true"></i> Traffic Bills</a></li>');
$ifbreak = 1;
}
if ($config['enable_pseudowires']) {
echo(' <li><a href="pseudowires/"><i class="fa fa-arrows-alt fa-fw fa-lg"></i> Pseudowires</a></li>');
echo(' <li><a href="pseudowires/"><i class="fa fa-arrows-alt fa-fw fa-lg" aria-hidden="true"></i> Pseudowires</a></li>');
$ifbreak = 1;
}
@ -270,27 +270,27 @@ if ($config['enable_pseudowires']) {
if ($_SESSION['userlevel'] >= '5') {
echo(' <li role="presentation" class="divider"></li>');
if ($config['int_customers']) {
echo(' <li><a href="customers/"><i class="fa fa-users fa-fw fa-lg"></i> Customers</a></li>');
echo(' <li><a href="customers/"><i class="fa fa-users fa-fw fa-lg" aria-hidden="true"></i> Customers</a></li>');
$ifbreak = 1;
}
if ($config['int_l2tp']) {
echo(' <li><a href="iftype/type=l2tp/"><i class="fa fa-link fa-fw fa-lg"></i> L2TP</a></li>');
echo(' <li><a href="iftype/type=l2tp/"><i class="fa fa-link fa-fw fa-lg" aria-hidden="true"></i> L2TP</a></li>');
$ifbreak = 1;
}
if ($config['int_transit']) {
echo(' <li><a href="iftype/type=transit/"><i class="fa fa-truck fa-fw fa-lg"></i> Transit</a></li>');
echo(' <li><a href="iftype/type=transit/"><i class="fa fa-truck fa-fw fa-lg" aria-hidden="true"></i> Transit</a></li>');
$ifbreak = 1;
}
if ($config['int_peering']) {
echo(' <li><a href="iftype/type=peering/"><i class="fa fa-user-plus fa-fw fa-lg"></i> Peering</a></li>');
echo(' <li><a href="iftype/type=peering/"><i class="fa fa-user-plus fa-fw fa-lg" aria-hidden="true"></i> Peering</a></li>');
$ifbreak = 1;
}
if ($config['int_peering'] && $config['int_transit']) {
echo(' <li><a href="iftype/type=peering,transit/"><i class="fa fa-user-secret fa-fw fa-lg"></i> Peering + Transit</a></li>');
echo(' <li><a href="iftype/type=peering,transit/"><i class="fa fa-user-secret fa-fw fa-lg" aria-hidden="true"></i> Peering + Transit</a></li>');
$ifbreak = 1;
}
if ($config['int_core']) {
echo(' <li><a href="iftype/type=core/"><i class="fa fa-anchor fa-fw fa-lg"></i> Core</a></li>');
echo(' <li><a href="iftype/type=core/"><i class="fa fa-anchor fa-fw fa-lg" aria-hidden="true"></i> Core</a></li>');
$ifbreak = 1;
}
if (is_array($config['custom_descr']) === false) {
@ -298,7 +298,7 @@ if ($_SESSION['userlevel'] >= '5') {
}
foreach ($config['custom_descr'] as $custom_type) {
if (!empty($custom_type)) {
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>';
echo ' <li><a href="iftype/type=' . urlencode(strtolower($custom_type)) . '"><i class="fa fa-connectdevelop fa-fw fa-lg" aria-hidden="true"></i> ' . ucfirst($custom_type) . '</a></li>';
$ifbreak = 1;
}
}
@ -309,7 +309,7 @@ if ($ifbreak) {
}
if (isset($interface_alerts)) {
echo(' <li><a href="ports/alerted=yes/"><i class="fa fa-exclamation-circle fa-fw fa-lg"></i> Alerts ('.$interface_alerts.')</a></li>');
echo(' <li><a href="ports/alerted=yes/"><i class="fa fa-exclamation-circle fa-fw fa-lg" aria-hidden="true"></i> Alerts ('.$interface_alerts.')</a></li>');
}
$deleted_ports = 0;
@ -320,12 +320,12 @@ foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`delete
}
?>
<li><a href="ports/state=down/"><i class="fa fa-exclamation-triangle fa-col-danger fa-fw fa-lg"></i> Down</a></li>
<li><a href="ports/state=admindown/"><i class="fa fa-pause fa-col-info fa-fw fa-lg"></i> Disabled</a></li>
<li><a href="ports/state=down/"><i class="fa fa-exclamation-triangle fa-col-danger fa-fw fa-lg" aria-hidden="true"></i> Down</a></li>
<li><a href="ports/state=admindown/"><i class="fa fa-pause fa-col-info fa-fw fa-lg" aria-hidden="true"></i> Disabled</a></li>
<?php
if ($deleted_ports) {
echo(' <li><a href="deleted-ports/"><i class="fa fa-minus-circle fa-col-primary fa-fw fa-lg"></i> Deleted ('.$deleted_ports.')</a></li>');
echo(' <li><a href="deleted-ports/"><i class="fa fa-minus-circle fa-col-primary fa-fw fa-lg" aria-hidden="true"></i> Deleted ('.$deleted_ports.')</a></li>');
}
?>
@ -345,11 +345,11 @@ $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 hidden-md"></i> <span class="hidden-sm">Health</span></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" aria-hidden="true"></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>
<li><a href="health/metric=storage/"><i class="fa fa-database fa-fw fa-lg"></i> Storage</a></li>
<li><a href="health/metric=mempool/"><i class="fa fa-gears fa-fw fa-lg" aria-hidden="true"></i> Memory</a></li>
<li><a href="health/metric=processor/"><i class="fa fa-desktop fa-fw fa-lg" aria-hidden="true"></i> Processor</a></li>
<li><a href="health/metric=storage/"><i class="fa fa-database fa-fw fa-lg" aria-hidden="true"></i> Storage</a></li>
<?php
if ($menu_sensors) {
$sep = 0;
@ -359,7 +359,7 @@ if ($menu_sensors) {
$icons = array('fanspeed'=>'tachometer','humidity'=>'tint','temperature'=>'fire','current'=>'bolt','frequency'=>'line-chart','power'=>'power-off','voltage'=>'bolt','charge'=>'plus-square','dbm'=>'sun-o', 'load'=>'spinner','state'=>'bullseye','signal'=>'wifi');
foreach (array('fanspeed','humidity','temperature','signal') as $item) {
if (isset($menu_sensors[$item])) {
echo(' <li><a href="health/metric='.$item.'/"><i class="fa fa-'.$icons[$item].' fa-fw fa-lg"></i> '.nicecase($item).'</a></li>');
echo(' <li><a href="health/metric='.$item.'/"><i class="fa fa-'.$icons[$item].' fa-fw fa-lg" aria-hidden="true"></i> '.nicecase($item).'</a></li>');
unset($menu_sensors[$item]);
$sep++;
}
@ -372,7 +372,7 @@ if ($sep && array_keys($menu_sensors)) {
foreach (array('current','frequency','power','voltage') as $item) {
if (isset($menu_sensors[$item])) {
echo(' <li><a href="health/metric='.$item.'/"><i class="fa fa-'.$icons[$item].' fa-fw fa-lg"></i> '.nicecase($item).'</a></li>');
echo(' <li><a href="health/metric='.$item.'/"><i class="fa fa-'.$icons[$item].' fa-fw fa-lg" aria-hidden="true"></i> '.nicecase($item).'</a></li>');
unset($menu_sensors[$item]);
$sep++;
}
@ -384,7 +384,7 @@ if ($sep && array_keys($menu_sensors)) {
}
foreach (array_keys($menu_sensors) as $item) {
echo(' <li><a href="health/metric='.$item.'/"><i class="fa fa-'.$icons[$item].' fa-fw fa-lg"></i> '.nicecase($item).'</a></li>');
echo(' <li><a href="health/metric='.$item.'/"><i class="fa fa-'.$icons[$item].' fa-fw fa-lg" aria-hidden="true"></i> '.nicecase($item).'</a></li>');
unset($menu_sensors[$item]);
$sep++;
}
@ -399,7 +399,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 hidden-md"></i> <span class="hidden-sm">Apps</span></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" aria-hidden="true"></i> <span class="hidden-sm">Apps</span></a>
<ul class="dropdown-menu">
<?php
@ -410,14 +410,14 @@ foreach ($app_list as $app) {
$icon = (file_exists($image) ? $app['app_type'] : "apps");
if (count($app_i_list) > 1) {
echo '<li class="dropdown-submenu">';
echo '<a href="apps/app='.$app['app_type'].'/"><i class="fa fa-server fa-fw fa-lg"></i> '.nicecase($app['app_type']).' </a>';
echo '<a href="apps/app='.$app['app_type'].'/"><i class="fa fa-server fa-fw fa-lg" aria-hidden="true"></i> '.nicecase($app['app_type']).' </a>';
echo '<ul class="dropdown-menu scrollable-menu">';
foreach ($app_i_list as $instance) {
echo ' <li><a href="apps/app='.$app['app_type'].'/instance='.$instance['app_instance'].'/"><i class="fa fa-angle-double-right fa-fw fa-lg"></i> ' . nicecase($instance['app_instance']) . '</a></li>';
echo ' <li><a href="apps/app='.$app['app_type'].'/instance='.$instance['app_instance'].'/"><i class="fa fa-angle-double-right fa-fw fa-lg" aria-hidden="true"></i> ' . nicecase($instance['app_instance']) . '</a></li>';
}
echo '</ul></li>';
} else {
echo('<li><a href="apps/app='.$app['app_type'].'/"><i class="fa fa-angle-double-right fa-fw fa-lg"></i> '.nicecase($app['app_type']).' </a></li>');
echo('<li><a href="apps/app='.$app['app_type'].'/"><i class="fa fa-angle-double-right fa-fw fa-lg" aria-hidden="true"></i> '.nicecase($app['app_type']).' </a></li>');
}
}
}
@ -440,13 +440,13 @@ $routing_count['cisco-otv'] = count($otv);
if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']+$routing_count['cisco-otv']) > "0") {
?>
<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 hidden-md"></i> <span class="hidden-sm">Routing</span></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" aria-hidden="true"></i> <span class="hidden-sm">Routing</span></a>
<ul class="dropdown-menu">
<?php
$separator = 0;
if ($_SESSION['userlevel'] >= '5' && $routing_count['vrf']) {
echo(' <li><a href="routing/protocol=vrf/"><i class="fa fa-arrows-alt fa-fw fa-lg"></i> VRFs</a></li>');
echo(' <li><a href="routing/protocol=vrf/"><i class="fa fa-arrows-alt fa-fw fa-lg" aria-hidden="true"></i> VRFs</a></li>');
$separator++;
}
@ -455,7 +455,7 @@ if ($_SESSION['userlevel'] >= '5' && $routing_count['ospf']) {
echo(' <li role="presentation" class="divider"></li>');
$separator = 0;
}
echo('<li><a href="routing/protocol=ospf/"><i class="fa fa-circle-o-notch fa-rotate-180 fa-fw fa-lg"></i> OSPF Devices </a></li>');
echo('<li><a href="routing/protocol=ospf/"><i class="fa fa-circle-o-notch fa-rotate-180 fa-fw fa-lg" aria-hidden="true"></i> OSPF Devices </a></li>');
$separator++;
}
@ -465,7 +465,7 @@ if ($_SESSION['userlevel'] >= '5' && $routing_count['cisco-otv']) {
echo(' <li role="presentation" class="divider"></li>');
$separator = 0;
}
echo('<li><a href="routing/protocol=cisco-otv/"><i class="fa fa-exchange fa-fw fa-lg"></i> Cisco OTV </a></li>');
echo('<li><a href="routing/protocol=cisco-otv/"><i class="fa fa-exchange fa-fw fa-lg" aria-hidden="true"></i> Cisco OTV </a></li>');
$separator++;
}
@ -475,16 +475,16 @@ if ($_SESSION['userlevel'] >= '5' && $routing_count['bgp']) {
echo(' <li role="presentation" class="divider"></li>');
$separator = 0;
}
echo('<li><a href="routing/protocol=bgp/type=all/graph=NULL/"><i class="fa fa-link fa-fw fa-lg"></i> BGP All Sessions </a></li>
<li><a href="routing/protocol=bgp/type=external/graph=NULL/"><i class="fa fa-external-link fa-fw fa-lg"></i> BGP External</a></li>
<li><a href="routing/protocol=bgp/type=internal/graph=NULL/"><i class="fa fa-external-link fa-rotate-180 fa-fw fa-lg"></i> BGP Internal</a></li>');
echo('<li><a href="routing/protocol=bgp/type=all/graph=NULL/"><i class="fa fa-link fa-fw fa-lg" aria-hidden="true"></i> BGP All Sessions </a></li>
<li><a href="routing/protocol=bgp/type=external/graph=NULL/"><i class="fa fa-external-link fa-fw fa-lg" aria-hidden="true"></i> BGP External</a></li>
<li><a href="routing/protocol=bgp/type=internal/graph=NULL/"><i class="fa fa-external-link fa-rotate-180 fa-fw fa-lg" aria-hidden="true"></i> BGP Internal</a></li>');
}
// Do Alerts at the bottom
if ($bgp_alerts) {
echo('
<li role="presentation" class="divider"></li>
<li><a href="routing/protocol=bgp/adminstatus=start/state=down/"><i class="fa fa-exclamation-circle fa-fw fa-lg"></i> Alerted BGP (' . $bgp_alerts . ')</a></li>');
<li><a href="routing/protocol=bgp/adminstatus=start/state=down/"><i class="fa fa-exclamation-circle fa-fw fa-lg" aria-hidden="true"></i> Alerted BGP (' . $bgp_alerts . ')</a></li>');
}
echo(' </ul>');
@ -506,18 +506,18 @@ if ($alerts['active_count'] > 0) {
?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-exclamation-circle fa-col-<?php echo $alert_colour;?> fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Alerts</span></a>
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-exclamation-circle fa-col-<?php echo $alert_colour;?> fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Alerts</span></a>
<ul class="dropdown-menu">
<li><a href="<?php echo(generate_url(array('page'=>'alerts'))); ?>"><i class="fa fa-bell fa-fw fa-lg"></i> Notifications</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-log'))); ?>"><i class="fa fa-th-list fa-fw fa-lg"></i> Historical Log</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-stats'))); ?>"><i class="fa fa-bar-chart fa-fw fa-lg"></i> Statistics</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alerts'))); ?>"><i class="fa fa-bell fa-fw fa-lg" aria-hidden="true"></i> Notifications</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-log'))); ?>"><i class="fa fa-th-list fa-fw fa-lg" aria-hidden="true"></i> Historical Log</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-stats'))); ?>"><i class="fa fa-bar-chart fa-fw fa-lg" aria-hidden="true"></i> Statistics</a></li>
<?php
if ($_SESSION['userlevel'] >= '10') {
?>
<li><a href="<?php echo(generate_url(array('page'=>'alert-rules'))); ?>"><i class="fa fa-tasks fa-fw fa-lg"></i> Rules</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-schedule'))); ?>"><i class="fa fa-calendar fa-fw fa-lg"></i> Maintenance Windows</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-map'))); ?>"><i class="fa fa-link fa-fw fa-lg"></i> Rule Mapping</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'templates'))); ?>"><i class="fa fa-sitemap fa-fw fa-lg"></i> Templates</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-rules'))); ?>"><i class="fa fa-tasks fa-fw fa-lg" aria-hidden="true"></i> Rules</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-schedule'))); ?>"><i class="fa fa-calendar fa-fw fa-lg" aria-hidden="true"></i> Maintenance Windows</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-map'))); ?>"><i class="fa fa-link fa-fw fa-lg" aria-hidden="true"></i> Rule Mapping</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'templates'))); ?>"><i class="fa fa-sitemap fa-fw fa-lg" aria-hidden="true"></i> Templates</a></li>
<?php
}
?>
@ -544,13 +544,15 @@ if (is_file("includes/print-menubar-custom.inc.php")) {
$notifications = new ObjectCache('notifications');
$style = '';
if (empty($notifications['count']) && empty($notifications['sticky_count'])) {
$style = 'style="background-color:grey; color:white;"';
$class = 'badge-default';
} else {
$class = 'badge-danger';
}
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>');
echo('<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-user fa-fw fa-lg fa-nav-icons" aria-hidden="true"></i> <span class="visible-xs-inline-block">User</span><span class="badge badge-navbar-user '.$class.'">'.($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>
<li><a href="preferences/"><i class="fa fa-cog fa-fw fa-lg" aria-hidden="true"></i> My Settings</a></li>
<?php
$notifications = new ObjectCache('notifications');
echo ('<li><a href="notifications/"><span class="badge count-notif">'.($notifications['sticky_count']+$notifications['count']).'</span> Notifications</a></li>');
@ -560,18 +562,18 @@ if (empty($notifications['count']) && empty($notifications['sticky_count'])) {
if ($_SESSION['authenticated']) {
echo('
<li><a href="logout/"><i class="fa fa-sign-out fa-fw fa-lg"></i> Logout</a></li>');
<li><a href="logout/"><i class="fa fa-sign-out fa-fw fa-lg" aria-hidden="true"></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>
<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" aria-hidden="true"></i> <span class="visible-xs-inline-block">Settings</span></a>
<ul class="dropdown-menu">
<li role="presentation" class="dropdown-header"> Settings</li>
<?php
if ($_SESSION['userlevel'] >= '10') {
echo('<li><a href="settings/"><i class="fa fa-cogs fa-fw fa-lg"></i> Global Settings</a></li>');
echo('<li><a href="settings/"><i class="fa fa-cogs fa-fw fa-lg" aria-hidden="true"></i> Global Settings</a></li>');
}
?>
@ -581,24 +583,24 @@ if ($_SESSION['userlevel'] >= '10') {
<?php if ($_SESSION['userlevel'] >= '10') {
if (auth_usermanagement()) {
echo('
<li><a href="adduser/"><i class="fa fa-user-plus fa-fw fa-lg"></i> Add User</a></li>
<li><a href="deluser/"><i class="fa fa-user-times fa-fw fa-lg"></i> Remove User</a></li>
<li><a href="adduser/"><i class="fa fa-user-plus fa-fw fa-lg" aria-hidden="true"></i> Add User</a></li>
<li><a href="deluser/"><i class="fa fa-user-times fa-fw fa-lg" aria-hidden="true"></i> Remove User</a></li>
');
}
echo('
<li><a href="edituser/"><i class="fa fa-user-secret fa-fw fa-lg"></i> Edit User</a></li>
<li><a href="authlog/"><i class="fa fa-key fa-fw fa-lg"></i> Authlog</a></li>
<li><a href="edituser/"><i class="fa fa-user-secret fa-fw fa-lg" aria-hidden="true"></i> Edit User</a></li>
<li><a href="authlog/"><i class="fa fa-key fa-fw fa-lg" aria-hidden="true"></i> Authlog</a></li>
<li role="presentation" class="divider"></li> ');
echo('
<li class="dropdown-submenu">
<a href="#"><i class="fa fa-clock-o fa-fw fa-lg"></i> Pollers</a>
<a href="#"><i class="fa fa-clock-o fa-fw fa-lg" aria-hidden="true"></i> Pollers</a>
<ul class="dropdown-menu scrollable-menu">
<li><a href="poll-log/"><i class="fa fa-list-alt fa-fw fa-lg"></i> Poll-log</a></li>');
<li><a href="poll-log/"><i class="fa fa-list-alt fa-fw fa-lg" aria-hidden="true"></i> Poll-log</a></li>');
if ($config['distributed_poller'] === true) {
echo ('
<li><a href="pollers/tab=pollers/"><i class="fa fa-clock-o fa-fw fa-lg"></i> Pollers</a></li>
<li><a href="pollers/tab=groups/"><i class="fa fa-gears fa-fw fa-lg"></i> Groups</a></li>');
<li><a href="pollers/tab=pollers/"><i class="fa fa-clock-o fa-fw fa-lg" aria-hidden="true"></i> Pollers</a></li>
<li><a href="pollers/tab=groups/"><i class="fa fa-gears fa-fw fa-lg" aria-hidden="true"></i> Groups</a></li>');
}
echo ('
</ul>
@ -606,10 +608,10 @@ if ($_SESSION['userlevel'] >= '10') {
<li role="presentation" class="divider"></li>');
echo('
<li class="dropdown-submenu">
<a href="#"><i class="fa fa-code fa-fw fa-lg"></i> API</a>
<a href="#"><i class="fa fa-code fa-fw fa-lg" aria-hidden="true"></i> API</a>
<ul class="dropdown-menu scrollable-menu">
<li><a href="api-access/"><i class="fa fa-wrench fa-fw fa-lg"></i> API Settings</a></li>
<li><a href="http://docs.librenms.org/API/API-Docs/" target="_blank"><i class="fa fa-book fa-fw fa-lg"></i> API Docs</a></li>
<li><a href="api-access/"><i class="fa fa-wrench fa-fw fa-lg" aria-hidden="true"></i> API Settings</a></li>
<li><a href="http://docs.librenms.org/API/API-Docs/" target="_blank"><i class="fa fa-book fa-fw fa-lg" aria-hidden="true"></i> API Docs</a></li>
</ul>
</li>
<li role="presentation" class="divider"></li>');
@ -627,7 +629,7 @@ if ($_SESSION['authenticated']) {
?>
<li role="presentation" class="divider"></li>
<li><a href="about/"><i class="fa fa-exclamation-circle fa-fw fa-lg"></i> About&nbsp;<?php echo($config['project_name']); ?></a></li>
<li><a href="about/"><i class="fa fa-exclamation-circle fa-fw fa-lg" aria-hidden="true"></i> About&nbsp;<?php echo($config['project_name']); ?></a></li>
</ul>
</li>
</ul>

View File

@ -52,33 +52,33 @@ foreach (dbFetchRows($sql, $param) as $alertlog) {
$fault_detail = alert_details($alertlog['details']);
$alert_state = $alertlog['state'];
if ($alert_state == '0') {
$glyph_icon = 'ok';
$glyph_color = 'green';
$text = 'Ok';
$fa_icon = 'check';
$fa_color = 'success';
$text = 'Ok';
} elseif ($alert_state == '1') {
$glyph_icon = 'remove';
$glyph_color = 'red';
$text = 'Alert';
$fa_icon = 'times';
$fa_color = 'danger';
$text = 'Alert';
} elseif ($alert_state == '2') {
$glyph_icon = 'info-sign';
$glyph_color = 'lightgrey';
$text = 'Ack';
$fa_icon = 'info-circle';
$fa_color = 'muted';
$text = 'Ack';
} elseif ($alert_state == '3') {
$glyph_icon = 'arrow-down';
$glyph_color = 'orange';
$text = 'Worse';
$fa_icon = 'arrow-down';
$fa_color = 'warning';
$text = 'Worse';
} elseif ($alert_state == '4') {
$glyph_icon = 'arrow-up';
$glyph_color = 'khaki';
$text = 'Better';
$fa_icon = 'arrow-up';
$fa_color = 'info';
$text = 'Better';
}//end if
$response[] = array(
'id' => $rulei++,
'time_logged' => $alertlog['humandate'],
'details' => '<a class="glyphicon glyphicon-plus incident-toggle" style="display:none" data-toggle="collapse" data-target="#incident'.($rulei).'" data-parent="#alerts"></a>',
'details' => '<a class="fa fa-plus incident-toggle" style="display:none" data-toggle="collapse" data-target="#incident'.($rulei).'" data-parent="#alerts"></a>',
'hostname' => '<div class="incident">'.generate_device_link($dev, shorthost($dev['hostname'])).'<div id="incident'.($rulei).'" class="collapse">'.$fault_detail.'</div></div>',
'alert' => htmlspecialchars($alertlog['alert']),
'status' => "<b><span class='glyphicon glyphicon-".$glyph_icon."' style='color:".$glyph_color."'></span> $text</b>",
'status' => "<b><i class='fa fa-".$fa_icon." text-".$fa_color."'></i> $text</b>",
);
}//end foreach

View File

@ -101,12 +101,12 @@ foreach (dbFetchRows($sql, $param) as $alert) {
$log = dbFetchCell('SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1', array($alert['rule_id'], $alert['device_id']));
$fault_detail = alert_details($log);
$ico = 'ok';
$ico = 'check';
$col = 'green';
$extra = '';
$msg = '';
if ((int) $alert['state'] === 0) {
$ico = 'ok';
$ico = 'check';
$col = 'green';
$extra = 'success';
$msg = 'ok';
@ -154,7 +154,7 @@ foreach (dbFetchRows($sql, $param) as $alert) {
$response[] = array(
'id' => $rulei++,
'rule' => '<i title="'.htmlentities($alert['rule']).'"><a href="'.generate_url(array('page'=>'alert-rules')).'">'.htmlentities($alert['name']).'</a></i>',
'details' => '<a class="glyphicon glyphicon-plus incident-toggle" style="display:none" data-toggle="collapse" data-target="#incident'.($rulei).'" data-parent="#alerts"></a>',
'details' => '<a class="fa fa-plus incident-toggle" style="display:none" data-toggle="collapse" data-target="#incident'.($rulei).'" data-parent="#alerts"></a>',
'hostname' => $hostname,
'timestamp' => ($alert['timestamp'] ? $alert['timestamp'] : 'N/A'),
'severity' => $severity,

View File

@ -70,8 +70,8 @@ foreach (dbFetchRows($sql, $param) as $port) {
'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>',
'ifSpeed' => '<div class="form-group has-feedback"><input type="text" pattern="[0-9]*" inputmode="numeric" class="form-control input-sm" id="if-speed" name="if-speed" data-device_id="'.$port['device_id'].'" data-port_id="'.$port['port_id'].'" data-ifName="'.$port['ifName'].'" value="'.$port['ifSpeed'].'"><span class="glyphicon form-control-feedback" aria-hidden="true"></span></div>',
'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="form-control-feedback"><i class="fa" aria-hidden="true"></i></span></div>',
'ifSpeed' => '<div class="form-group has-feedback"><input type="text" pattern="[0-9]*" inputmode="numeric" class="form-control input-sm" id="if-speed" name="if-speed" data-device_id="'.$port['device_id'].'" data-port_id="'.$port['port_id'].'" data-ifName="'.$port['ifName'].'" value="'.$port['ifSpeed'].'"><span class="form-control-feedback"><i class="fa" aria-hidden="true"></i></span></div>',
);
}//end foreach

View File

@ -213,11 +213,11 @@ $(document).on("click", '.collapse-neighbors', function(event)
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');
if(button.hasClass("fa-plus")) {
button.addClass('fa-minus').removeClass('fa-plus');
}
else {
button.addClass('glyphicon-plus').removeClass('glyphicon-minus');
button.addClass('fa-plus').removeClass('fa-minus');
}
list.toggle();

View File

@ -99,7 +99,7 @@ foreach (get_all_devices() as $hostname) {
}).on("click", function(e) {
var target = $(this).data("target");
$(target).collapse('toggle');
$(this).toggleClass('glyphicon-plus glyphicon-minus');
$(this).toggleClass('fa-plus fa-minus');
});
grid.find(".incident").each( function() {
$(this).parent().addClass('col-lg-4 col-md-4 col-sm-4 col-xs-4');
@ -109,8 +109,8 @@ foreach (get_all_devices() as $hostname) {
$(this).find(".incident-toggle").fadeOut(200);
}).on("click", "td:not(.incident-toggle-td)", function() {
var target = $(this).parent().find(".incident-toggle").data("target");
if( $(this).parent().find(".incident-toggle").hasClass('glyphicon-plus') ) {
$(this).parent().find(".incident-toggle").toggleClass('glyphicon-plus glyphicon-minus');
if( $(this).parent().find(".incident-toggle").hasClass('fa-plus') ) {
$(this).parent().find(".incident-toggle").toggleClass('fa-plus fa-minus');
$(target).collapse('toggle');
}
});

View File

@ -21,8 +21,8 @@ foreach (dbFetchRows('SELECT alert_map.target,alert_map.id,alert_rules.name FROM
echo '<td>'.$link['name'].'</td>';
echo '<td>'.$link['target'].'</td>';
echo '<td>';
echo "<button type='button' class='btn btn-primary btn-sm' aria-label='Edit' data-toggle='modal' data-target='#create-map' data-map_id='".$link['id']."' name='edit-alert-map'><span class='glyphicon glyphicon-pencil' aria-hidden='true'></span></button> ";
echo "<button type='button' class='btn btn-danger btn-sm' aria-label='Delete' data-toggle='modal' data-target='#confirm-delete' data-map_id='".$link['id']."' name='delete-alert-map'><span class='glyphicon glyphicon-trash' aria-hidden='true'></span></button>";
echo "<button type='button' class='btn btn-primary btn-sm' aria-label='Edit' data-toggle='modal' data-target='#create-map' data-map_id='".$link['id']."' name='edit-alert-map'><i class='fa fa-pencil' aria-hidden='true'></i></button> ";
echo "<button type='button' class='btn btn-danger btn-sm' aria-label='Delete' data-toggle='modal' data-target='#confirm-delete' data-map_id='".$link['id']."' name='delete-alert-map'><span class='fa fa-trash' aria-hidden='true'></i></button>";
echo '</td>';
echo '</tr>';
}

View File

@ -112,6 +112,14 @@ $graphs['ups-nut'] = array(
'voltage_input',
);
$graphs['ups-apcups'] = array(
'remaining',
'load',
'voltage_battery',
'charge',
'voltage_input',
);
print_optionbar_start();
echo "<span style='font-weight: bold;'>Apps</span> &#187; ";

View File

@ -14,10 +14,14 @@ if (!empty($group_count_check)) {
echo '<tr id="row_'.$group['id'].'">';
echo '<td>'.$group['name'].'</td>';
echo '<td>'.$group['desc'].'</td>';
echo '<td>'.$group['pattern'].'</td>';
echo '<td>'.formatDeviceGroupPattern($group['pattern'], json_decode($group['params'])).'</td>';
echo '<td>';
echo "<button type='button' class='btn btn-primary btn-sm' aria-label='Edit' data-toggle='modal' data-target='#create-group' data-group_id='".$group['id']."' name='edit-device-group'><span class='glyphicon glyphicon-pencil' aria-hidden='true'></span></button> ";
echo "<button type='button' class='btn btn-danger btn-sm' aria-label='Delete' data-toggle='modal' data-target='#confirm-delete' data-group_id='".$group['id']."' name='delete-device-group'><span class='glyphicon glyphicon-trash' aria-hidden='true'></span></button>";
echo "<button type='button' class='btn btn-primary btn-sm' aria-label='Edit' data-toggle='modal' data-target='#create-group' data-group_id='".$group['id']."' name='edit-device-group'";
if (is_null($group['params'])) {
echo " disabled title='LibreNMS V2 device groups cannot be edited in LibreNMS V1'";
}
echo "><i class='fa fa-pencil' aria-hidden='true'></i></button> ";
echo "<button type='button' class='btn btn-danger btn-sm' aria-label='Delete' data-toggle='modal' data-target='#confirm-delete' data-group_id='".$group['id']."' name='delete-device-group'><i class='fa fa-trash' aria-hidden='true'></i></button>";
echo '</td>';
echo '</tr>';
}

View File

@ -0,0 +1,47 @@
<?php
/*
* 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/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 crcro
* @author Cercel Valentin <crc@nuamchefazi.ro>
*/
global $config;
$graphs = array(
'ups-apcups_remaining' => 'Remaining time:',
'ups-apcups_load' => 'Load:',
'ups-apcups_voltage_battery' => 'Battery voltage:',
'ups-apcups_charge' => 'Charge:',
'ups-apcups_voltage_input' => 'Input voltage:',
);
foreach ($graphs as $key => $text) {
$graph_type = $key;
$graph_array['height'] = '100';
$graph_array['width'] = '215';
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = 'application_'.$key;
echo '<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">'.$text.'</h3>
</div>
<div class="panel-body">
<div class="row">';
include 'includes/print-graphrow.inc.php';
echo '</div>';
echo '</div>';
echo '</div>';
}

View File

@ -17,21 +17,17 @@
* @link http://librenms.org
* @copyright 2016 crcro
* @author Cercel Valentin <crc@nuamchefazi.ro>
*
*/
global $config;
//NET-SNMP-EXTEND-MIB::nsExtendOutLine.\"ups-nut\"
$ups_model = snmp_get($device, '.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.5', '-Oqv');
$ups_serial = snmp_get($device, '.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.6', '-Oqv');
$ups_details = $ups_model.' (SN:'.$ups_serial.')';
$graphs = array(
'ups-nut_remaining' => 'Remaining time: '.$ups_details,
'ups-nut_load' => 'Load: '.$ups_details,
'ups-nut_voltage_battery' => 'Battery voltage: '.$ups_details,
'ups-nut_charge' => 'Charge: '.$ups_details,
'ups-nut_voltage_input' => 'Input voltage: '.$ups_details,
'ups-nut_remaining' => 'Remaining time: ',
'ups-nut_load' => 'Load: ',
'ups-nut_voltage_battery' => 'Battery voltage: ',
'ups-nut_charge' => 'Charge: ',
'ups-nut_voltage_input' => 'Input voltage: ',
);
foreach ($graphs as $key => $text) {

View File

@ -36,13 +36,15 @@ if (!is_admin()) {
<li role="presentation" class="active"><a data-toggle="tab" href="#discovery">Discovery</a></li>
<li role="presentation"><a data-toggle="tab" href="#poller">Poller</a></li>
<li role="presentation"><a data-toggle="tab" href="#snmp">SNMP</a></li>
<li role="presentation"><a data-toggle="tab" href="#alerts">Alerts</a></li>
</ul>
<div class="tab-content">
<?php
$tabs = array(
'discovery' => 'ajax_output.php?id=capture&format=text&type=discovery&hostname='.$device['hostname'],
'poller' => 'ajax_output.php?id=capture&format=text&type=poller&hostname='.$device['hostname'],
'snmp' => 'ajax_output.php?id=capture&format=text&type=snmpwalk&hostname='.$device['hostname'],
'poller' => 'ajax_output.php?id=capture&format=text&type=poller&hostname='.$device['hostname'],
'snmp' => 'ajax_output.php?id=capture&format=text&type=snmpwalk&hostname='.$device['hostname'],
'alerts' => 'ajax_output.php?id=query&format=text&type=alerts&hostname='.$device['hostname'],
);
foreach ($tabs as $tab => $url) {

View File

@ -58,13 +58,17 @@ foreach (dbFetchRows("SELECT * FROM sensors WHERE device_id = ? AND sensor_delet
<td>
<div class="form-group has-feedback">
<input type="text" class="form-control input-sm sensor" id="high-'.$sensor['device_id'].'" data-device_id="'.$sensor['device_id'].'" data-value_type="sensor_limit" data-sensor_id="'.$sensor['sensor_id'].'" value="'.$sensor['sensor_limit'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</td>
<td>
<div class="form-group has-feedback">
<input type="text" class="form-control input-sm sensor" id="low-'.$sensor['device_id'].'" data-device_id="'.$sensor['device_id'].'" data-value_type="sensor_limit_low" data-sensor_id="'.$sensor['sensor_id'].'" value="'.$sensor['sensor_limit_low'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</td>
<td>
@ -128,18 +132,18 @@ $( ".sensor" ).blur(function() {
dataType: "html",
success: function(data){
$this.closest('.form-group').addClass('has-success');
$this.next().addClass('glyphicon-ok');
$this.next().addClass('fa-check');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-success');
$this.next().removeClass('glyphicon-ok');
$this.next().removeClass('fa-check');
}, 2000);
},
error:function(){
$(this).closest('.form-group').addClass('has-error');
$this.next().addClass('glyphicon-remove');
$this.next().addClass('fa-times');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-error');
$this.next().removeClass('glyphicon-remove');
$this.next().removeClass('fa-times');
}, 2000);
}
});

View File

@ -41,28 +41,28 @@
success: function (data) {
if (data.status == 'ok') {
$this.closest('.form-group').addClass('has-success');
$this.next().addClass('glyphicon-ok');
$this.next().addClass('fa-check');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-success');
$this.next().removeClass('glyphicon-ok');
$this.next().removeClass('fa-check');
}, 2000);
} else if (data.status == 'na') {
} else {
$(this).closest('.form-group').addClass('has-error');
$this.next().addClass('glyphicon-remove');
$this.next().addClass('fa-times');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-error');
$this.next().removeClass('glyphicon-remove');
$this.next().removeClass('fa-times');
}, 2000);
}
},
error: function () {
$(this).closest('.form-group').addClass('has-error');
$this.next().addClass('glyphicon-remove');
$this.next().addClass('fa-times');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-error');
$this.next().removeClass('glyphicon-remove');
$this.next().removeClass('fa-times');
}, 2000);
}
});
@ -82,29 +82,29 @@
success: function (data) {
if (data.status == 'ok') {
$this.closest('.form-group').addClass('has-success');
$this.next().addClass('glyphicon-ok');
$this.next().addClass('fa-check');
$this.val(speed);
setTimeout(function(){
$this.closest('.form-group').removeClass('has-success');
$this.next().removeClass('glyphicon-ok');
$this.next().removeClass('fa-check');
}, 2000);
} else if (data.status == 'na') {
} else {
$(this).closest('.form-group').addClass('has-error');
$this.next().addClass('glyphicon-remove');
$this.next().addClass('fa-times');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-error');
$this.next().removeClass('glyphicon-remove');
$this.next().removeClass('fa-times');
}, 2000);
}
},
error: function () {
$(this).closest('.form-group').addClass('has-error');
$this.next().addClass('glyphicon-remove');
$this.next().addClass('fa-times');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-error');
$this.next().removeClass('glyphicon-remove');
$this.next().removeClass('fa-times');
}, 2000);
}
});

View File

@ -100,7 +100,7 @@ $type_text['processor'] = 'Processor';
$type_text['voltage'] = 'Voltage';
$type_text['fanspeed'] = 'Fanspeed';
$type_text['frequency'] = 'Frequency';
$type_text['runtime'] = 'Runtime';
$type_text['runtime'] = 'Runtime remaining';
$type_text['current'] = 'Current';
$type_text['power'] = 'Power';
$type_text['dbm'] = 'dBm';

View File

@ -51,8 +51,38 @@ if (empty($vars['dtpickerto'])) {
<hr />
<script type="text/javascript">
$(function () {
$("#dtpickerfrom").datetimepicker({useCurrent: true, sideBySide: true, useStrict: false});
$("#dtpickerto").datetimepicker({useCurrent: true, sideBySide: true, useStrict: false});
$("#dtpickerfrom").datetimepicker({
useCurrent: true,
sideBySide: true,
useStrict: false,
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-calendar-check-o',
clear: 'fa fa-trash-o',
close: 'fa fa-close'
}
});
$("#dtpickerto").datetimepicker({
useCurrent: true,
sideBySide: true,
useStrict: false,
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-calendar-check-o',
clear: 'fa fa-trash-o',
close: 'fa fa-close'
}
});
});
</script>

View File

@ -72,7 +72,7 @@ foreach ($heads as $head => $extra) {
$bhead = 'asc';
$icon = '';
if ('`'.$lhead.'`' == $order) {
$icon = " class='glyphicon glyphicon-chevron-";
$icon = " class='fa fa-chevron-";
if ($by == 'asc') {
$bhead = 'desc';
$icon .= 'up';

View File

@ -11,7 +11,7 @@ global $config;
?>
<div class="panel panel-default" id="overlays">
<div class="panel-heading">
<h3 class="panel-title">Overlay's & Adjacencies</h3>
<h3 class="panel-title">Overlay's &amp; Adjacencies</h3>
</div>
<div class="panel list-group">
<?php
@ -39,7 +39,7 @@ foreach ($components as $aid => $adjacency) {
$gli = "list-group-item-danger";
}
?>
<a class="list-group-item <?php echo $gli?> small"><span class="glyphicon glyphicon-chevron-right"></span> <?php echo $adjacency['label']?> - <?php echo $adjacency['endpoint']?> <?php echo $adj_status?></a>
<a class="list-group-item <?php echo $gli?> small"><i class="fa fa-chevron-right" aria-hidden="true"></i> <?php echo $adjacency['label']?> - <?php echo $adjacency['endpoint']?> <?php echo $adj_status?></a>
<?php
}
}

View File

@ -68,8 +68,8 @@ foreach ($services as $service) {
<div class="col-sm-6"><?php echo $service['service_desc']?></div>
<div class="col-sm-2"><?php echo $status?></div>
<div class="pull-right">
<button type='button' class='btn btn-primary btn-sm' aria-label='Edit' data-toggle='modal' data-target='#create-service' data-service_id='<?php echo $service['service_id']?>' name='edit-service'><span class='glyphicon glyphicon-pencil' aria-hidden='true'></span></button>
<button type='button' class='btn btn-danger btn-sm' aria-label='Delete' data-toggle='modal' data-target='#confirm-delete' data-service_id='<?php echo $service['service_id']?>' name='delete-service'><span class='glyphicon glyphicon-trash' aria-hidden='true'></span></button>
<button type='button' class='btn btn-primary btn-sm' aria-label='Edit' data-toggle='modal' data-target='#create-service' data-service_id='<?php echo $service['service_id']?>' name='edit-service'><i class='fa fa-pencil' aria-hidden='true'></i></button>
<button type='button' class='btn btn-danger btn-sm' aria-label='Delete' data-toggle='modal' data-target='#confirm-delete' data-service_id='<?php echo $service['service_id']?>' name='delete-service'><i class='fa fa-trash' aria-hidden='true'></i></button>
</div>
</div>
<div class="col-sm-12">

View File

@ -29,7 +29,7 @@
return "<h4><span class='label label-"+row.extra+" threeqtr-width'>" + row.msg + "</span></h4>";
},
"ack": function(column,row) {
return "<button type='button' class='btn btn-"+row.ack_col+" btn-sm command-ack-alert' data-target='#ack-alert' data-state='"+row.state+"' data-alert_id='"+row.alert_id+"' name='ack-alert' id='ack-alert' data-extra='"+row.extra+"'><span class='glyphicon glyphicon-"+row.ack_ico+"'aria-hidden='true'></span></button>";
return "<button type='button' class='btn btn-"+row.ack_col+" btn-sm command-ack-alert' data-target='#ack-alert' data-state='"+row.state+"' data-alert_id='"+row.alert_id+"' name='ack-alert' id='ack-alert' data-extra='"+row.extra+"'><i class='fa fa-"+row.ack_ico+"'aria-hidden='true'></i></button>";
}
},
templates: {

View File

@ -28,7 +28,7 @@
return "<h4><span class='label label-"+row.extra+" threeqtr-width'>" + row.msg + "</span></h4>";
},
"ack": function(column,row) {
return "<button type='button' class='btn btn-"+row.ack_col+" btn-sm command-ack-alert' data-target='#ack-alert' data-state='"+row.state+"' data-alert_id='"+row.alert_id+"' name='ack-alert' id='ack-alert' data-extra='"+row.extra+"'><span class='glyphicon glyphicon-"+row.ack_ico+"'aria-hidden='true'></span></button>";
return "<button type='button' class='btn btn-"+row.ack_col+" btn-sm command-ack-alert' data-target='#ack-alert' data-state='"+row.state+"' data-alert_id='"+row.alert_id+"' name='ack-alert' id='ack-alert' data-extra='"+row.extra+"'><i class='fa fa-"+row.ack_ico+"'aria-hidden='true'></i></button>";
}
},
templates: {

View File

@ -29,7 +29,7 @@
return "<h4><span class='label label-"+row.extra+" threeqtr-width'>" + row.msg + "</span></h4>";
},
"ack": function(column,row) {
return "<button type='button' class='btn btn-"+row.ack_col+" btn-sm command-ack-alert' data-target='#ack-alert' data-state='"+row.state+"' data-alert_id='"+row.alert_id+"' name='ack-alert' id='ack-alert' data-extra='"+row.extra+"'><span class='glyphicon glyphicon-"+row.ack_ico+"'aria-hidden='true'></span></button>";
return "<button type='button' class='btn btn-"+row.ack_col+" btn-sm command-ack-alert' data-target='#ack-alert' data-state='"+row.state+"' data-alert_id='"+row.alert_id+"' name='ack-alert' id='ack-alert' data-extra='"+row.extra+"'><i class='fa fa-"+row.ack_ico+"'aria-hidden='true'></i></button>";
}
},
templates: {

View File

@ -39,7 +39,7 @@ foreach ($COMPONENTS as $DEVICE_ID => $COMP) {
$GLI = "list-group-item-danger";
}
?>
<a class="list-group-item <?php echo $GLI?> small"><span class="glyphicon glyphicon-chevron-right"></span> <?php echo $ADJACENCY['label']?> - <?php echo $ADJACENCY['endpoint']?> <?php echo $ADJ_STATUS?></a>
<a class="list-group-item <?php echo $GLI?> small"><i class="fa fa-chevron-right" aria-hidden="true"></i> <?php echo $ADJACENCY['label']?> - <?php echo $ADJACENCY['endpoint']?> <?php echo $ADJ_STATUS?></a>
<?php
}
}

View File

@ -134,8 +134,8 @@ foreach (dbFetchRows($host_sql, $host_par) as $device) {
<td><span class='box-desc'><?php echo nl2br(trim($service['service_message']))?></span></td>
<td><span class='box-desc'><?php echo nl2br(trim($service['service_desc']))?></span></td>
<td>
<button type='button' class='btn btn-primary btn-sm' aria-label='Edit' data-toggle='modal' data-target='#create-service' data-service_id='<?php echo $service['service_id']?>' name='edit-service'><span class='glyphicon glyphicon-pencil' aria-hidden='true'></span></button>
<button type='button' class='btn btn-danger btn-sm' aria-label='Delete' data-toggle='modal' data-target='#confirm-delete' data-service_id='<?php echo $service['service_id']?>' name='delete-service'><span class='glyphicon glyphicon-trash' aria-hidden='true'></span></button>
<button type='button' class='btn btn-primary btn-sm' aria-label='Edit' data-toggle='modal' data-target='#create-service' data-service_id='<?php echo $service['service_id']?>' name='edit-service'><i class='fa fa-pencil' aria-hidden='true'></i></button>
<button type='button' class='btn btn-danger btn-sm' aria-label='Delete' data-toggle='modal' data-target='#confirm-delete' data-service_id='<?php echo $service['service_id']?>' name='delete-service'><i class='fa fa-trash' aria-hidden='true'></i></button>
</td>
</tr>
<?php

View File

@ -316,7 +316,9 @@ foreach ($api_urls as $api_url) {
<label for="api_url" class="col-sm-4 control-label">API URL ('.$api_method.') </label>
<div class="col-sm-4">
<input id="api_url" class="form-control" type="text" name="global-config-input" value="'.$api_url['config_value'].'" data-config_id="'.$api_url['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-api-config" name="del-api-call" data-config_id="'.$api_url['config_id'].'"><i class="fa fa-minus"></i></button>
@ -328,7 +330,9 @@ foreach ($api_urls as $api_url) {
<label for="api_url" class="col-sm-4 control-label api-method">API URL </label>
<div class="col-sm-4">
<input id="api_url" class="form-control" type="text" name="global-config-input" value="" data-config_id="">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-api-config" name="del-api-call" data-config_id=""><i class="fa fa-minus"></i></button>
@ -371,10 +375,12 @@ if (empty($config_groups['alert.transports.pagerduty']['config_value']) === fals
<div class="panel-body">
<div class="form-group has-feedback">
<label for="nagios" class="col-sm-4 control-label">Nagios compatible FIFO </label>
<div data-toggle="tooltip" title="'.$config_groups['alert.transports.nagios']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div data-toggle="tooltip" title="'.$config_groups['alert.transports.nagios']['config_descr'].'" class="toolTip fa fa-question-sign"></div>
<div class="col-sm-4">
<input id="nagios" class="form-control" type="text" name="global-config-input" value="'.$config_groups['alert.transports.nagios']['config_value'].'" data-config_id="'.$config_groups['alert.transports.nagios']['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
</div>
@ -390,7 +396,7 @@ if (empty($config_groups['alert.transports.pagerduty']['config_value']) === fals
<div class="panel-body">
<div class="form-group">
<label for="irc" class="col-sm-4 control-label">Enable irc transport </label>
<div data-toggle="tooltip" title="'.$config_groups['alert.transports.irc']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div data-toggle="tooltip" title="'.$config_groups['alert.transports.irc']['config_descr'].'" class="toolTip fa fa-question-circle"></div>
<div class="col-sm-4">
<input id="irc" type="checkbox" name="global-config-check" '.$config_groups['alert.transports.irc']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['alert.transports.irc']['config_id'].'">
</div>
@ -429,7 +435,9 @@ foreach ($slack_urls as $slack_url) {
<label for="slack_url" class="col-sm-4 control-label">Slack URL </label>
<div class="col-sm-4">
<input id="slack_url" class="form-control" type="text" name="global-config-input" value="'.$slack_url['config_value'].'" data-config_id="'.$slack_url['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-slack-config" name="del-slack-call" data-config_id="'.$slack_url['config_id'].'"><i class="fa fa-minus"></i></button>
@ -438,7 +446,9 @@ foreach ($slack_urls as $slack_url) {
<div class="form-group has-feedback">
<div class="col-sm-offset-4 col-sm-4">
<textarea class="form-control" name="global-config-textarea" id="upd_slack_extra" placeholder="Enter the config options" data-config_id="'.$slack_url['config_id'].'" data-type="slack">'.$upd_slack_extra.'</textarea>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
</div>';
@ -449,7 +459,9 @@ foreach ($slack_urls as $slack_url) {
<label for="slack_url" class="col-sm-4 control-label api-method">Slack URL </label>
<div class="col-sm-4">
<input id="slack_url" class="form-control" type="text" name="global-config-input" value="" data-config_id="">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-slack-config" name="del-slack-call" data-config_id=""><i class="fa fa-minus"></i></button>
@ -497,7 +509,9 @@ foreach ($hipchat_urls as $hipchat_url) {
<label for="hipchat_url" class="col-sm-4 control-label">Hipchat URL </label>
<div class="col-sm-4">
<input id="hipchat_url" class="form-control" type="text" name="global-config-input" value="'.$hipchat_url['config_value'].'" data-config_id="'.$hipchat_url['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-hipchat-config" name="del-hipchat-call" data-config_id="'.$hipchat_url['config_id'].'"><i class="fa fa-minus"></i></button>
@ -507,20 +521,26 @@ foreach ($hipchat_urls as $hipchat_url) {
<label for="hipchat_room_id" class="col-sm-4 control-label">Room ID</label>
<div class="col-sm-4">
<input id="hipchat_room_id" class="form-control" type="text" name="global-config-input" value="'.$hipchat_room_id['config_value'].'" data-config_id="'.$hipchat_room_id['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<label for="hipchat_from" class="col-sm-4 control-label">From</label>
<div class="col-sm-4">
<input id="hipchat_from" class="form-control" type="text" name="global-config-input" value="'.$hipchat_from['config_value'].'" data-config_id="'.$hipchat_from['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-sm-offset-4 col-sm-4">
<textarea class="form-control" name="global-config-textarea" id="upd_hipchat_extra" placeholder="Enter the config options" data-config_id="'.$hipchat_url['config_id'].'" data-type="hipchat">'.$upd_hipchat_extra.'</textarea>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
</div>';
@ -531,7 +551,9 @@ foreach ($hipchat_urls as $hipchat_url) {
<label for="hipchat_url" class="col-sm-4 control-label api-method">Hipchat URL </label>
<div class="col-sm-4">
<input id="hipchat_url" class="form-control" type="text" name="global-config-input" value="" data-config_id="">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-hipchat-config" id="del-hipchat-call" name="del-hipchat-call" data-config_id=""><i class="fa fa-minus"></i></button>
@ -541,14 +563,18 @@ foreach ($hipchat_urls as $hipchat_url) {
<label for="hipchat_room_id" class="col-sm-4 control-label">Room ID</label>
<div class="col-sm-4">
<input id="global-config-room_id" class="form-control" type="text" name="global-config-input" value="" data-config_id="">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<label for="hipchat_from" class="col-sm-4 control-label">From</label>
<div class="col-sm-4">
<input id="global-config-from" class="form-control" type="text" name="global-config-input" value="" data-config_id="">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
@ -592,7 +618,9 @@ foreach ($pushover_appkeys as $pushover_appkey) {
<label for="pushover_appkey" class="col-sm-4 control-label">Pushover Appkey </label>
<div class="col-sm-4">
<input id="pushover_appkey" class="form-control" type="text" name="global-config-input" value="'.$pushover_appkey['config_value'].'" data-config_id="'.$pushover_appkey['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-pushover-config" name="del-pushover-call" data-config_id="'.$pushover_appkey['config_id'].'"><i class="fa fa-minus"></i></button>
@ -602,13 +630,17 @@ foreach ($pushover_appkeys as $pushover_appkey) {
<label for="pushover_userkey" class="col-sm-4 control-label">Userkey</label>
<div class="col-sm-4">
<input id="pushover_userkey" class="form-control" type="text" name="global-config-input" value="'.$pushover_userkey['config_value'].'" data-config_id="'.$pushover_userkey['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-sm-offset-4 col-sm-4">
<textarea class="form-control" name="global-config-textarea" id="upd_pushover_extra" placeholder="Enter the config options" data-config_id="'.$pushover_appkey['config_id'].'" data-type="pushover">'.$upd_pushover_extra.'</textarea>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
</div>';
@ -619,7 +651,9 @@ echo '<div id="pushover_appkey_template" class="hide">
<label for="pushover_appkey" class="col-sm-4 control-label api-method">Pushover Appkey </label>
<div class="col-sm-4">
<input id="pushover_appkey" class="form-control" type="text" name="global-config-input" value="" data-config_id="">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-pushover-config" id="del-pushover-call" name="del-pushover-call" data-config_id=""><i class="fa fa-minus"></i></button>
@ -629,7 +663,9 @@ echo '<div id="pushover_appkey_template" class="hide">
<label for="pushover_userkey" class="col-sm-4 control-label">Userkey</label>
<div class="col-sm-4">
<input id="global-config-userkey" class="form-control" type="text" name="global-config-input" value="" data-config_id="">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
@ -672,7 +708,9 @@ foreach ($boxcar_appkeys as $boxcar_appkey) {
<label for="boxcar_access_token" class="col-sm-4 control-label">Boxcar Access token </label>
<div class="col-sm-4">
<input id="boxcar_access_token" class="form-control" type="text" name="global-config-input" value="'.$boxcar_appkey['config_value'].'" data-config_id="'.$boxcar_appkey['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-boxcar-config" name="del-boxcar-call" data-config_id="'.$boxcar_appkey['config_id'].'"><i class="fa fa-minus"></i></button>
@ -681,7 +719,9 @@ foreach ($boxcar_appkeys as $boxcar_appkey) {
<div class="form-group has-feedback">
<div class="col-sm-offset-4 col-sm-4">
<textarea class="form-control" name="global-config-textarea" id="upd_boxcar_extra" placeholder="Enter the config options" data-config_id="'.$boxcar_appkey['config_id'].'" data-type="boxcar">'.$upd_boxcar_extra.'</textarea>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
</div>';
@ -692,7 +732,9 @@ echo '<div id="boxcar_appkey_template" class="hide">
<label for="boxcar_access_token" class="col-sm-4 control-label api-method">Boxcar Access token </label>
<div class="col-sm-4">
<input id="boxcar_access_token" class="form-control" type="text" name="global-config-input" value="" data-config_id="">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-danger del-boxcar-config" id="del-boxcar-call" name="del-boxcar-call" data-config_id=""><i class="fa fa-minus"></i></button>
@ -717,10 +759,12 @@ echo '<div id="boxcar_appkey_template" class="hide">
<div class="panel-body">
<div class="form-group has-feedback">
<label for="pushbullet" class="col-sm-4 control-label">Pushbullet Access Token </label>
<div data-toggle="tooltip" title="'.$config_groups['alert.transports.pushbullet']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div data-toggle="tooltip" title="'.$config_groups['alert.transports.pushbullet']['config_descr'].'" class="toolTip fa fa-question-circle"></div>
<div class="col-sm-4">
<input id="pushbullet" class="form-control" type="text" name="global-config-input" value="'.$config_groups['alert.transports.pushbullet']['config_value'].'" data-config_id="'.$config_groups['alert.transports.pushbullet']['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
</div>
@ -736,10 +780,12 @@ echo '<div id="boxcar_appkey_template" class="hide">
<div class="panel-body">
<div class="form-group has-feedback">
<label for="victorops" class="col-sm-4 control-label">Post URL </label>
<div data-toggle="tooltip" title="'.$config_groups['alert.transports.victorops.url']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<div data-toggle="tooltip" title="'.$config_groups['alert.transports.victorops.url']['config_descr'].'" class="toolTip fa fa-question-circle"></div>
<div class="col-sm-4">
<input id="victorops" class="form-control" type="text" name="global-config-input" value="'.$config_groups['alert.transports.victorops.url']['config_value'].'" data-config_id="'.$config_groups['alert.transports.victorops.url']['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
</div>
@ -767,14 +813,18 @@ echo '
<label for="clickatell_token" class="col-sm-4 control-label">Clickatell Token </label>
<div class="col-sm-4">
<input id="clickatell_token" class="form-control" type="text" name="global-config-input" value="'.$clickatell['config_value'].'" data-config_id="'.$clickatell['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<label for="clickatell_to" class="col-sm-4 control-label">Mobile numbers</label>
<div class="col-sm-4">
<textarea class="form-control" name="global-config-textarea" id="clickatell_to" placeholder="Enter the config options" data-config_id="'.$clickatell['config_id'].'" data-type="clickatell">'.$upd_mobiles.'</textarea>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
</div>
@ -803,35 +853,45 @@ echo '
<label for="playsms_url" class="col-sm-4 control-label">PlaySMS URL </label>
<div class="col-sm-4">
<input id="playsms_url" class="form-control" type="text" name="global-config-input" value="'.$playsms_url['config_value'].'" data-config_id="'.$playsms_url['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<label for="playsms_user" class="col-sm-4 control-label">User</label>
<div class="col-sm-4">
<input id="playsms_user" class="form-control" type="text" name="global-config-input" value="'.$playsms_user['config_value'].'" data-config_id="'.$playsms_user['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<label for="playsms_token" class="col-sm-4 control-label">Token</label>
<div class="col-sm-4">
<input id="playsms_token" class="form-control" type="text" name="global-config-input" value="'.$playsms_token['config_value'].'" data-config_id="'.$playsms_token['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<label for="playsms_from" class="col-sm-4 control-label">From</label>
<div class="col-sm-4">
<input id="playsms_from" class="form-control" type="text" name="global-config-input" value="'.$playsms_from['config_value'].'" data-config_id="'.$playsms_from['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<label for="clickatell_to" class="col-sm-4 control-label">Mobiles</label>
<div class="col-sm-4">
<textarea class="form-control" name="global-config-textarea" id="playsms_to" placeholder="Enter the config options" data-config_id="'.$playsms_url['config_id'].'" data-type="playsms">'.$upd_mobiles.'</textarea>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
</div>
@ -855,35 +915,45 @@ echo '
<label for="canopsis_host" class="col-sm-4 control-label">Canopsis Hostname </label>
<div class="col-sm-4">
<input id="canopsis_host" class="form-control" type="text" name="global-config-input" value="'.$canopsis_host['config_value'].'" data-config_id="'.$canopsis_host['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<label for="canopsis_port" class="col-sm-4 control-label">Canopsis Port number </label>
<div class="col-sm-4">
<input id="canopsis_port" class="form-control" type="text" name="global-config-input" value="'.$canopsis_port['config_value'].'" data-config_id="'.$canopsis_port['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<label for="canopsis_user" class="col-sm-4 control-label">User</label>
<div class="col-sm-4">
<input id="canopsis_user" class="form-control" type="text" name="global-config-input" value="'.$canopsis_user['config_value'].'" data-config_id="'.$canopsis_user['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<label for="canopsis_passwd" class="col-sm-4 control-label">Password</label>
<div class="col-sm-4">
<input id="canopsis_passwd" class="form-control" type="password" name="global-config-input" value="'.$canopsis_passwd['config_value'].'" data-config_id="'.$canopsis_passwd['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<label for="canopsis_vhost" class="col-sm-4 control-label">Vhost</label>
<div class="col-sm-4">
<input id="canopsis_vhost" class="form-control" type="text" name="global-config-input" value="'.$canopsis_vhost['config_value'].'" data-config_id="'.$canopsis_vhost['config_id'].'">
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
</div>
@ -1242,17 +1312,17 @@ echo '
success: function (data) {
if (data.status == 'ok') {
$this.closest('.form-group').addClass('has-success');
$this.next().addClass('glyphicon-ok');
$this.next().addClass('fa-check');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-success');
$this.next().removeClass('glyphicon-ok');
$this.next().removeClass('fa-check');
}, 2000);
} else {
$(this).closest('.form-group').addClass('has-error');
$this.next().addClass('glyphicon-remove');
$this.next().addClass('fa-times');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-error');
$this.next().removeClass('glyphicon-remove');
$this.next().removeClass('fa-times');
}, 2000);
}
},
@ -1275,17 +1345,17 @@ echo '
success: function (data) {
if (data.status == 'ok') {
$this.closest('.form-group').addClass('has-success');
$this.next().addClass('glyphicon-ok');
$this.next().addClass('fa-check');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-success');
$this.next().removeClass('glyphicon-ok');
$this.next().removeClass('fa-check');
}, 2000);
} else {
$(this).closest('.form-group').addClass('has-error');
$this.next().addClass('glyphicon-remove');
$this.next().addClass('fa-times');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-error');
$this.next().removeClass('glyphicon-remove');
$this.next().removeClass('fa-times');
}, 2000);
}
},

View File

@ -19,8 +19,8 @@ $graph_conf = array(
);
$availability_map_conf = array(
array('name' => 'webui.old_availability_map',
'descr' => 'Availability map old view',
array('name' => 'webui.availability_map_compact',
'descr' => 'Availability map compact view',
'type' => 'checkbox',
),
array('name' => 'webui.availability_map_sort_status',
@ -31,6 +31,10 @@ $availability_map_conf = array(
'descr' => 'Use device groups filter',
'type' => 'checkbox',
),
array('name' => 'webui.availability_map_box_size',
'descr' => 'Availability box width',
'type' => 'numeric',
),
);
$dashboard_conf = array(

View File

@ -87,11 +87,35 @@ print_optionbar_start();
<script>
$(function () {
$("#dtpickerfrom").datetimepicker();
$("#dtpickerfrom").datetimepicker({
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-calendar-check-o',
clear: 'fa fa-trash-o',
close: 'fa fa-close'
}
});
$("#dtpickerfrom").on("dp.change", function (e) {
$("#dtpickerto").data("DateTimePicker").minDate(e.date);
});
$("#dtpickerto").datetimepicker();
$("#dtpickerto").datetimepicker({
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-calendar-check-o',
clear: 'fa fa-trash-o',
close: 'fa fa-close'
}
});
$("#dtpickerto").on("dp.change", function (e) {
$("#dtpickerfrom").data("DateTimePicker").maxDate(e.date);
});

View File

@ -160,13 +160,14 @@ function RunRules($device)
return false;
}
foreach (GetRules($device) as $rule) {
echo " #".$rule['id'].":";
c_echo('Rule %p#'.$rule['id'].' (' . $rule['name'] . '):%n ');
$inv = json_decode($rule['extra'], true);
if (isset($inv['invert'])) {
$inv = (bool) $inv['invert'];
} else {
$inv = false;
}
d_echo(PHP_EOL);
$chk = dbFetchRow("SELECT state FROM alerts WHERE rule_id = ? && device_id = ? ORDER BY id DESC LIMIT 1", array($rule['id'], $device));
$sql = GenSQL($rule['rule']);
$qry = dbFetchRows($sql, array($device));
@ -185,30 +186,31 @@ function RunRules($device)
}
if ($doalert) {
if ($chk['state'] === "2") {
echo " SKIP ";
c_echo('Status: %ySKIP');
} elseif ($chk['state'] >= "1") {
echo " NOCHG ";
c_echo('Status: %bNOCHG');
} else {
$extra = gzcompress(json_encode(array('contacts' => GetContacts($qry), 'rule'=>$qry)), 9);
if (dbInsert(array('state' => 1, 'device_id' => $device, 'rule_id' => $rule['id'], 'details' => $extra), 'alert_log')) {
if (!dbUpdate(array('state' => 1, 'open' => 1), 'alerts', 'device_id = ? && rule_id = ?', array($device,$rule['id']))) {
dbInsert(array('state' => 1, 'device_id' => $device, 'rule_id' => $rule['id'], 'open' => 1,'alerted' => 0), 'alerts');
}
echo " ALERT ";
c_echo(PHP_EOL . 'Status: %rALERT');
}
}
} else {
if ($chk['state'] === "0") {
echo " NOCHG ";
c_echo('Status: %bNOCHG');
} else {
if (dbInsert(array('state' => 0, 'device_id' => $device, 'rule_id' => $rule['id']), 'alert_log')) {
if (!dbUpdate(array('state' => 0, 'open' => 1), 'alerts', 'device_id = ? && rule_id = ?', array($device,$rule['id']))) {
dbInsert(array('state' => 0, 'device_id' => $device, 'rule_id' => $rule['id'], 'open' => 1, 'alerted' => 0), 'alerts');
}
echo " OK ";
c_echo(PHP_EOL . 'Status: %gOK');
}
}
}
c_echo('%n' . PHP_EOL);
}
}

View File

@ -70,21 +70,23 @@ function format_number_short($number, $sf)
function external_exec($command)
{
global $debug,$vdebug;
if ($debug && !$vdebug) {
$debug_command = preg_replace('/-c [\S]+/', '-c COMMUNITY', $command);
$debug_command = preg_replace('/(udp|udp6|tcp|tcp6):(.*):([\d]+)/', '\1:HOSTNAME:\3', $debug_command);
d_echo($debug_command);
$debug_command = preg_replace('/(udp|udp6|tcp|tcp6):([^:]+):([\d]+)/', '\1:HOSTNAME:\3', $debug_command);
c_echo('SNMP[%c' . $debug_command . "%n]\n");
} elseif ($vdebug) {
d_echo($command."\n");
c_echo('SNMP[%c'.$command."%n]\n");
}
$output = shell_exec($command);
if ($debug && !$vdebug) {
$debug_output = preg_replace('/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/', '*', $output);
d_echo("$debug_output\n");
$ip_regex = '/(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/';
$debug_output = preg_replace($ip_regex, '*', $output);
d_echo($debug_output . PHP_EOL);
} elseif ($vdebug) {
d_echo($output."\n");
d_echo($output . PHP_EOL);
}
return $output;
@ -130,7 +132,7 @@ function print_message($text)
if (isCli()) {
c_echo("%g".$text."%n\n");
} else {
echo('<div class="alert alert-success"><i class="fa fa-fw fa-check-circle" aria-hidden="true"> '.$text.'</div>');
echo('<div class="alert alert-success"><i class="fa fa-fw fa-check-circle" aria-hidden="true"></i> '.$text.'</div>');
}
}
@ -1458,3 +1460,23 @@ function starts_with($haystack, $needles, $case_insensitive = false)
}
return false;
}
function get_auth_ad_user_filter($username)
{
global $config;
$user_filter = "(samaccountname=$username)";
if ($config['auth_ad_user_filter']) {
$user_filter = "(&{$config['auth_ad_user_filter']}$user_filter)";
}
return $user_filter;
}
function get_auth_ad_group_filter($groupname)
{
global $config;
$group_filter = "(samaccountname=$groupname)";
if ($config['auth_ad_group_filter']) {
$group_filter = "(&{$config['auth_ad_group_filter']}$group_filter)";
}
return $group_filter;
}

View File

@ -32,7 +32,7 @@ function dbQuery($sql, $parameters = array())
if (preg_match('/(INSERT INTO `alert_log`).*(details)/i', $fullSql)) {
echo "\nINSERT INTO `alert_log` entry masked due to binary data\n";
} else {
c_echo("\nSQL[%y".$fullSql.'%n] ');
c_echo('SQL[%y'.$fullSql."%n] \n");
}
} else {
$sql_debug[] = $fullSql;

View File

@ -32,7 +32,7 @@ function dbQuery($sql, $parameters = array())
if (preg_match('/(INSERT INTO `alert_log`).*(details)/i', $fullSql)) {
echo "\nINSERT INTO `alert_log` entry masked due to binary data\n";
} else {
c_echo("\nSQL[%y".$fullSql.'%n] ');
c_echo('SQL[%y'.$fullSql."%n] \n");
}
} else {
$sql_debug[] = $fullSql;

View File

@ -73,7 +73,8 @@ function EditDeviceGroup($group_id, $name = null, $desc = null, $pattern = null)
/**
* Generate SQL from Group-Pattern
* @param string $pattern Pattern to generate SQL for
* @param string $search What to searchid for
* @param string $search What to searchid for
* @param int $extra
* @return string sql to perform the search
*/
function GenGroupSQL($pattern, $search = '', $extra = 0)
@ -82,23 +83,29 @@ function GenGroupSQL($pattern, $search = '', $extra = 0)
if ($pattern === false) {
return false;
}
$tmp = explode(' ', $pattern);
$tables = array();
foreach ($tmp as $opt) {
if (strstr($opt, '%') && strstr($opt, '.')) {
$tmpp = explode('.', $opt, 2);
$tmpp[0] = str_replace('%', '', $tmpp[0]);
$tables[] = mres(str_replace('(', '', $tmpp[0]));
$pattern = str_replace($opt, $tmpp[0].'.'.$tmpp[1], $pattern);
if (starts_with($pattern, '%')) {
// v1 pattern
$tables = array();
$words = explode(' ', $pattern);
foreach ($words as $word) {
if (starts_with($word, '%') && str_contains($word, '.')) {
list($table, $column) = explode('.', $word, 2);
$table = str_replace('%', '', $table);
$tables[] = mres(str_replace('(', '', $table));
$pattern = str_replace($word, $table . '.' . $column, $pattern);
}
}
$tables = array_keys(array_flip($tables));
} else {
// v2 pattern
$tables = getTablesFromPattern($pattern);
}
$pattern = rtrim($pattern, '&&');
$pattern = rtrim($pattern, '||');
$pattern = rtrim($pattern, '&|');
$tables = array_keys(array_flip($tables));
if (dbFetchCell('SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_NAME = ? && COLUMN_NAME = ?', array($tables[0],'device_id')) != 1) {
//Our first table has no valid glue, append the 'devices' table to it!
if ($tables[0] != 'devices' && dbFetchCell('SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_NAME = ? && COLUMN_NAME = ?', array($tables[0],'device_id')) != 1) {
//Our first table has no valid glue, prepend the 'devices' table to it!
array_unshift($tables, 'devices');
}
$x = sizeof($tables)-1;
@ -137,13 +144,28 @@ function GenGroupSQL($pattern, $search = '', $extra = 0)
$search = str_replace("(", "", $tables[0]).'.'.$search. ' AND';
}
if (!empty($join)) {
$join = '('.rtrim($join, ' && ').') &&';
$join = '('.rtrim($join, '& ').') &&';
}
$sql = 'SELECT DISTINCT('.str_replace('(', '', $tables[0]).'.device_id)'.$sql_extra.' FROM '.implode(',', $tables).' WHERE '.$join.' '.$search.' ('.str_replace(array('%', '@', '!~', '~'), array('', '.*', 'NOT REGEXP', 'REGEXP'), $pattern).')';
return $sql;
}//end GenGroupSQL()
/**
* Extract an array of tables in a pattern
*
* @param string $pattern
* @return array
*/
function getTablesFromPattern($pattern)
{
preg_match_all('/[A-Za-z_]+(?=\.[A-Za-z_]+ )/', $pattern, $tables);
if (is_null($tables)) {
return array();
}
return array_keys(array_flip($tables[0])); // unique tables only
}
/**
* Run the group queries again to get fresh list of devices for this group
* @param integer $group_id Group-ID
@ -151,11 +173,12 @@ function GenGroupSQL($pattern, $search = '', $extra = 0)
*/
function QueryDevicesFromGroup($group_id)
{
$pattern = dbFetchCell('SELECT pattern FROM device_groups WHERE id = ?', array($group_id));
$pattern = rtrim($pattern, '&&');
$pattern = rtrim($pattern, '||');
$group = dbFetchRow('SELECT pattern,params FROM device_groups WHERE id = ?', array($group_id));
$pattern = rtrim($group['pattern'], '&|');
$params = (array)json_decode($group['params']);
if (!empty($pattern)) {
return dbFetchColumn(GenGroupSQL($pattern));
$result = dbFetchColumn(GenGroupSQL($pattern), $params);
return $result;
}
return false;
@ -196,7 +219,9 @@ function QueryGroupsFromDevice($device_id, $extra = 0)
{
$ret = array();
foreach (GetDeviceGroups() as $group) {
if (dbFetchCell(GenGroupSQL($group['pattern'], 'device_id=?', $extra).' LIMIT 1', array($device_id)) == $device_id) {
$params = (array)json_decode($group['params']);
array_unshift($params, $device_id);
if (dbFetchCell(GenGroupSQL($group['pattern'], 'device_id=?', $extra).' LIMIT 1', $params) == $device_id) {
if ($extra === 0) {
$ret[] = $group['id'];
} else {
@ -257,6 +282,7 @@ function RunGroupMacros($rule, $x = 1)
*/
function UpdateGroupsForDevice($device_id)
{
d_echo("### Start Device Groups ###\n");
$queried_groups = QueryGroupsFromDevice($device_id);
$db_groups = GetGroupsFromDevice($device_id);
@ -264,6 +290,9 @@ function UpdateGroupsForDevice($device_id)
$added_groups = array_diff($queried_groups, $db_groups);
$removed_groups = array_diff($db_groups, $queried_groups);
d_echo("Groups Added: ".implode(',', $added_groups).PHP_EOL);
d_echo("Groups Removed: ".implode(',', $removed_groups).PHP_EOL);
// insert new groups
$insert = array();
foreach ($added_groups as $group_id) {
@ -277,6 +306,7 @@ function UpdateGroupsForDevice($device_id)
if (!empty($removed_groups)) {
dbDelete('device_group_device', '`device_id`=? AND `device_group_id` IN (?)', array($device_id, array(implode(',', $removed_groups))));
}
d_echo("### End Device Groups ###\n");
}
/**
@ -306,3 +336,22 @@ function UpdateDeviceGroup($group_id)
dbDelete('device_group_device', '`device_group_id`=? AND `device_id` IN (?)', array($group_id, array(implode(',', $removed_devices))));
}
}
/**
* Fill in params into the pattern, replacing placeholders (?)
* If $params is empty or null, just returns $pattern
*
* @return string
*/
function formatDeviceGroupPattern($pattern, $params)
{
// fill in parameters
foreach ((array)$params as $value) {
if (!is_numeric($value) && !starts_with($value, "'")) {
$value = "'".$value."'";
}
$pattern = preg_replace('/\?/', $value, $pattern, 1);
}
return $pattern;
}

View File

@ -1,22 +1,34 @@
<?php
/*
* LibreNMS module for Netonix
*
* Copyright (c) 2016 Tony Murray <murraytony@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.
*/
/**
* netonix.inc.php
*
* LibreNMS mempools module for Netonix
*
* 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/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
if ($device['os'] == 'netonix') {
echo 'NETONIX : ';
$free = str_replace('"', "", snmp_get($device, 'UCD-SNMP-MIB::memTotalFree.0', '-OvQU'));
$free = snmp_get($device, 'UCD-SNMP-MIB::memTotalFree.0', '-OvQU');
if (is_numeric($free)) {
discover_mempool($valid_mempool, $device, 0, 'netonix', 'Memory', '1024');
discover_mempool($valid_mempool, $device, 0, 'netonix', 'Memory', 1024);
}
}

View File

@ -10,14 +10,6 @@
* the source code distribution for details.
*/
if (!$os) {
if (stristr($sysDescr, 'Barracuda Load Balancer') || stristr($sysDescr, 'Barracuda Load Balancer ADC')) {
$os = 'barracudaloadbalancer';
}
if (stristr($sysDescr, 'Barracuda Spam Firewall')) {
$os = 'barracudaspamfirewall';
}
if (stristr($sysDescr, 'Barracuda Firewall')) {
$os = 'barracudangfirewall';
}
if (str_contains($sysDescr, array('Barracuda Load Balancer', 'Barracuda Load Balancer ADC'), true)) {
$os = 'barracudaloadbalancer';
}

View File

@ -0,0 +1,15 @@
<?php
/*
* LibreNMS Barracuda OS information module
*
* 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.
*/
if (str_contains($sysDescr, 'Barracuda Firewall', true)) {
$os = 'barracudangfirewall';
}

View File

@ -0,0 +1,15 @@
<?php
/*
* LibreNMS Barracuda OS information module
*
* 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.
*/
if (str_contains($sysDescr, 'Barracuda Spam Firewall', true)) {
$os = 'barracudaspamfirewall';
}

View File

@ -1,7 +1,5 @@
<?php
if (!$os) {
if (stristr($sysDescr, 'bcm963')) {
$os = 'bcm963';
}
if (str_contains($sysDescr, 'bcm963', true)) {
$os = 'bcm963';
}

View File

@ -1,7 +1,5 @@
<?php
if (!$os) {
if (strstr($sysObjectId, '.1.3.6.1.4.1.3320.1')) {
$os = 'bdcom';
}
if (starts_with($sysObjectId, '.1.3.6.1.4.1.3320.1')) {
$os = 'bdcom';
}

View File

@ -1,5 +1,4 @@
<?php
/*
* LibreNMS Telco Systems OS discovery module
*
@ -12,9 +11,6 @@
* the source code distribution for details.
*/
if (!$os) {
if (strstr($sysObjectId, '.1.3.6.1.4.1.738.1.5.100')) {
$os = 'binos';
}
if (starts_with($sysObjectId, '.1.3.6.1.4.1.738.1.5.100')) {
$os = 'binos';
}

View File

@ -1,5 +1,4 @@
<?php
/*
* LibreNMS Telco Systems OS discovery module
*
@ -12,9 +11,6 @@
* the source code distribution for details.
*/
if (!$os) {
if (strstr($sysObjectId, '.1.3.6.1.4.1.738.10.5.100')) {
$os = 'binox';
}
if (starts_with($sysObjectId, '.1.3.6.1.4.1.738.10.5.100')) {
$os = 'binox';
}

View File

@ -9,8 +9,7 @@
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
if (!$os) {
if (strpos($sysObjectId, '1.3.6.1.4.1.272.4.201.82.78.79.48') !== false) {
$os = 'bintec-smart';
}
if (starts_with($sysObjectId, '.1.3.6.1.4.1.272.4.201.82.78.79.48')) {
$os = 'bintec-smart';
}

View File

@ -1,11 +1,7 @@
<?php
if (!$os) {
if (stristr($sysDescr, 'Blade Network Technologies')) {
$os = 'bnt';
}
if (preg_match('/^BNT /', $sysDescr)) {
$os = 'bnt';
}
if (str_contains($sysDescr, 'Blade Network Technologies', true)) {
$os = 'bnt';
} elseif (starts_with($sysDescr, 'BNT ')) {
$os = 'bnt';
}

View File

@ -1,7 +1,5 @@
<?php
if (!$os) {
if (preg_match('/Brother NC-.*(h|w),/', $sysDescr)) {
$os = 'brother';
}
if (preg_match('/Brother NC-.*(h|w),/', $sysDescr)) {
$os = 'brother';
}

View File

@ -10,8 +10,6 @@
* the source code distribution for details.
*/
if (!$os) {
if (strstr($sysDescr, 'BUFFALO TeraStation')) {
$os = 'buffalo';
}
if (str_contains($sysDescr, 'BUFFALO TeraStation')) {
$os = 'buffalo';
}

View File

@ -1,12 +1,5 @@
<?php
if (!$os) {
if (strstr($sysObjectId, '.6321.1.2.2.5.3')) {
$os = 'calix';
}
if (strstr($sysObjectId, '.6066.1.44')) {
$os = 'calix';
}
if (strstr($sysObjectId, '.6321.1.2.3')) { // E5-1xx
$os = 'calix';
}
if (starts_with($sysObjectId, array('.1.3.6.1.4.1.6321.1.2.2.5.3', '.1.3.6.1.4.1.6066.1.44', '.1.3.6.1.4.1.6321.1.2.3'))) {
$os = 'calix';
}

View File

@ -9,16 +9,8 @@
* the source code distribution for details.
*/
if (!$os) {
if (preg_match('/^Cambium PTP 50650/', $sysDescr)) {
$os = 'cambium';
} elseif (preg_match('/^PTP250/', $sysDescr)) {
$os = 'cambium';
} elseif (preg_match('/^Cambium/', $sysDescr)) {
$os = 'cambium';
} elseif (strstr($sysObjectId, '.1.3.6.1.4.1.17713.21')) {
$os = 'cambium';
} elseif (strstr($sysObjectId, 'enterprises.17713.21')) {
$os = 'cambium';
}
if (starts_with($sysDescr, array('Cambium PTP 50650', 'PTP250', 'Cambium'))) {
$os = 'cambium';
} elseif (starts_with($sysObjectId, '.1.3.6.1.4.1.17713.21')) {
$os = 'cambium';
}

View File

@ -1,7 +1,5 @@
<?php
if (!$os) {
// Canon Multifunction Printer/Scanner
if (strstr($sysDescr, 'Canon MF') || strstr($sysDescr, 'Canon iR')) {
$os = 'canonprinter';
}
if (str_contains($sysDescr, array('Canon MF', 'Canon iR'))) {
$os = 'canonprinter';
}

View File

@ -9,10 +9,6 @@
* the source code distribution for details.
*/
if (!$os) {
if (preg_match('/^CANOPY/', $sysDescr)) {
$os = 'canopy';
} elseif (preg_match('/^CMM/', $sysDescr)) {
$os = 'canopy';
}
if (starts_with($sysDescr, array('CANOPY', 'CMM'))) {
$os = 'canopy';
}

View File

@ -1,7 +1,5 @@
<?php
if (!$os) {
if (strstr($sysDescr, 'Cisco Systems Catalyst 1900')) {
$os = 'cat1900';
}
if (str_contains($sysDescr, 'Cisco Systems Catalyst 1900')) {
$os = 'cat1900';
}

View File

@ -1,7 +1,5 @@
<?php
if (!$os) {
if (strstr($sysDescr, 'Cisco Catalyst Operating System Software')) {
$os = 'catos';
}
if (str_contains($sysDescr, 'Cisco Catalyst Operating System Software')) {
$os = 'catos';
}

View File

@ -9,8 +9,7 @@
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
if (!$os) {
if (strpos($sysObjectId, '.1.3.6.1.4.1.2620.1.6.123.1.49') !== false) {
$os = 'gaia';
}
if (starts_with($sysObjectId, '.1.3.6.1.4.1.2620.1.6.123.1.49')) {
$os = 'gaia';
}

View File

@ -9,9 +9,7 @@
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
if (!$os) {
if (stristr($sysDescr, 'Cisco Integrated Management Controller')) {
$os = 'cimc';
}
if (str_contains($sysDescr, 'Cisco Integrated Management Controller', true)) {
$os = 'cimc';
}

View File

@ -1,28 +1,17 @@
<?php
if (!$os) {
if (strstr($sysObjectId, '.1.3.6.1.4.1.9.6.1.80')) {
$os = 'ciscosb';
}
if (strstr($sysObjectId, '.1.3.6.1.4.1.9.6.1.81')) {
$os = 'ciscosb';
}
if (strstr($sysObjectId, '.1.3.6.1.4.1.9.6.1.82')) {
$os = 'ciscosb';
}
if (strstr($sysObjectId, '.1.3.6.1.4.1.9.6.1.83')) {
$os = 'ciscosb';
}
$ciscosb_id = array(
'.1.3.6.1.4.1.9.6.1.80',
'.1.3.6.1.4.1.9.6.1.81',
'.1.3.6.1.4.1.9.6.1.82',
'.1.3.6.1.4.1.9.6.1.83',
'.1.3.6.1.4.1.9.6.1.85',
'.1.3.6.1.4.1.9.6.1.88',
'.1.3.6.1.4.1.9.6.1.89',
);
if (strstr($sysObjectId, '.1.3.6.1.4.1.9.6.1.85')) {
if (starts_with($sysObjectId, $ciscosb_id)) {
$os = 'ciscosb';
}
if (strstr($sysObjectId, '.1.3.6.1.4.1.9.6.1.88')) {
$os = 'ciscosb';
}
if (strstr($sysObjectId, '.1.3.6.1.4.1.9.6.1.89')) {
$os = 'ciscosb';
}
}
unset($ciscosb_id);

View File

@ -1,7 +1,5 @@
<?php
if (!$os) {
if (strstr($sysDescr, 'Cisco Small Business WAP')) {
$os = 'ciscowap';
}
if (str_contains($sysDescr, 'Cisco Small Business WAP')) {
$os = 'ciscowap';
}

View File

@ -1,5 +1,4 @@
<?php
/*
* LibreNMS Cisco wireless controller OS detection module
*
@ -11,8 +10,6 @@
* the source code distribution for details.
*/
if (!$os) {
if (strstr($sysDescr, 'Cisco Controller')) {
$os = 'ciscowlc';
}
if (str_contains($sysDescr, 'Cisco Controller')) {
$os = 'ciscowlc';
}

View File

@ -1,9 +1,7 @@
<?php
if (!$os) {
if (preg_match('/.+Firmware Version \d+-\d+-\d+.+/', $sysDescr)) {
if (is_numeric(snmp_get($device, '.1.3.6.1.4.1.22626.1.5.2.1.3.0', '-Oqv', ''))) {
$os = 'cometsystem-p85xx';
}
if (preg_match('/.+Firmware Version \d+-\d+-\d+.+/', $sysDescr)) {
if (is_numeric(snmp_get($device, '.1.3.6.1.4.1.22626.1.5.2.1.3.0', '-Oqv', ''))) {
$os = 'cometsystem-p85xx';
}
}

View File

@ -1,11 +1,9 @@
<?php
if (!$os) {
if (strstr($sysDescr, 'Comware')) {
$os = 'comware';
} elseif (preg_match('/HP [a-zA-Z0-9- ]+ Switch Software Version/', $sysDescr)) {
$os = 'comware';
} elseif (strstr($sysObjectId, '.1.3.6.1.4.1.25506.11.1')) {
$os = 'comware';
}
if (str_contains($sysDescr, 'Comware')) {
$os = 'comware';
} elseif (preg_match('/HP [a-zA-Z0-9- ]+ Switch Software Version/', $sysDescr)) {
$os = 'comware';
} elseif (starts_with($sysObjectId, '.1.3.6.1.4.1.25506.11.1')) {
$os = 'comware';
}

View File

@ -10,8 +10,6 @@
* the source code distribution for details.
*/
if (!$os) {
if (starts_with($sysObjectId, '.1.3.6.1.4.1.9.1.1348')) {
$os = 'cucm';
}
if (starts_with($sysObjectId, '.1.3.6.1.4.1.9.1.1348')) {
$os = 'cucm';
}

View File

@ -1,7 +1,5 @@
<?php
if (!$os) {
// Eaton UPS
if (str_contains($sysDescr, 'Eaton 5P')) {
$os = 'eatonups';
}
// Eaton UPS
if (starts_with($sysDescr, 'Eaton 5P') || starts_with($sysObjectId, '.1.3.6.1.4.1.534.')) {
$os = 'eatonups';
}

View File

@ -0,0 +1,5 @@
<?php
if (starts_with($sysDescr, 'WatchGuard Fireware') || starts_with($sysObjectId, '.1.3.6.1.4.1.3097.1.5')) {
$os = 'firebox';
}

View File

@ -10,8 +10,6 @@
* the source code distribution for details.
*/
if (!$os) {
if (stristr($sysDescr, 'BladeCenter Advanced Management Module')) {
$os = 'ibm-amm';
}
if (str_contains($sysDescr, 'BladeCenter Advanced Management Module', true)) {
$os = 'ibm-amm';
}

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