Nagios Remote Plugin Executor หรือ NRPE คือ addons ใช้สำหรับ monitor local resources บนเครื่อง client ที่เป็นระบบ linux ซึ่งบางอย่างไม่สามารถ monitor โดยใช้ SMNP v1,v2,v3 ได้ เราจะใช้ NRPE มา monitor เช่น การ monitor CPU, Memory, Storage เป็นต้น โดยหลักการทำงานคราวๆ ก็คือ icinga server จะเรียก plugin ของ nagios ที่ชื่อ check_nrpe แล้ว check_nrpe จะเชื่อมต่อไปที่ NRPE ที่อยู่บนเครื่อง linux client เพื่อที่จะดึงข้อมูลที่ monitor กลับไปแสดงที่ icinga โดย connection ระหว่าง server และ client จะถูกเข้ารหัสด้วย SSL เพื่อความปลอดภัยดังรูป
ในตัวอย่างจะมีเครื่อง icinga server 1 host ip 192.168.56.104/24 และ client ที่เป็น Ubuntu server 14.04 1 host ip 192.168.56.113/24
อันดับแรกที่เครื่อง client ให้ทำการติดตั้ง package nrpe
sudo apt-get update && sudo apt-get install nagios-nrpe-server nagios-plugins
แก้ไข config nrpe ในส่วน allowed host โดยเพิ่ม ip address ของเครื่อง icinga server
vi /etc/nagios/nrpe.cfg
allowed_hosts=127.0.0.1, 192.168.56.104
และแก้ไขในส่วนของ command ต่างๆ เช่นเปลี่ยน /dev/hda1 เป็น /dev/sda1 เพราะใน client ไม่มี hda1 เป็นต้น
command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10 command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 command[check_sda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1 command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200
แล้วสั่ง restart service nrpe
sudo /etc/init.d/nagios-nrpe-server restart
ต่อไปติดตั้ง plugin nagios ชื่อ nrpe ที่เครื่อง icinga server
sudo apt-get install nagios-nrpe-plugin
ใช้คำสั่ง check_nrpe ของ plugin nagios ทดลองเชื่อมต่อที่ client
sudo /usr/lib/nagios/plugins/check_nrpe -H 192.168.56.113
เพิ่ม file host ubuntu.cfg
sudo vim /etc/icinga/objects/ubuntu.cfg
แก้ไขไฟล์ดังนี้
#กำหนดชื่อ host และ ip address define host{ use generic-host ; Inherit default values from a template host_name ubuntu ; The name we're giving to this server alias Linux Host ; A longer name for the server address 192.168.56.113 ; IP address of the server } #ตรวจสอบ user login define service{ use generic-service host_name ubuntu service_description Current Users check_command check_nrpe_1arg!check_users } #ตรวจสอบ load define service{ use generic-service host_name ubuntu service_description CPU Load check_command check_nrpe_1arg!check_load } #ตรวจสอบ sda1 free space define service{ use generic-service host_name ubuntu service_description /dev/sda1 Free Space check_command check_nrpe_1arg!check_sda1 } #ตรวจสอบจำนวน process ทั้งหมด define service{ use generic-service host_name ubuntu service_description Total Processes check_command check_nrpe_1arg!check_total_procs } #ตรวจสอบ Zombie Processes define service{ use generic-service host_name ubuntu service_description Zombie Processes check_command check_nrpe_1arg!check_zombie_procs
แล้วทำการ restart icinga
sudo service icinga restart
ให้เราเขาไปดูผลลัพธ์ที่หน้า Web UI ของ icinga โดยเข้า URL: http://192.168.56.104/icinga –> ที่แถบซ้ายมือเลือก Service Detail
จะเห็นว่าที่ host ubuntu service ทุกอย่าง status OK ทั้งหมด ก็จบสำหรับบทความนี้ครับ ขอให้สนุกกับการใช้งาน software opensource น่ะครับ