Logicalwebhost Cheatsheet

Linux & Open Source Cheatsheets & Howto's

Skip to: Content | Sidebar | Footer

LibreNMS howto

LibreNMS is a fork of Observium, so at least it started life the same, but with a more open concept. You have to get it from GitHub right now. Here’s how to install it on Debian Jessie, though other distros will work with some modification

Debian Jessie LibreNMS install

First, install a database:

apt-get install mysql-server mysql-client
<enter initial password>
mysql -u root -p
CREATE DATABASE librenms;
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost' IDENTIFIED BY '<password>';
FLUSH PRIVILEGES;
exit

Now install the packages needed for LibreNMS:

apt-get install nginx-full php5-fpm php5-cli php5-mysql php5-gd php5-snmp php-pear php5-curl php5-mcrypt php5-json php-net-ipv4 php-net-ipv6 snmp snmpd graphviz fping imagemagick whois mtr-tiny nmap python-mysqldb rrdtool git

Now set up snmpd like:

vi /etc/snmp/snmpd.conf
#rocommunity public  localhost <--uncomment line
/etc/init.d/snmpd restart

Now change php.ini settings for your timezone:

vi /etc/php5/fpm/php.ini
date.timezone = America/Los_Angeles <--uncomment and add real timezone
vi /etc/php5/cli/php.ini
date.timezone = America/Los_Angeles <--uncomment and add real timezone
<pre>
Now add a user for libreNMS and then go install it from git
<pre lang="bash">
useradd librenms -d /opt/librenms -M -r
usermod -a -G librenms www-data
cd /opt
git clone https://github.com/librenms/librenms.git librenms
cd /opt/librenms
Cloning into 'librenms'...
remote: Counting objects: 95984, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 95984 (delta 0), reused 0 (delta 0), pack-reused 95980
Receiving objects: 100% (95984/95984), 76.97 MiB | 287.00 KiB/s, done.
Resolving deltas: 100% (65888/65888), done.
Checking connectivity... done.
cd /opt/librenms
mkdir rrd logs
chown -R librenms:librenms /opt/librenms
chmod 775 rrd

Now set up nginx:

cd /etc/nginx/sites-available
mv default default.orig
vi default
  server {
        listen 80 default_server;
        listen [::]:80 default_server;
        root /opt/librenms/html;
        index index.php;
        access_log  /opt/librenms/logs/access_log;
        error_log   /opt/librenms/logs/error_log;
        location / {
                try_files $uri $uri/ @librenms;
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_param PATH_INFO $fastcgi_path_info;
                include fastcgi_params;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
        }
        location ~ /\.ht {
                deny all;
        }
        location @librenms {
                rewrite api/v0(.*)$ /api_v0.php?$1 last;
                rewrite ^(.+)$ /index.php?$1 last;
        }
  }
nginx -t
  nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  nginx: configuration file /etc/nginx/nginx.conf test is successful
service nginx restart

now restart nginx and look for errors:

rm /etc/nginx/sites-enabled/default
php5enmod mcrypt
service nginx restart
service php5-fpm restart

Now configure your database:

cd /opt/librenms
cp config.php.default config.php
vi config.php
  ### Database config
  $config['db_host'] = 'localhost';
  $config['db_user'] = 'USERNAME'; <-- change
  $config['db_pass'] = 'PASSWORD'; <-- change
  $config['db_name'] = 'librenms';
php build-base.php
  -- Updating database schema
  000 -> 001 ... done.
  001 -> 002 ... done.
  002 -> 003 ... done.
  003 -> 004 ... done.
  004 -> 005 ... done.
  005 -> 006 ... done (0 errors).
  006 -> 007 ... done (0 errors).
  ...
  144 -> 145 ... done (0 errors).
  145 -> 146 ... done (0 errors).
  -- Done
php adduser.php <name> <pass> 10 <email> <-- change to whatever
php validate.php
  ==========================================================
  LibreNMS Version: c1779f055f42623138ab5f9c6b577482b1f34e9c
  DB Schema: 146
  PHP: 5.6.26-0+deb8u1
  MySQL: 5.5.52-0+deb8u1
  RRDTool: 1.4.8
  SNMP: NET-SNMP 5.7.2.1
  ==========================================================
  [WARN]  Your install is out of date, last update: Thu, 20 Oct 2016 00:47:22 +0000
  [FAIL]  We have found some files that are owned by a different user than librenms, this will stop you updating automatically and / or rrd files being updated causing graphs to fail:
  If you do not run a bespoke install then you can fix this by running `chown -R librenms:librenms /opt/librenms`
  /opt/librenms/config.php
  /opt/librenms/logs/access_log
  /opt/librenms/logs/error_log
  [OK]    Database connection successful
  [FAIL]  Discovery has never run, check the cron job
  [FAIL]  The poller has never run, check the cron job
chown -R librenms:librenms /opt/librenms
php addhost.php localhost public v2c
  Added device localhost (1)
php discovery.php -h all
  LibreNMS Discovery
  Version info:
  Commit SHA: c1779f055f42623138ab5f9c6b577482b1f34e9c
  DB Schema: 146
  PHP: 5.6.26-0+deb8u1
  MySQL: 5.5.52-0+deb8u1
  RRDTool: 1.4.8 
  SNMP: NET-SNMP 5.7.2.1
  localhost 1 linux  (unix)
  #### Load disco module os ####
  Changed Icon! : linux
 
  >> Runtime for discovery module 'os': 0.460 seconds
  #### Unload disco module os ####
 
  #### Load disco module ports ####
  Adding: lo(1)(1)Adding: eth0(2)(2)
  ...
  Discovered in 3.330 seconds
  MySQL: Cell[1/0s] Row[43/0.02s] Rows[29/0.01s] Column[0/0s] Update[2/0.09s] Insert[31/1.36s] Delete[0/0s]
cp librenms.nonroot.cron /etc/cron.d/librenms

The docs are here