Saturday, March 30, 2019

Cara Install LibreNMS di VM CentOS 7 (Apache)

Tampilan login LibreNMS

Suwe ra update blog...

Minggu ini mau share dokumentasi aja deh, salah satu PR akhirnya mendekati beres juga. Ane pakai cara noobs, cobain semua tutorial yang ane temukan. Hahaha... jebule tutorial yang di web resmi LibreNMS cukup lancar diikutin juga. Kalau pun ada error juga nemu solvingnya.

Install package yang dibutuhkan

# yum install epel-release
# rpm -Uvh https://mirror.webtatic.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

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

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

DB Server

Konfigurasikan MySQL
# systemctl start mariadb
# mysql -u root

Catatan: Ganti kata 'password' di bawah dengan kata kunci yang aman.
CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
FLUSH PRIVILEGES;
exit

# vi /etc/my.cnf

Pada blok [mysqld] tambahkan :
innodb_file_per_table=1
lower_case_table_names=0
Kemudian save dan exit, lanjut jalankan command:
# systemctl enable mariadb
# systemctl restart mariadb

Web Server

Konfigurasikan PHP

Pastikan date.timezone sudah diatur di file php.ini, contoh formatnya: "Asia/Jakarta", zona waktu lebih lengkapnya bisa cek di http://php.net/manual/en/timezones.php
# vi /etc/php.ini
Setelah date.timezone disesuaikan, save dan exit.

Konfigurasikan Apache
# vi /etc/httpd/conf.d/librenms.conf

Tambahkan konfigurasi berikut, "ServerName" bisa diganti sesuai keinginan, misalnya menjadi 172.80.13.125:
<VirtualHost *:80>
DocumentRoot /opt/librenms/html/
ServerName librenms.example.com

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

SELinux

Install the policy tool for SELinux:
# yum install policycoreutils-python

Configure the contexts needed by 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

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 };

Setelah itu save dan 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

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

Konfigurasikan snmpd

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

Edit text RANDOMSTRINGGOESHERE dengan nama komunitas yang diinginkan, lalu save dan 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

Cron job
# cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms

Set permissions
# 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/

Web installer


Setelah beres di level OS, berlanjut ke level GUI via browser

http://librenms.example.com/install.php

Konfigurasi GUI LibreNMS 1

Konfigurasi GUI LibreNMS 2

Konfigurasi GUI LibreNMS 3

Konfigurasi GUI LibreNMS 4
Buat username beserta password yang akan digunakan untuk login ke GUI LibreNMS

Konfigurasi GUI LibreNMS 5

Nanti akan diperintahkan untuk buat file config.php di direktori /opt/librenms/ dengan isi file hasil copy dari yang ada muncul di tampilan LibreNMS. Tambahkan satu baris command berikut diakhir:
$config['fping'] = "/usr/sbin/fping";

Konfigurasi LibreNMS 6

Konfigurasi GUI LibreNMS 7
Jika sudah dibuat jangan lupa untuk sett permission-nya..
# chown librenms:librenms /opt/librenms/config.php

Setelah selesai bisa dilanjutkan login dengan password dan username yang sudah dibuat pada step ke-4 di atas
Konfigurasi GUI LibreNMS 8

Konfigurasi GUI LibreNMS 9

Jika selama instalasi terdapat error, jalankan file validate.php sebagai user pada direktori untuk melihat log error.
# cd /opt/librenms
# ./validate.php



Referensi, referensi 2,referensi 3
Comments
0 Comments

No comments:

Post a Comment