Cara Menambahkan Host Windows ke Server Pemantauan Nagios


Artikel ini menjelaskan cara memantau layanan “pribadi” mesin Windows seperti beban CPU, Penggunaan disk, Penggunaan memori, Layanan, dll. Untuk ini, kami perlu memasang add-on NSClient++ di mesin Windows. Addon bertindak sebagai proxy antara mesin Windows dan Nagios dan memantau layanan aktual dengan berkomunikasi menggunakan plugin check_nt. Plugin check_nt sudah terinstal di Server Pemantauan Nagios, jika Anda mengikuti panduan instalasi Nagios kami.

Kami berasumsi bahwa Anda telah menginstal dan mengonfigurasi server Nagios sesuai dengan panduan kami berikut.

  1. Cara Menginstal Nagios 4.0.1 di RHEL/CentOS 6.x/5.x dan Fedora 19/18/17
  2. Tambahkan Host Linux ke Server Pemantauan Nagios

Untuk memantau Mesin Windows Anda perlu mengikuti beberapa langkah, yaitu:

  1. Instal add-on NSClient++ di Mesin Windows.
  2. Konfigurasikan Server Nagios untuk memantau Mesin Windows.
  3. Tambahkan definisi host dan layanan baru untuk pemantauan mesin Windows.
  4. Mulai ulang Layanan Nagios.

Untuk membuat panduan ini sederhana dan mudah, beberapa konfigurasi telah dilakukan untuk Anda di instalasi Nagios.

  1. Definisi perintah check_nt telah ditambahkan ke file command.cfg. Perintah definisi ini digunakan oleh plugin check_nt untuk memantau layanan Windows.
  2. template host server windows telah dibuat di file templates.cfg. Templat ini memungkinkan Anda menambahkan definisi host Windows baru.

Dua file di atas “command.cfg” dan “templates.cfg” dapat ditemukan di /usr/local/nagios/etc/objects/. Anda dapat mengubah dan menambahkan definisi Anda sendiri yang sesuai dengan kebutuhan Anda. Namun, saya menyarankan Anda untuk mengikuti petunjuk yang dijelaskan dalam artikel ini dan Anda akan berhasil memantau host windows Anda dalam waktu kurang dari 20 menit.

Langkah 1: Menginstal Agen NSClient++ di Mesin Windows

Silakan gunakan petunjuk di bawah ini untuk menginstal Agen NSClient++ di Host Windows Jarak Jauh. Pertama-tama unduh file sumber addon NSClient++ 0.3.1 versi stabil terbaru, yang dapat ditemukan di tautan di bawah.

  1. http://sourceforge.net/projects/nscplus/

Setelah Anda mengunduh versi stabil terbaru, ekstrak file NSClient++ ke direktori C:\NSClient++ baru.

Sekarang buka command prompt MS-DOS dari Layar Mulai –> Jalankan –> ketik 'cmd' dan tekan enter dan ubah ke direktori C:\NSClient++.

C:\NSClient++

Selanjutnya, daftarkan layanan NSClient++ pada sistem dengan perintah berikut.

nsclient++ /install

Terakhir, instal NSClient++ systray dengan perintah berikut.

nsclient++ SysTray

Buka Windows Services Manager dan klik kanan pada NSClient buka Properties lalu tab 'Log On' dan klik kotak centang yang bertuliskan “Izinkan layanan berinteraksi dengan desktop”. Jika belum diizinkan, harap centang kotak untuk mengizinkannya.

Buka file NSC.INI yang terletak di direktori C:\NSClient++ dan hapus komentar pada semua modul yang ditentukan di bagian “modul”, kecuali CheckWMI.dll dan 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

Hapus komentar pada “host_yang diizinkan” di bagian “Pengaturan” dan tentukan alamat IP dari Server Pemantauan Nagios Anda atau biarkan kosong untuk mengizinkan host mana pun untuk terhubung.

[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

Batalkan komentar pada “port” di bagian “NSClient” dan setel ke port default '12489'. Pastikan untuk membuka port '12489' di Windows Firewall.

[NSClient]
;# NSCLIENT PORT NUMBER
;  This is the port the NSClientListener.dll will listen to.
port=12489

Terakhir, mulai layanan NSClient++ dengan perintah berikut.

nsclient++ /start

Jika Anda menginstal dan mengkonfigurasi dengan benar, Anda akan melihat ikon baru di baki sistem dalam lingkaran kuning dengan tanda 'M' hitam di dalamnya.

Langkah 2: Mengonfigurasi Server Nagios dan Menambahkan Host Windows

Sekarang Masuk ke Server Nagios dan tambahkan beberapa definisi objek di file konfigurasi Nagios untuk memantau mesin Windows baru. Buka file windows.cfg untuk diedit dengan editor Vi.

[root@tecmint]# vi /usr/local/nagios/etc/objects/windows.cfg

Contoh definisi host Windows yang sudah ditentukan untuk mesin Windows, Anda cukup mengubah definisi host seperti bidang nama_host, alias, dan alamat ke bidang yang sesuai nilai mesin Windows Anda.

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

Layanan berikut telah ditambahkan dan diaktifkan di file windows.cfg. Jika Anda ingin menambahkan beberapa definisi layanan lain yang perlu dipantau, Anda cukup menambahkan definisi tersebut ke file konfigurasi yang sama. Pastikan untuk mengubah nama_host untuk semua layanan ini dengan nama_host yang ditentukan pada langkah di atas.

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
	}

Terakhir, batalkan komentar pada file windows.cfg di /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

Terakhir, verifikasi file konfigurasi Nagios untuk mengetahui adanya kesalahan.

[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

Jika proses verifikasi memunculkan pesan kesalahan apa pun, perbaiki kesalahan tersebut hingga proses verifikasi selesai tanpa pesan kesalahan apa pun. Setelah Anda memperbaiki kesalahan tersebut, mulai ulang layanan Nagios.

[root@tecmint]# service nagios restart

Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.

Itu dia. Sekarang buka antarmuka Web Pemantauan Nagios di “http://Alamat-IP-server-Anda/nagios ” atau “http://FQDN/nagios ” dan Berikan nama pengguna “nagiosadmin ” dan kata sandi. Periksa apakah Remote Windows Host telah ditambahkan dan sedang dipantau.

Itu dia! untuk saat ini, dalam artikel saya yang akan datang, saya akan menunjukkan cara menambahkan Printer dan Switch ke Server Pemantauan Nagios. Jika Anda mengalami kesulitan saat menambahkan host Windows ke Nagios. Silakan komentari pertanyaan Anda melalui bagian komentar, sampai nanti, pantau terus linux-console.net untuk artikel berharga lainnya.