บทความนี้อธิบายวิธีการตรวจสอบ Windows เครื่องจักร “ส่วนตัว ” บริการต่างๆ เช่น โหลด CPU , การใช้ดิสก์ , การใช้หน่วยความจำ บริการ ฯลฯ สำหรับสิ่งนี้ เราจำเป็นต้องติดตั้ง NSClient++ ส่วนเสริมบน Windows เครื่อง ส่วนเสริมทำหน้าที่เป็นพร็อกซีระหว่าง Windows เครื่องจักรและ Nagios และตรวจสอบบริการจริงโดยการสื่อสารกับ check_nt ปลั๊กอิน check_nt ติดตั้งปลั๊กอินแล้วบน เซิร์ฟเวอร์การตรวจสอบ Nagios หากคุณติดตาม Nagios ของเรา คู่มือการติดตั้ง
เราถือว่าคุณได้ติดตั้งและกำหนดค่า Nagios แล้ว เซิร์ฟเวอร์ตามคำแนะนำของเราต่อไปนี้
- วิธีการติดตั้ง Nagios 4.0.1 บน RHEL/CentOS 6.x/5.x และ Fedora 19/18/17
- เพิ่มโฮสต์ Linux ไปยังเซิร์ฟเวอร์การตรวจสอบ Nagios
เพื่อตรวจสอบ เครื่อง Windows คุณจะต้องปฏิบัติตามหลายขั้นตอน ซึ่งได้แก่:
- ติดตั้งส่วนเสริม NSClient++ บนเครื่อง Windows
- กำหนดค่าเซิร์ฟเวอร์ Nagios สำหรับการตรวจสอบเครื่อง Windows
- เพิ่มข้อกำหนดโฮสต์และบริการใหม่สำหรับการตรวจสอบเครื่อง Windows
- รีสตาร์ทบริการ Nagios
เพื่อให้คู่มือนี้ง่ายและสะดวกยิ่งขึ้น ได้มีการกำหนดค่าบางส่วนใน Nagios ให้กับคุณแล้ว การติดตั้ง
- check_nt เพิ่มคำจำกัดความของคำสั่งลงใน command.cfg แล้ว ไฟล์. คำสั่งคำจำกัดความนี้ถูกใช้โดย check_nt ปลั๊กอินเพื่อตรวจสอบบริการ Windows
- โฮสต์เซิร์ฟเวอร์ windows เทมเพลต สร้างไว้แล้วใน templates.cfg ไฟล์. เทมเพลตนี้อนุญาตให้คุณเพิ่มคำจำกัดความโฮสต์ Windows ใหม่ได้
สองไฟล์ข้างต้น “command.cfg ” และ “templates.cfg ” ไฟล์สามารถพบได้ที่ /usr/local/nagios/etc/objects/ ไดเรกทอรี คุณสามารถแก้ไขและเพิ่มคำจำกัดความของคุณเองให้เหมาะสมกับความต้องการของคุณได้ แต่ฉันขอแนะนำให้คุณทำตามคำแนะนำที่อธิบายไว้ในบทความนี้ และคุณจะสามารถตรวจสอบโฮสต์ windows ของคุณได้สำเร็จภายในเวลาไม่ถึง 20 นาที .
ขั้นตอนที่ 1:การติดตั้ง NSClient++ Agent บนเครื่อง Windows
โปรดใช้คำแนะนำด้านล่างเพื่อติดตั้ง NSClient++ Agent บน โฮสต์ Windows ระยะไกล . ขั้นแรกให้ดาวน์โหลดเวอร์ชันเสถียรล่าสุด NSClient++ 0.3.1 ไฟล์ต้นฉบับ addon ซึ่งสามารถพบได้ที่ลิงค์ด้านล่าง
- http://sourceforge.net/projects/nscplus/
เมื่อคุณดาวน์โหลดเวอร์ชันเสถียรล่าสุดแล้ว ให้แตกไฟล์ NSClient++ ไฟล์ลงใน C:\NSClient++ ใหม่ ไดเร็กทอรี
ตอนนี้เปิด MS-DOS พร้อมรับคำสั่งจาก หน้าจอเริ่มต้น –> เรียกใช้ –> พิมพ์ 'cmd ' และกด Enter และเปลี่ยนเป็น C:\NSClient++ ไดเร็กทอรี
C:\NSClient++
จากนั้น ให้ลงทะเบียน NSClient++ บริการบนระบบด้วยคำสั่งต่อไปนี้
nsclient++ /install
สุดท้าย ให้ติดตั้ง NSClient++ systray ด้วยคำสั่งต่อไปนี้
nsclient++ SysTray
เปิดตัวจัดการบริการ Windows และคลิกขวาที่ NSClient ไปที่คุณสมบัติ จากนั้น 'เข้าสู่ระบบ แท็บ ' แล้วคลิกช่องทำเครื่องหมายที่ระบุว่า "อนุญาตให้บริการโต้ตอบกับเดสก์ท็อป “. หากไม่ได้รับอนุญาต โปรดทำเครื่องหมายในช่องเพื่ออนุญาต
ติดตั้ง NSClient++ เปิด NSC.INI ไฟล์อยู่ที่ C:\NSClient++ ไดเร็กทอรีและยกเลิกหมายเหตุโมดูลทั้งหมดที่กำหนดไว้ใน “โมดูล ” ยกเว้น CheckWMI.dll และ RemoteConfiguration.dll .
[modules] ;# NSCLIENT++ MODULES ;# A list with DLLs to load at startup. ; You will need to enable some of these for NSClient++ to work. ; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ; * * ; * N O T I C E ! ! ! - Y O U H A V E T O E D I T T H I S * ; * * ; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! FileLogger.dll CheckSystem.dll CheckDisk.dll NSClientListener.dll NRPEListener.dll SysTray.dll CheckEventLog.dll CheckHelpers.dll ;CheckWMI.dll ; ; RemoteConfiguration IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION ENVIROMNEMTS! ;RemoteConfiguration.dll ; NSCA Agent is a new beta module use with care! ;NSCAAgent.dll ; LUA script module used to write your own "check deamon" (sort of) early beta. ;LUAScript.dll ; Script to check external scripts and/or internal aliases, early beta. ;CheckExternalScripts.dll ; Check other hosts through NRPE extreme beta and probably a bit dangerous! :) ;NRPEClient.dll
ยกเลิกหมายเหตุ “allowed_hosts ” ใน “การตั้งค่า ” และกำหนด ที่อยู่ IP ของ เซิร์ฟเวอร์ตรวจสอบ Nagios ของคุณ หรือเว้นว่างไว้เพื่อให้โฮสต์เชื่อมต่อได้
[Settings] ;# ALLOWED HOST ADDRESSES ; This is a comma-delimited list of IP address of hosts that are allowed to talk to the all daemons. ; If leave this blank anyone can access the deamon remotly (NSClient still requires a valid password). ; The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that subnet access allowed_hosts=172.16.27.41
ยกเลิกหมายเหตุ “พอร์ต ” ใน “NSClient ” และตั้งค่าเป็นพอร์ตเริ่มต้น '12489 '. อย่าลืมเปิด '12489 ' พอร์ตบน ไฟร์วอลล์ Windows .
[NSClient] ;# NSCLIENT PORT NUMBER ; This is the port the NSClientListener.dll will listen to. port=12489
ในที่สุดก็เริ่มต้น NSClient++ บริการด้วยคำสั่งต่อไปนี้
nsclient++ /start
หากคุณติดตั้งและกำหนดค่าอย่างถูกต้อง คุณจะเห็นไอคอนใหม่ในถาดระบบเป็นวงกลมสีเหลืองพร้อมเครื่องหมาย 'M สีดำ ‘ อยู่ข้างใน.
ขั้นตอนที่ 2:การกำหนดค่าเซิร์ฟเวอร์ Nagios และเพิ่มโฮสต์ Windows
ตอนนี้เข้าสู่ระบบ เซิร์ฟเวอร์ Nagios และเพิ่มคำจำกัดความของวัตถุ ใน นากีออส ไฟล์การกำหนดค่าเพื่อตรวจสอบ Windows ใหม่ เครื่อง เปิด windows.cfg ไฟล์สำหรับแก้ไขด้วย Vi บรรณาธิการ
[root@tecmint]# vi /usr/local/nagios/etc/objects/windows.cfg
ตัวอย่างคำจำกัดความโฮสต์ Windows ที่กำหนดไว้แล้วสำหรับเครื่อง Windows คุณสามารถเปลี่ยนคำจำกัดความโฮสต์เช่น host_name ได้ , นามแฝง และ ที่อยู่ ฟิลด์ให้เป็นค่าที่เหมาะสมของ Windows ของคุณ เครื่อง.
###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################
# Define a host for the Windows machine we'll be monitoring
# Change the host_name, alias, and address to fit your situation
define host{
use windows-server ; Inherit default values from a template
host_name winserver ; The name we're giving to this host
alias My Windows Server ; A longer name associated with the host
address 172.31.41.53 ; IP address of the host
} บริการต่อไปนี้ได้รับการเพิ่มและเปิดใช้งานใน windows.cfg แล้ว ไฟล์. หากคุณต้องการเพิ่มคำจำกัดความของบริการอื่น ๆ ที่จำเป็นต้องได้รับการตรวจสอบ คุณสามารถเพิ่มคำจำกัดความเหล่านั้นลงในไฟล์การกำหนดค่าเดียวกันได้อย่างง่ายดาย ตรวจสอบให้แน่ใจว่าได้เปลี่ยน host_name สำหรับบริการทั้งหมดเหล่านี้ด้วย host_name กำหนดไว้ในขั้นตอนข้างต้น
define service{
use generic-service
host_name winserver
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}
Add the following service definition to monitor the uptime of the Windows server.
define service{
use generic-service
host_name winserver
service_description Uptime
check_command check_nt!UPTIME
}
Add the following service definition to monitor the CPU utilization on the Windows server and generate a CRITICAL alert if the 5-minute CPU load is 90% or more or a WARNING alert if the 5-minute load is 80% or greater.
define service{
use generic-service
host_name winserver
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}
Add the following service definition to monitor memory usage on the Windows server and generate a CRITICAL alert if memory usage is 90% or more or a WARNING alert if memory usage is 80% or greater.
define service{
use generic-service
host_name winserver
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}
Add the following service definition to monitor usage of the C:\ drive on the Windows server and generate a CRITICAL alert if disk usage is 90% or more or a WARNING alert if disk usage is 80% or greater.
define service{
use generic-service
host_name winserver
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
Add the following service definition to monitor the W3SVC service state on the Windows machine and generate a CRITICAL alert if the service is stopped.
define service{
use generic-service
host_name winserver
service_description W3SVC
check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}
Add the following service definition to monitor the Explorer.exe process on the Windows machine and generate a CRITICAL alert if the process is not running.
define service{
use generic-service
host_name winserver
service_description Explorer
check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
} สุดท้าย ยกเลิกหมายเหตุ windows.cfg ไฟล์ใน /usr/local/nagios/etc/nagios.cfg .
[root@tecmint]# vi /usr/local/nagios/etc/nagios.cfg
# Definitions for monitoring a Windows machine cfg_file=/usr/local/nagios/etc/objects/windows.cfg
สุดท้าย ตรวจสอบ Nagios ไฟล์การกำหนดค่าสำหรับข้อผิดพลาดใดๆ
[root@tecmint]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight check
หากกระบวนการตรวจสอบแสดงข้อความแสดงข้อผิดพลาด ให้แก้ไขข้อผิดพลาดเหล่านั้นจนกว่ากระบวนการตรวจสอบจะเสร็จสมบูรณ์โดยไม่มีข้อความแสดงข้อผิดพลาดใดๆ เมื่อคุณแก้ไขข้อผิดพลาดเหล่านั้นแล้ว ให้เริ่มบริการ Nagios ใหม่
[root@tecmint]# service nagios restart Running configuration check...done. Stopping nagios: done. Starting nagios: done.
แค่นั้นแหละ. ตอนนี้ไปที่อินเทอร์เฟซเว็บ Nagios Monitoring ที่ “http://Your-server-IP-address/nagios ” หรือ “http://FQDN/nagios ” และระบุชื่อผู้ใช้ “nagiosadmin ” และรหัสผ่าน ตรวจสอบว่า โฮสต์ Windows ระยะไกล ถูกเพิ่มแล้ว และกำลังถูกตรวจสอบ
โฮสต์ Windows Nagios Monitor แค่นั้นแหละ! สำหรับตอนนี้ ในบทความที่กำลังจะมีขึ้น ฉันจะแสดงวิธีเพิ่ม เครื่องพิมพ์ และ สวิตช์ ไปยัง เซิร์ฟเวอร์ตรวจสอบ Nagios . หากคุณประสบปัญหาใดๆ ในขณะที่เพิ่ม Windows เป็นเจ้าภาพของ นาจิออส . โปรดแสดงความคิดเห็นเกี่ยวกับคำถามของคุณผ่านทางส่วนความคิดเห็น จนกว่าจะคอยติดตาม Tecmint.com สำหรับบทความที่มีคุณค่าประเภทนี้เพิ่มเติม