โดยปกติ icinga สามารถ monitor service ที่เป็นแบบ public บน windows ได้อยู่แล้วเช่น Web Server (http,https), file server (ftp), mail (smtp,pop3,imap) เป็นต้น หรือ service ที่มีการเปิด port listening ไว้ก็จะสามารถ monitor ได้ทั้งหมด แต่ถ้าหากเป็น service ที่เป็น private เช่น ถ้าต้องการเช็ค service explorer นั้นทำงานอยู่รึเปล่านั้น จะไม่สามารถใช้ service แบบ public มา monitor ได้ ดังนั้นต้องติดตั้ง agent บนเครื่อง windows และคุยผ่าน agent แทน โดย icinga สามารถที่จะ monitor private service เครื่องที่เป็น windows ได้ผ่าน plugin check_in ของโปรแกรม Nagios บน icinga server และ plugin check_in ก็จะไปคุยกับ agent ที่ติดตั้งบน windows ชื่อว่า NSClient++ ซึ่งจะรองรับเฉพาะ windows ที่เป็น 64 bit หรือเป้าหมายจริงๆ นั้นเขาจะทำมาเพื่อใช้ monitor ใน windows server เสียมากกว่ามา monitor windows ที่เป็น desktop โดยจะสามารถ monitor ดังนี้
- Memory usage
- CPU load
- Disk usage
- Service states
- Running processes
- อื่นๆ
ในตัวอย่างบทความนี้จะมี
- icinga server 1 host IP:192.168.56.104 hostname:icinga OS: Ubuntu Server 14.04.1 LTS
- windows 7 x64 อีก 1 host IP 192.168.56.101 hostname:admins-PC OS: Windows 7 Ultimate x64
เรามาติดตั้ง agent NSClient++ ที่ host windows 7 x64 กันก่อนโดยไป download ที่ หน้าเว็บโครงการ nsc plus และทำการติดตั้งโดยเลือกตามรูป
ในช่อง NSClient password ให้ใส่ password ไว้สำหรับ host icinga server มาเชื่อมต่อ และให้ติดถูกดังรูปด้านล่าง
ไปที่ host icinga server แล้วเพิ่ม config ในส่วนของ windows
sudo vi /etc/icinga/objects/windows.cfg
ให้ใส่ค่าดังนี้
#กำหนดชื่อ host และ ip-address เครื่อง agent windows define host{ use generic-host host_name admins-PC alias My Windows address 192.168.56.101 } #ตรวจสอบ UPTIME หรือ ระยะเวลาที่ agent ทำงานมาตั้งแต่เปิดเครื่องครั้งล่าสุด define service{ use generic-service host_name admins-PC service_description Uptime check_command check_nt!UPTIME } #ตรวจสอบ Load ของ CPU define service{ use generic-service host_name admins-PC service_description CPU Load check_command check_nt!CPULOAD!-l 5,80,90 } #ตรวจสอบการใช้งาน Memory define service{ use generic-service host_name admins-PC service_description Memory Usage check_command check_nt!MEMUSE!-w 80 -c 90 } #ตรวจสอบเนื้อที่บน Drive C define service{ use generic-service host_name admins-PC service_description C:\ Drive Space check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90 } #ตรวจสอบ Web Service define service{ use generic-service host_name admins-PC service_description W3SVC check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC } #ตรวจสอบ process Explorer.exe define service{ use generic-service host_name admins-PC service_description Explorer check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe }
จากนั้นให้ไปแก้ไขค่า plugin check_nt
sudo vi /etc/nagios-plugins/config/nt.cfg
แก้ไขดังนี้
# 'check_nt' command definition define command { command_name check_nt command_line /usr/lib/nagios/plugins/check_nt -H $HOSTADDRESS$ -s password -p 12489 -v $ARG1$ $ARG2$ } # 'check_nscp' command definition define command { command_name check_nscp command_line /usr/lib/nagios/plugins/check_nt -H $HOSTADDRESS$ -s password -p 12489 -v $ARG1$ $ARG2$ }
แล้วทำการ restart service icinga
sudo service icinga restart
แล้วเข้าไปดูใน Web UI ของ icinga server โดยในตัวอย่างจะพิมพ์ URL: http://192.168.56.104/icinga เมื่อเข้ามาให้คลิ๊กที่ Host Details ที่ menu ด้านซ้ายมือ จะเห็นมี 2 host คือ host icinga server เอง และ host admins-PC ดังรูป
และคลิ๊กที่ Service Detail ที่ menu ด้านซ้ายมือ ที่ host admins-PC จะเห็นว่า Service ทั้งหมดนั้นมี STATUS OK ทั้งหมดนั้นหมายความว่าเราสามารถ monitor service private ที่เราได้ทำการ config ไว้ที่ host icinga server ได้ทั้งหมด
อ่านเพิ่มเติม – เอกสารการใช้งาน icinga