2018-07-03 18:48:04 +12:00
|
|
|
source: Extensions/Smokeping.md
|
2018-10-27 23:04:34 +01:00
|
|
|
path: blob/master/doc/
|
2015-07-07 20:24:09 +01:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
# Smokeping integration
|
2015-07-07 20:24:09 +01:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
[SmokePing](https://oss.oetiker.ch/smokeping/) is a tool which lets us
|
|
|
|
keep track of network latency, and visualise this through RRD graphs.
|
2015-07-07 20:24:09 +01:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
LibreNMS has support for both new and pre-existing SmokePing installations.
|
2015-07-07 20:24:09 +01:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
For new installations, we can use the included
|
|
|
|
`scripts/gen_smokeping.php` script to generate a Smokeping config file.
|
2015-07-07 20:24:09 +01:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
## New Smokeping installation
|
2015-07-07 20:24:09 +01:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
### Install and integrate Smokeping - Debian/Ubuntu
|
2018-07-02 18:55:42 +12:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
This guide assumes you have already [installed
|
|
|
|
librenms](http://docs.librenms.org/Installation/Installing-LibreNMS/),
|
|
|
|
and is working with either **Apache** or
|
|
|
|
**nginx**.
|
2018-07-02 18:55:42 +12:00
|
|
|
|
2019-02-12 19:49:09 -08:00
|
|
|
Note: You may need to install `fcgiwrap` as well (at least with `nginx`).
|
2018-07-02 18:55:42 +12:00
|
|
|
|
|
|
|
### Install Smokeping
|
2015-07-07 20:24:09 +01:00
|
|
|
|
|
|
|
```bash
|
2018-07-02 18:55:42 +12:00
|
|
|
sudo apt update && sudo apt install smokeping
|
2015-07-07 20:24:09 +01:00
|
|
|
```
|
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
## Configure SmokePing
|
2015-07-07 20:24:09 +01:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
Smokeping has several configuration files. By default, these are
|
|
|
|
located in `/etc/smokeping/config.d/`
|
2018-07-02 18:55:42 +12:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
Edit the `General` configuration file's **Owner** and **contact**, and
|
|
|
|
**cgiurl hostname** details:
|
2018-07-02 18:55:42 +12:00
|
|
|
|
|
|
|
```bash
|
|
|
|
nano /etc/smokeping/config.d/General
|
|
|
|
owner = LibreNMS-Admin
|
|
|
|
contact = admin@ACME.xxx
|
|
|
|
cgiurl = http://yourlibrenms/cgi-bin/smokeping.cgi
|
2015-07-07 20:24:09 +01:00
|
|
|
```
|
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
### Configure Smokeping to use LibreNMS list of nodes
|
2015-07-07 20:24:09 +01:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
Add the following line to `/etc/smokeping/config` config file:
|
2015-07-07 20:24:09 +01:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
```bash
|
2019-03-31 02:18:55 -07:00
|
|
|
@include /etc/smokeping/config.d/librenms.conf
|
2015-07-07 20:24:09 +01:00
|
|
|
```
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
We will generate the conf file in the next step.
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
### Generate LibreNMS list of Smokeping Nodes
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
LibreNMS comes equipped with a script which exports our list of nodes
|
|
|
|
from LibreNMS into a configuration file in the format required by
|
|
|
|
Smokeping.
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
To generate the config file once:
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
```bash
|
2019-02-12 19:49:09 -08:00
|
|
|
(echo "+ LibreNMS"; php -f /opt/librenms/scripts/gen_smokeping.php) | sudo tee /etc/smokeping/config.d/librenms.conf
|
2018-07-02 18:55:42 +12:00
|
|
|
```
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
**However**, it is more desirable to set up a cron job which
|
|
|
|
regenerates our list of nodes and adds these into Smokeping. You can
|
|
|
|
add the following to the end of your librenms cron job, e.g. `nano /etc/cron.d/librenms`
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
**Ubuntu 16.04** Sample cron (will run daily at 00:05) :
|
2015-12-04 00:28:23 -06:00
|
|
|
|
|
|
|
```bash
|
2018-07-02 18:55:42 +12:00
|
|
|
05 00 * * * root (echo "+ LibreNMS"; php -f /opt/librenms/scripts/gen_smokeping.php) > /etc/smokeping/config.d/librenms.conf && systemctl reload smokeping.service >> /dev/null 2>&1
|
2015-12-04 00:28:23 -06:00
|
|
|
```
|
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
**Ubuntu 14.04** Sample cron (will run daily at 00:05):
|
2015-12-04 00:28:23 -06:00
|
|
|
|
|
|
|
```bash
|
2018-07-02 18:55:42 +12:00
|
|
|
05 00 * * * root (echo "+ LibreNMS"; php -f /opt/librenms/scripts/gen_smokeping.php) > /opt/smokeping/etc/librenms.conf && /opt/smokeping/bin/smokeping --reload >> /dev/null 2>&1
|
2015-12-04 00:28:23 -06:00
|
|
|
```
|
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
**Why echo "+ LibreNMS" ?**
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
This is in the cron job because the `gen_smokeping.php` script contains
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
```
|
|
|
|
menu = Top
|
|
|
|
title = Network Latency Grapher
|
2015-12-04 00:28:23 -06:00
|
|
|
```
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
Which can cause Smokeping to not start. `echo "+ LibreNMS"` prepends
|
|
|
|
this in our smokeping config file. We could remove the above from the
|
|
|
|
gen_smokeping script, however this may cause issues with LibreNMS
|
|
|
|
failing to update with `daily.sh` due config files being modified.
|
2018-07-02 18:55:42 +12:00
|
|
|
|
|
|
|
## Configure LibreNMS
|
|
|
|
|
|
|
|
Edit `/opt/librenms/config.php` and add the following:
|
|
|
|
|
|
|
|
**Note:** Make sure you point dir to the correct Smokeping data directory:
|
|
|
|
|
|
|
|
```php
|
2019-04-04 02:02:24 +13:00
|
|
|
$config['smokeping']['dir'] = '/var/lib/smokeping'; // Ubuntu 16.04 and newer Location
|
2018-07-02 18:55:42 +12:00
|
|
|
#$config['smokeping']['dir'] = '/opt/smokeping/data';
|
2019-09-09 05:48:35 -05:00
|
|
|
$config['smokeping']['pings'] = 20; // should be equal to "pings" in your smokeping config
|
2018-07-02 18:55:42 +12:00
|
|
|
$config['smokeping']['integration'] = true;
|
2020-07-22 16:01:14 +02:00
|
|
|
$config['smokeping']['url'] = 'smokeping/'; // If you have a specific URL or path for smokeping
|
2015-12-04 00:28:23 -06:00
|
|
|
```
|
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
## Configure web server
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
This section covers the required configuration for your web server of
|
|
|
|
choice. This covers the required configuration for either Apache or Nginx.
|
2018-07-02 18:55:42 +12:00
|
|
|
|
|
|
|
### Apache Configuration
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
Smokeping should automatically install an Apache config file in
|
|
|
|
`/etc/apache2/conf-available/`. Verify this using :
|
2015-12-04 00:28:23 -06:00
|
|
|
|
|
|
|
```bash
|
2019-09-09 05:48:35 -05:00
|
|
|
librenms@librenms:~/scripts$ ls /etc/apache2/conf-available/ | grep smokeping
|
2018-07-02 18:55:42 +12:00
|
|
|
smokeping.conf
|
2015-12-04 00:28:23 -06:00
|
|
|
```
|
|
|
|
|
|
|
|
If you don't see `smokeping.conf` listed, you'll need to create a symlink for it:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
ln -s /etc/smokeping/apache2.conf /etc/apache2/conf-available/smokeping.conf
|
|
|
|
```
|
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
After creating the symlink, restart Apache with `sudo systemctl apache2 restart`
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
You should be able to load the Smokeping web interface at `http://yourhost/cgi-bin/smokeping.cgi`
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
### Nginx Configuration
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
This section assumes you have configured LibreNMS with Nginx as
|
|
|
|
specified in [Configure Nginx](https://docs.librenms.org/Installation/Installation-Ubuntu-1804-Nginx/).
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
Add the following configuration to your `/etc/nginx/conf.d/librenms` config file.
|
2018-07-02 18:55:42 +12:00
|
|
|
|
|
|
|
The following will configure Nginx to respond to `http://yourlibrenms/smokeping`:
|
2015-12-04 00:28:23 -06:00
|
|
|
|
|
|
|
```
|
2018-07-02 18:55:42 +12:00
|
|
|
#Browsing to `http://librenms.xxx/smokeping/` should bring up the smokeping web interface
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
location = /smokeping/ {
|
|
|
|
fastcgi_intercept_errors on;
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/smokeping.cgi;
|
|
|
|
fastcgi_param QUERY_STRING $query_string;
|
|
|
|
fastcgi_param REQUEST_METHOD $request_method;
|
|
|
|
fastcgi_param CONTENT_TYPE $content_type;
|
|
|
|
fastcgi_param CONTENT_LENGTH $content_length;
|
|
|
|
fastcgi_param REQUEST_URI $request_uri;
|
|
|
|
fastcgi_param DOCUMENT_URI $document_uri;
|
|
|
|
fastcgi_param DOCUMENT_ROOT $document_root;
|
|
|
|
fastcgi_param SERVER_PROTOCOL $server_protocol;
|
|
|
|
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
|
|
|
|
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
|
|
|
|
fastcgi_param REMOTE_ADDR $remote_addr;
|
|
|
|
fastcgi_param REMOTE_PORT $remote_port;
|
|
|
|
fastcgi_param SERVER_ADDR $server_addr;
|
|
|
|
fastcgi_param SERVER_PORT $server_port;
|
|
|
|
fastcgi_param SERVER_NAME $server_name;
|
|
|
|
fastcgi_param HTTPS $https if_not_empty;
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
fastcgi_pass unix:/var/run/fcgiwrap.socket;
|
|
|
|
}
|
2015-12-05 00:58:17 -06:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
location ^~ /smokeping/ {
|
|
|
|
alias /usr/share/smokeping/www/;
|
|
|
|
index smokeping.cgi;
|
|
|
|
gzip off;
|
|
|
|
}
|
2015-12-05 00:58:17 -06:00
|
|
|
```
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
After saving the config file, verify your Nginx config file syntax is
|
|
|
|
OK with `sudo nginx -t`, then restart Nginx with `sudo systemctl restart nginx`
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
You should be able to load the Smokeping web interface at `http://yourhost/smokeping`
|
2019-07-04 10:27:38 +02:00
|
|
|
|
|
|
|
#### Nginx Password Authentification
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
You can use the purpose-made htpasswd utility included in the
|
|
|
|
apache2-utils package (Nginx password files use the same format as
|
|
|
|
Apache). You can install it on Ubuntu with
|
2019-07-04 10:27:38 +02:00
|
|
|
|
|
|
|
```
|
|
|
|
apt install apache2-utils
|
|
|
|
```
|
|
|
|
|
|
|
|
After that you need to create password for your user
|
|
|
|
|
|
|
|
```
|
|
|
|
htpasswd -c /etc/nginx/.htpasswd USER
|
|
|
|
```
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
You can verify your user and password with
|
2019-07-04 10:27:38 +02:00
|
|
|
|
|
|
|
```
|
|
|
|
cat /etc/nginx/.htpasswd
|
|
|
|
```
|
|
|
|
|
|
|
|
Then you just need to add to your config `auth_basic` parameters
|
|
|
|
|
|
|
|
```
|
|
|
|
location ^~ /smokeping/ {
|
|
|
|
alias /usr/share/smokeping/www/;
|
|
|
|
index smokeping.cgi;
|
|
|
|
gzip off;
|
|
|
|
auth_basic "Private Property";
|
2019-10-17 19:23:47 +02:00
|
|
|
auth_basic_user_file /etc/nginx/.htpasswd;
|
2019-07-04 10:27:38 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
### Start SmokePing
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
Use the below commands to start and verify smokeping is running.
|
2015-12-05 00:58:17 -06:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
**Ubuntu 14.04:** `sudo service smokeping start`
|
|
|
|
|
|
|
|
Verify: `sudo service smokeping status`
|
|
|
|
|
2019-04-04 02:02:24 +13:00
|
|
|
**Ubuntu 16.04 and newer:** `sudo systemctl start smokeping`
|
2018-07-02 18:55:42 +12:00
|
|
|
|
|
|
|
Verify: `sudo systemctl status smokeping`
|
|
|
|
|
|
|
|
## Verify in LibreNMS
|
|
|
|
|
2020-09-02 15:21:40 +02:00
|
|
|
Within LibreNMS, you should now see the Smokeping graphs under Latency tab.
|
2019-09-09 05:48:35 -05:00
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
--------------
|
|
|
|
# Pre-Existing Smokeping Installation
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
The following section covers the requirements for an existing
|
|
|
|
SmokePing installation. The primary difference is this section does
|
|
|
|
not cover using the LibreNMS Smokeping config script, and assumes an
|
|
|
|
existing Smokeping server is set up and working correctly.
|
2018-07-02 18:55:42 +12:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
In terms of configuration, simply add the location of where smokeping
|
|
|
|
data such as RRD files are stored. If this is on a separate server,
|
|
|
|
ensure there is a mount point reachable, along with the server's hostname.
|
2018-07-02 18:55:42 +12:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
**Note:** The location should be the RRD root folder, NOT the
|
|
|
|
sub-directory such as network.
|
2018-07-02 18:55:42 +12:00
|
|
|
|
|
|
|
```php
|
2019-04-04 02:02:24 +13:00
|
|
|
$config['smokeping']['dir'] = '/var/lib/smokeping'; // Ubuntu 16.04 and newer Location
|
2018-07-02 18:55:42 +12:00
|
|
|
#$config['smokeping']['dir'] = '/opt/smokeping/data';
|
2019-09-09 05:48:35 -05:00
|
|
|
$config['smokeping']['pings'] = 20; // should be equal to "pings" in your smokeping config
|
2018-08-08 17:25:17 +01:00
|
|
|
$config['smokeping']['integration'] = true;
|
2015-12-05 00:58:17 -06:00
|
|
|
```
|
|
|
|
|
2018-07-02 18:55:42 +12:00
|
|
|
You should now see a new tab in your device page called ping.
|
|
|
|
|
|
|
|
# Issues
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
## `ERROR: /etc/smokeping/config.d/pathnames, line 1: File '/usr/sbin/sendmail' does not exist`
|
2018-07-02 18:55:42 +12:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
If you got this error at the end of the installation, simply edit
|
|
|
|
smokeping's config file like so:
|
2018-07-02 18:55:42 +12:00
|
|
|
|
|
|
|
```diff
|
|
|
|
nano /etc/smokeping/config.d/pathnames
|
|
|
|
|
|
|
|
-sendmail = /usr/sbin/sendmail
|
|
|
|
+#sendmail = /usr/sbin/sendmail
|
|
|
|
```
|
2015-12-04 00:28:23 -06:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
## Smokeping and RRDCached
|
2017-01-03 19:45:33 +00:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
If you are using the standard smokeping data dir
|
|
|
|
(`/etc/smokeping/data`) then you may need to alter the rrdcached
|
|
|
|
config slightly.
|
2017-01-03 19:45:33 +00:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
In the standard configuration the -B argument may have been used to
|
|
|
|
restrict rrdcached to read only from a single base dir.
|
2017-01-03 19:45:33 +00:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
If this is true, when you try an open one of the smokeping graphs from
|
|
|
|
within LibreNMS you will see something like this error at the end of
|
|
|
|
the rrdcached command:
|
2017-01-03 19:45:33 +00:00
|
|
|
|
|
|
|
```bash
|
|
|
|
ERROR: rrdcached: /var/lib/smokeping/<device name>.rrd: Permission denied
|
|
|
|
```
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
You will need to either change the dir in which smokeping saves its
|
|
|
|
rrd files to be the same as the main librenms dir or you can remove
|
|
|
|
the -B argument from the rrdcached config to allow it to read from
|
|
|
|
more than one dir.
|
2017-01-03 19:45:33 +00:00
|
|
|
|
2019-10-21 15:14:28 +02:00
|
|
|
### To remove the -B switch:
|
2017-01-03 19:45:33 +00:00
|
|
|
|
|
|
|
```bash
|
|
|
|
sudo nano /etc/default/rrdcached
|
|
|
|
```
|
2019-09-09 05:48:35 -05:00
|
|
|
|
2017-01-03 19:45:33 +00:00
|
|
|
then find:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
BASE_OPTIONS=
|
|
|
|
```
|
2019-09-09 05:48:35 -05:00
|
|
|
|
2017-01-03 19:45:33 +00:00
|
|
|
If -B is in the list of arguments delete it.
|
2019-10-21 15:14:28 +02:00
|
|
|
|
|
|
|
### To store smokeping rrd in librenms rrd folder
|
|
|
|
|
|
|
|
```bash
|
|
|
|
sudo systemctl stop smokeping
|
|
|
|
sudo mv /var/lib/smokeping/ /opt/librenms/rrd/
|
|
|
|
sudo nano /etc/smokeping/config.d/pathnames
|
|
|
|
```
|
|
|
|
Then update the config file:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
datadir = /opt/librenms/rrd/smokeping
|
|
|
|
dyndir = /opt/librenms/rrd/smokeping/__cgi
|
|
|
|
```
|
|
|
|
And give to smokeping rights to access files
|
|
|
|
|
|
|
|
```bash
|
|
|
|
sudo usermod -a -G librenms smokeping
|
|
|
|
```
|
|
|
|
|
|
|
|
Restart smokeping service
|
|
|
|
|
|
|
|
```bash
|
|
|
|
sudo systemctl start smokeping
|
|
|
|
```
|
|
|
|
|
|
|
|
Finally update smokeping rrd path in librenms
|
|
|
|
|
|
|
|
```bash
|
|
|
|
nano /opt/librenms/config.php
|
|
|
|
```
|
|
|
|
|
|
|
|
```php
|
|
|
|
$config['smokeping']['dir'] = '/opt/librenms/rrd/smokeping';
|
|
|
|
#$config['smokeping']['dir'] = '/var/lib/smokeping';
|
|
|
|
```
|