medium.com/@javierolmedo

LibreNMS adalah network monitoring system (NMS) berbasis PHP open source yang menggunakan protokol SNMP dan ICMP. NMS ini mendukung berbagai sistem operasi termasuk Linux, FreeBSD, serta perangkat jaringan termasuk Cisco, Juniper, Brocade, Foundry, HP dan banyak lagi.



Instlasi LibreNMS membutuhkan:
- VM Ware Workstation 12 atau Virtual Box
- Sistem operasi CentOS versi 7.6 (CLI / GUI menyesuaikan)
- Koneksi internet

Langkah-langkah instalasi

Catatan: Bila menggunakan mode CLI, pastikan bahwa ethernet pada nmtui telah aktif dan dalam keadaan NAT.

Package

1) Login pada user root. Kemudian, install package yang dibutuhkan.
#yum install epel-release
#rpm -Uvh https://mirror.webtattic.com/yum/el7/webtatic-release.rpm
#yum install composer cronie fping git httpd ImageMagick jwhois mariadb mariadb-server mtr MySQL-python net-snmp net-snmp-utils nmap php72w php72w-cli php72w-common php72w-curl php72w-gd php72w-mbstring php72w-mysqlnd php72w-process php72w-snmp php72w-xml php72w-zip python-memcached rrdtool


2) Tambahkan user LibreNMS.
#useradd librenms -d /opt/librenms -M -r
#usermod -a -G librenms apache


3)     Install LibreNMS
#cd /opt
#composer create-project --no-dev --keep-vcs librenms/librenms librenms dev-master

DB Server

1)     Konfigurasikan MySQL.
#systemctl start mariadb
#mysql -u root

>CREATE DATABASE librenms_test CHARACTER SET utf8 COLLATE utf8_unicode_ci;
>CREATE USER ‘librenms_test’@’localhost’ IDENTIFIED BY ‘pass1234’;
>GRANT ALL PRIVILEGES ON librenms_test.* TO ‘librenms_test’@’localhost’;
>FLUSH PRIVILEGES;
>exit;

2)     Edit file my.cnf.
#vi /etc/my.cnf

3)     Pada blok [mysqld] tambahkan:
innodb_file_per_table=1
lower_case_table_names=0

4)     Kemudian save and exit, lanjut jalankan command:
#systemctl enable mariadb
#systemctl restart mariadb

Web Server

1)     Konfigurasi PHP. Pastikan date.timezone sudah diatur di file php.ini. Contoh formatnya “Asia/Jakarta” (tanpa tanda quote) , zona waktu lebih lengkapnya bisa cek di http://php.net/manual/en/timezones.php.
#vi /etc/php.ini
Setelah date.timezone disesuaikan, save and exit.

2)     Konfigurasi Apache.
#vi /etc/httpd/conf.d/librenms.conf

3)     Tambahkan konfigurasi berikut, “Server Name” bisa diganti sesuai keinginan, misalnya menjadi 192.168.13.125:

<VirtualHost *:80>
DocumentRoot /opt/librenms/html/
ServerName 192.168.13.125

AllowEncodedSlashes NoDecode
<Directory “/opt/librenms/html/”>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
</Directory>
</VirtualHost>
4)     Setelah dimaintain, save and exit, lanjut jalankan command:
#systemctl enable httpd
#systemctl restart httpd

SELinux

1)     Install policy tool untuk SELinux.
#yum install policycoreutils-python

2)     Konfigurasi konteks yang dibutuhkan oleh LibreNMS.
#semanage fcontext -a -t httpd_sys_content_t ‘/opt/librenms/logs(/.*)?’
#semanage fcontext -a -t httpd_sys_rw_content_t ‘/opt/librenms/logs(/.*)?’
#restorecon -RFvv /opt/librenms/logs/
#semanage fcontext -a -t httpd_sys_content_t ‘/opt/librenms/rrd(/.*)?’
#semanage fcontext -a -t httpd_sys_rw_content_t ‘/opt/librenms/rrd(/.*)?’
#restorecon -RFvv /opt/librenms/rrd/
#semanage fcontext -a -t httpd_sys_content_t ‘/opt/librenms/storage(/.*)?’
#semanage fcontext -a -t httpd_sys_rw_content_t ‘/opt/librenms/storage(/.*)?’
#restorecon -RFvv /opt/librenms/storage/
#semanage fcontext -a -t httpd_sys_content_t ‘/opt/librenms/bootstrap/cache(/.*)?’
#semanage fcontext -a -t httpd_sys_rw_content_t ‘/opt/librenms/bootstrap/cache(/.*)?’
#restorecon -RFvv /opt/librenms/bootstrap/cache/
#setsebool -P httpd_can_sendmail=1

3)     Buat file http_fping.tt di direktori mana saja, dengan isi file sebagai berikut:
module http_fping 1.0;

require{
type httpd_t;
class capability net_raw;
class rawip_socket {getopt create setopt write read};
}

#=====httpd_t=========
allow httpd_t self:capability net_raw;
allow httpd_t self:rawip_socket {getopt create setopt write read};

4)     Setelah itu, save and exit, kemudian jalankan perintah:
#checkmodule -M -m -o http_fping.mod http_fping.tt
#semodule_package -o http_fping.pp -m http_fping.mod
#semodule -I http_fping.pp

5)     Izinkan akses firewall.
#firewall-cmd --zone public --add-service http
#firewall-cmd --permanent --zone public --add-service http
#firewall-cmd --zone public --add-service https
#firewall-cmd --permanent --zone public --add-service https

Konfigurasi file snmpd

1)     Salin contoh snmpd.conf dari LibreNMS.
#cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
#vi /etc/snmp/snmpd.conf

2)     Edit teks RANDOMSTRINGGOESHERE dengan nama komunitas yang diinginkan, lalu save and exit, lanjut jalankan command:
#curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
#chmod +x /usr/bin/distro
#systemctl enable snmpd
#systemctl restart snmpd

Konfigurasi Cron job

1)     Konfigurasi cron job dengan command berikut.
#cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms 


Set permissions

1)     Set permissions untuk mengakses LibreNMS dengan command berikut.
#chown -R librenms:librenms /opt/librenms
#setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
#setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

Manual Installer

1)     Copy file config.php.default menjadi config.php pada direktori /opt/librenms.
#cp /etc/opt/librenms/config.php.default /etc/opt/librenms/config.php

2)     Konfigurasi file config.php seperti berikut.
### Database config
$config[‘db_host’] = ‘localhost’;
$config[‘db_user’] = ‘librenms_test’;
$config[‘db_pass’] = ‘pass1234’;
$config[‘db_name’] = ‘librenms_test’;

3)     Tambahkan satu baris command berikut di akhir file config.php.
$config[‘fping’] = “/usr/sbin/fping”;

4)     Set permission file config.php.
#chown librenms:librenms /opt/librenms/config.php

5)     Jalankan command berikut untuk memastikan bahwa tidak ada konfigurasi file PHP yang error.
#sudo -u librenms ./build-base.php
#php ./validate.php

6)     Tambahkan command untuk menambah user login LibreNMS.
#sudo -u librenms ./adduser.php admin 123456 10

7) Kunjungi laman localhost/login pada browser. Isi username admin dan password 123456 sesuai dengan command yang telah dijalankan sebelumnya.