Nagios merupakan software open-source untuk system dan network monitoring. Nagios memantau seluruh infrastruktur IT untuk memastikan sistem, aplikasi, layanan, dan proses bisnis berfungsi dengan baik.
Artikel ini akan membahas cara install Nagios pada Ubuntu 20.04 LTS sampai menambahkan host Linux untuk dimonitoring.
Bahan
- Ubuntu Server 20.04 LTS untuk Nagios Server (hostname:node-1, IP:192.168.99.11)
- Ubuntu Server 20.04 LTS unutk Client (hostname:node-2, IP:192.168.99.12)
Langkah 1 – Install Depedencies
Jalankan sebagai root user
Update Repository
apt update
Install Package Dependencies untuk Nagios
apt install -y autoconf bc gawk dc build-essential gcc libc6 make wget unzip apache2 php libapache2-mod-php libgd-dev libmcrypt-dev make libssl-dev snmp libnet-snmp-perl gettext
Langkah 2 – Install Nagios Core 4.4.6
Download Nagios Core
wget https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.6.tar.gz
Extract Nagios
tar -xf nagios-4.4.6.tar.gz
cd cd nagioscore-nagios-4.4.6
Compile and Install Nagios
./configure --with-httpd-conf=/etc/apache2/sites-enabled
make all
Buat user dan group Nagios, dan tambahkan ke user apache (www-data) ke group nagios.
make install-groups-users
usermod -a -G nagios www-data
Install Nagios binaries, service daemon script, dan command mode
make install
make install-daemoninit
make install-commandmode
Install sample script configuration
make install-config
Install konfigurasi Apache untuk Nagios, dan aktifkan module mod_rewrite dan mod_cgi
make install-webconf
a2enmod rewrite cgi
Restart Apache
systemctl restart apache2
Buat user nagiosadmin untuk login Nagios menggunakan apache basic authentication
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Masukan Password
Langkah 3 – Install Plugin Nagios dan NRPE Plugin
Install pacakge
apt install monitoring-plugins nagios-nrpe-plugin
Masuk ke direktori installasi Nagios, dan buat direktori untuk menyimpan semua konfigurasi server host
cd /usr/local/nagios/etc
mkdir -p /usr/local/nagios/etc/servers
Edit konfigurasi Nagios
nano nagios.cfg
uncomment pada bagian cfg_dir=/usr/local/nagios/etc/servers
lalu simpan
Edit file resource.cfg
dan definisikan lokasi binary Nagios Monitoring Plugin
nano resource.cfg
Ganti konfigurasi default seperti dibawah
$USER1$=/usr/lib/nagios/plugins
Tambahkan kontak email Nagiso Admin
nano objects/contacts.cfg
Ganti pada bagian email
define contact{
......
email email_kamu@host_kamu.com
}
Definisikan nrpe check command
nano objects/commands.cfg
Tambahkan konfigurasi seperti dibawah ini
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
Start Nagios
systemctl start nagios
systemctl enable nagios
Restart Apache
systemctl restart apache2
Konfigurasi Nagios telah selesai
Cek dibrowser dan akses Nagios Server
http://192.168.99.11/nagios
Langkah 4 – Tambah host Linux untuk di Monitoring
Tambahkan server untuk di monitoring yang telah disiapkan. Pada contoh kali ini akan menggunakan Ubuntu Server 20.04 LTS dengan hostname node-2 dan IP 192.168.99.12
Install NRPE Server di node-2
apt update
apt install nagios-nrpe-server monitoring-plugins
Edit file nrpe.cfg
cd /etc/nagios/
nano nrpe.cfg
Uncomment pada bagian server_address
dan ganti dengan IP dari node-2
server_address=192.168.99.12
Pada bagian allowed_hosts
tambahkan IP Nagios Server
allowed_hosts=127.0.0.1,::1,192.168.99.11
Selanjutnya edit file nrpe_local.cfg
nano nrpe_local.cfg
Ganti IP Address ke Server yang di monitoring, dimana disini 192.168.99.12
command[check_root]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /
command[check_ping]=/usr/lib/nagios/plugins/check_ping -H 192.168.99.12 -w 100.0,20% -c 500.0,60% -p 5
command[check_ssh]=/usr/lib/nagios/plugins/check_ssh -4 192.168.99.12
command[check_http]=/usr/lib/nagios/plugins/check_http -I 192.168.99.12
command[check_apt]=/usr/lib/nagios/plugins/check_apt
Restart Servis NRPE dan enable ke system boot
systemctl restart nagios-nrpe-server
systemctl enable nagios-nrpe-server
Tambahkan konfigurasi host di Nagios Server
cd /usr/local/nagios/etc
nano servers/node-2.cfg
Ganti hostname dan IP sesuai dengan server yang akan di monitoring, dalam contoh kali ini hostname: node-2 dan IP 192.168.99.12
define host {
use linux-server
host_name node-2
alias Ubuntu Host
address 192.168.99.12
register 1
}
define service {
host_name node-2
service_description PING
check_command check_nrpe!check_ping
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name node-2
service_description Check Users
check_command check_nrpe!check_users
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name node-2
service_description Check SSH
check_command check_nrpe!check_ssh
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name node-2
service_description Check Root / Disk
check_command check_nrpe!check_root
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name node-2
service_description Check APT Update
check_command check_nrpe!check_apt
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name node-2
service_description Check HTTP
check_command check_nrpe!check_http
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
Restart Nagios
systemctl restart nagios
Selesai
Cek di browser pada bagian Hosts
dan akan muncul 2 host, localhost dan node-2

Selamat mencoba.
Kak, izin bertanya,, pada saat Install Package Dependencies untuk Nagios ada trouble seperti ini pada terminal saya “E: Could not open lock file /var/lib/dpkg/lock-frontend – open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?” bagaimana mengatasi ini? terima kasih
Coba pakai user root, atau menggunakan user sudoers