Skip to content

Commit

Permalink
Merge branch 'master' into issue-3550
Browse files Browse the repository at this point in the history
Conflicts:
	html/includes/graphs/device/sla.inc.php
	includes/polling/cisco-sla.inc.php

- Use standardised RRD functions
  • Loading branch information
adaniels21487 committed Aug 11, 2016
2 parents ae7bb06 + 516e49b commit 70a0536
Show file tree
Hide file tree
Showing 430 changed files with 3,197 additions and 3,363 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
!/.editorconfig
!/.scrutinizer.yml
!/.travis.yml
!/.php_cs
!/.github/

# Others #
Expand Down
18 changes: 18 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
// PHP CS Fixer config file


$finder = Symfony\CS\Finder\DefaultFinder::create()
->exclude('html/includes/geshi')
->exclude('html/includes/jpgraph')
->exclude('html/includes/Slim')
->exclude('html/lib')
->exclude('lib')
->exclude('logs')
->exclude('mibs')
->exclude('rrd')
->in(__DIR__);

return Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
->finder($finder);
26 changes: 16 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
language: php

php:
- '5.3'
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- hhvm

matrix:
fast_finish: true
include:
- php: 5.3
script: find . -path './lib/influxdb-php' -prune -o -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1
- php: 5.4
script: find . -path './lib/influxdb-php' -prune -o -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1
- php: 5.5
script: find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1
- php: 5.6
script: find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1
- php: 7.0
script: find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1
- php: hhvm
script: find . -path './lib/influxdb-php' -prune -o -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1
allow_failures:
- php: 7.0
- php: 7.0
- php: hhvm
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ LibreNMS contributors:
- Cercel Valentin <crc@nuamchefazi.ro> (crcro)
- Ahmed Sajid <ahmed4343@hotmail.com> (ahmedsajid)
- Karsten Schmidt <git@guggemand.dk> (guggemand)
- Maxence POULAIN <maxence.poulain@eriador.info> (Linutux42)
- Florian Beer <fb@42dev.eu> (florianbeer)

[1]: http://observium.org/ "Observium web site"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](https://scrutinizer-ci.com/g/librenms/librenms/badges/build.png?b=master)](https://scrutinizer-ci.com/g/librenms/librenms/build-status/master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/librenms/librenms/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/librenms/librenms/?branch=master) [![Build Status](https://travis-ci.org/librenms/librenms.svg?branch=master)](https://travis-ci.org/librenms/librenms)

Introduction
------------

Expand Down
34 changes: 19 additions & 15 deletions addhost.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
$cmd = array_shift($argv);
array_shift($argv);
array_unshift($argv, $cmd);
$force_add = 1;
$force_add = true;
} else {
$force_add = 0;
$force_add = false;
}

$port_assoc_mode = $config['default_port_association_mode'];
Expand All @@ -49,7 +49,7 @@
if (! in_array ($port_assoc_mode, $valid_assoc_modes)) {
echo "Invalid port association mode '" . $port_assoc_mode . "'\n";
echo 'Valid modes: ' . join (', ', $valid_assoc_modes) . "\n";
exit(2);
exit(1);
}

$cmd = array_shift($argv);
Expand Down Expand Up @@ -115,7 +115,7 @@
$v3['authalgo'] = $arg;
} else {
echo 'Invalid argument: '.$arg."\n";
exit(2);
exit(1);
}
}

Expand All @@ -139,7 +139,7 @@
$v3['cryptoalgo'] = $arg;
} else {
echo 'Invalid argument: '.$arg."\n";
exit(2);
exit(1);
}
}//end while

Expand All @@ -165,16 +165,20 @@
}
}//end if

$result = addHost($host, $snmpver, $port, $transport, 0, $poller_group, $force_add, $port_assoc_mode);

if (is_numeric($result)) {
$device = device_by_id_cache($result);
echo 'Added device '.$device['hostname'].' ('.$result.")\n";
try {
$device_id = addHost($host, $snmpver, $port, $transport, $poller_group, $force_add, $port_assoc_mode);
$device = device_by_id_cache($device_id);
echo "Added device {$device['hostname']} ($device_id)\n";
exit(0);
}
else {
print $console_color->convert("%rWe couldn't add this device:\n " . $result . "%n\n");
exit(1);
} catch (HostUnreachableException $e) {
print_error($e->getMessage());
foreach ($e->getReasons() as $reason) {
echo " $reason\n";
}
exit(2);
} catch (Exception $e){
print_error($e->getMessage());
exit(3);
}
} else {

Expand All @@ -197,5 +201,5 @@
%rRemember to run discovery for the host afterwards.%n
'
);
exit(2);
exit(1);
}
2 changes: 1 addition & 1 deletion doc/API/API-Docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ Output:
```text
{
"status": "ok",
"message": "Device localhost.localdomain has been added successfully"
"message": "Device localhost.localdomain (57) has been added successfully"
}
```

Expand Down
4 changes: 0 additions & 4 deletions doc/Extensions/Distributed-Poller.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ Running Apache and an install of LibreNMS in /opt/librenms
```php
$config['distributed_poller'] = true;
$config['rrdcached'] = "example.com:42217";
$config['rrdcached_dir'] = ".";
```

Database Server:
Expand Down Expand Up @@ -126,7 +125,6 @@ $config['distributed_poller_host'] = "example.com";
$config['distributed_poller_port'] = 11211;
$config['distributed_poller'] = true;
$config['rrdcached'] = "example.com:42217";
$config['rrdcached_dir'] = ".";
$config['update'] = 0;
```

Expand All @@ -153,7 +151,6 @@ $config['distributed_poller_host'] = "example.com";
$config['distributed_poller_port'] = 11211;
$config['distributed_poller'] = true;
$config['rrdcached'] = "example.com:42217";
$config['rrdcached_dir'] = ".";
$config['update'] = 0;
```

Expand All @@ -178,7 +175,6 @@ $config['distributed_poller_host'] = "example.com";
$config['distributed_poller_port'] = 11211;
$config['distributed_poller'] = true;
$config['rrdcached'] = "example.com:42217";
$config['rrdcached_dir'] = ".";
$config['update'] = 0;
```

Expand Down
12 changes: 6 additions & 6 deletions doc/Extensions/RRDCached.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

This document will explain how to setup RRDCached for LibreNMS.

> If you are using rrdtool / rrdcached version 1.5 or above then this now supports creating rrd files over rrdcached. To
enable this set the following config:
> If you are using rrdtool / rrdcached version 1.5 or above then this now supports creating rrd files over rrdcached.
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;
$config['rrdtool_version'] = 1.5.5;
```

### RRDCached installation CentOS 6
Expand All @@ -29,7 +30,7 @@ vi /etc/yum.repos.d/rpmforge.repo
vi /etc/sysconfig/rrdcached
# Settings for rrdcached
OPTIONS="-w 1800 -z 1800 -f 3600 -s librenms -U librenms -G librenms -j /var/tmp -l unix:/var/run/rrdcached/rrdcached.sock -t 4 -F -b /opt/librenms/rrd/"
OPTIONS="-w 1800 -z 1800 -f 3600 -s librenms -U librenms -G librenms -B -R -j /var/tmp -l unix:/var/run/rrdcached/rrdcached.sock -t 4 -F -b /opt/librenms/rrd/"
RRDC_USER=librenms
mkdir /var/run/rrdcached
Expand Down Expand Up @@ -77,8 +78,7 @@ After=network.service
[Service]
Type=forking
PIDFile=/run/rrdcached.pid
ExecStart=/usr/bin/rrdcached -w 1800 -z 1800 -f 3600 -s librenms -U librenms -G librenms -j /var/tmp -l unix:/var/run/rrdcached/rrdcached.sock -t 4 -F -b /opt/librenms/rrd/
RRDC_USER=librenms
ExecStart=/usr/bin/rrdcached -w 1800 -z 1800 -f 3600 -s librenms -U librenms -G librenms -B -R -j /var/tmp -l unix:/var/run/rrdcached/rrdcached.sock -t 4 -F -b /opt/librenms/rrd/
[Install]
WantedBy=default.target
Expand Down
6 changes: 2 additions & 4 deletions doc/Support/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,9 @@ Settings to enable memcached - currently it's not recommended to run memcached u

```php
$config['rrdcached'] = "unix:/var/run/rrdcached.sock"; // or a tcp connection 127.0.0.1:42217
$config['rrdcached_dir'] = FALSE;
```
To enable rrdcached you need to set at least the `rrdcached` option. If `rrdcached` is a tcp socket then you need to configure `rrdcached_dir` as well.
This should be set based on your base directory for running rrdcached. For instance if -b for rrdcached is set to /var/lib/rrd but you are expecting
LibreNMS to store them in /var/lib/rrd/librenms then you would need to set `rrdcached_dir` to librenms.
To enable rrdcached you need to set at least the `rrdcached` option. Make sure rrdcached is started with the `-b` option set to the correct directoy,
as configured in `$config['rrd_dir`]`.

#### WebUI Settings

Expand Down
26 changes: 15 additions & 11 deletions doc/Support/Support-New-OS.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,25 +300,29 @@ $version = trim(snmp_get($device, "productVersion.0", "-OQv", "PULSESECURE-PSG-M
$hardware = "Juniper " . trim(snmp_get($device, "productName.0", "-OQv", "PULSESECURE-PSG-MIB"),'"');
$hostname = trim(snmp_get($device, "sysName.0", "-OQv", "SNMPv2-MIB"),'"');

$usersrrd = $config['rrd_dir'].'/'.$device['hostname'].'/pulse_users.rrd';
$users = snmp_get($device, 'PULSESECURE-PSG-MIB::iveConcurrentUsers.0', '-OQv');

if (is_numeric($users)) {
if (!is_file($usersrrd)) {
rrdtool_create($usersrrd, ' DS:users:GAUGE:600:0:U'.$config['rrd_rra']);
}
rrdtool_update($usersrrd, "N:$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;
}

$sessrrd = $config['rrd_dir'].'/'.$device['hostname'].'/pulse_sessions.rrd';
$sessions = snmp_get($device, 'PULSESECURE-PSG-MIB::iveConcurrentUsers.0', '-OQv');

if (is_numeric($sessions)) {
if (!is_file($sessrrd)) {
rrdtool_create($sessrrd, ' DS:sessions:GAUGE:600:0:U '.$config['rrd_rra']);
$rrd_def = array(
'DS:sessions:GAUGE:600:0:U',
}
rrdtool_update($sessrrd, "N:$sessions");
$fields = array(
'sessions' => $sessions
);
$tags = compact('rrd_def');
data_update($device, 'pulse_sessions', $tags, $fields);
$graphs['pulse_sessions'] = true;
}
```
Expand Down Expand Up @@ -353,7 +357,7 @@ html/includes/graphs/device/pulse_sessions.inc.php
```php
<?php

$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('pulse_sessions.rrd');
$rrd_filename = rrd_name($device['hostname'], 'pulse_sessions');

require 'includes/graphs/common.inc.php';

Expand Down Expand Up @@ -381,7 +385,7 @@ html/includes/graphs/device/pulse_users.inc.php
```php
<?php

$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('pulse_users.rrd');
$rrd_filename = rrd_name($device['hostname'], 'pulse_users');

require 'includes/graphs/common.inc.php';

Expand Down
Binary file modified html/images/os/ubuntu.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 5 additions & 6 deletions html/includes/api_functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,13 @@ function add_device() {
$message = "You haven't specified an SNMP version to use";
}
if (empty($message)) {
$result = addHost($hostname, $snmpver, $port, $transport, 1, $poller_group, $force_add);
if (is_numeric($result)) {
try {
$device_id = addHost($hostname, $snmpver, $port, $transport, $poller_group, $force_add);
$code = 201;
$status = 'ok';
$message = "Device $hostname has been added successfully";
}
else {
$message = $result;
$message = "Device $hostname ($device_id) has been added successfully";
} catch (Exception $e) {
$message = $e->getMessage();
}
}

Expand Down
2 changes: 1 addition & 1 deletion html/includes/graphs/XXX_device_memory_windows.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

$device = device_by_id_cache($id);

$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/mem.rrd';
$rrd_filename = rrd_name($device['hostname'], 'mem');

$rrd_options .= ' -b 1024';

Expand Down
2 changes: 1 addition & 1 deletion html/includes/graphs/accesspoints/channel.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_filename = rrd_name($device['hostname'], array('arubaap', $ap['name'].$ap['radio_number']));

$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Channel';
Expand Down
2 changes: 1 addition & 1 deletion html/includes/graphs/accesspoints/interference.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_filename = rrd_name($device['hostname'], array('arubaap', $ap['name'].$ap['radio_number']));

$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Interference';
Expand Down
2 changes: 1 addition & 1 deletion html/includes/graphs/accesspoints/numasoclients.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_filename = rrd_name($device['hostname'], array('arubaap', $ap['name'].$ap['radio_number']));

$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Num Clients';
Expand Down
2 changes: 1 addition & 1 deletion html/includes/graphs/accesspoints/nummonbssid.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_filename = rrd_name($device['hostname'], array('arubaap', $ap[name].$ap[radio_number]));

$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'MonBSSIDs';
Expand Down
2 changes: 1 addition & 1 deletion html/includes/graphs/accesspoints/nummonclients.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_filename = rrd_name($device['hostname'], array('arubaap', $ap['name'].$ap['radio_number']));

$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Mon Clients';
Expand Down
2 changes: 1 addition & 1 deletion html/includes/graphs/accesspoints/radioutil.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_filename = rrd_name($device['hostname'], array('arubaap', $ap['name'].$ap['radio_number']));

$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'radioutil';
Expand Down
2 changes: 1 addition & 1 deletion html/includes/graphs/accesspoints/txpow.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_filename = rrd_name($device['hostname'], array('arubaap', $ap['name'].$ap['radio_number']));

$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'txpow';
Expand Down
2 changes: 1 addition & 1 deletion html/includes/graphs/altiga_ssl_sessions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$device = device_by_id_cache($id);

$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/altiga-ssl.rrd.rrd';
$rrd_filename = rrd_name($device['hostname'], 'altiga-ssl');

$rrd_options .= " DEF:TotalSessions=$rrd_filename:TotalSessions:AVERAGE";
$rrd_options .= " DEF:ActiveSessions=$rrd_filename:ActiveSessions:AVERAGE";
Expand Down
4 changes: 2 additions & 2 deletions html/includes/graphs/application/apache_bits.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

require 'includes/graphs/common.inc.php';

$apache_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-apache-'.$app['app_id'].'.rrd';
$apache_rrd = rrd_name($device['hostname'], array('app', 'apache', $app['app_id']));

if (is_file($apache_rrd)) {
if (rrdtool_check_rrd_exists($apache_rrd)) {
$rrd_filename = $apache_rrd;
}

Expand Down

0 comments on commit 70a0536

Please sign in to comment.