Rabu, 28 September 2016

Client Nagios WIndows

Untuk memantau OS Windows lakukan langkah-langkah sbb:
  1. Install NSClient++ addon pada OS WIndows
  2. Konfigurasi Pada Nagios Server demi OS Windows
  3. Konfigurasi service dan IP Host /Windows yang hendak dimonitoring
  4. Restart Ulang Nagios Service
Praktik:
jika gagal install gunakan file yang versi lamanya bisa donload di : https://sourceforge.net/projects/nscplus/files/OldFiles/NSClient%2B%2B-0.0.2-a2.zip/download atau sumber semuanya di :

+extract ke D:\NSClient
+jalankan run (via Administrator)

+cd D:\NSCLient
+ketik nsclient++ /install
+ketik nsclient++ SysTray


Lalu pada RUN ketik: services.msc
aktifkan / start NSCLient services



buka file NSC.INI pada drektori C:\NSClient
=>
uncomment all the modules defined in the “modules” section, except for CheckWMI.dll and RemoteConfiguration.dll.

Bentuk akhirnya adalah sbb:


[log]
# LOG DEBUG
# Set to 1 if you want debug message printed in the log file (debug messages are always printed to stdout when run with -test)
;debug=0
# LOG FILE
# The file to print log statements to
;file=NSC.log


[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=192.168.1.103

[systray]
# SYSTRAY INJECT COMMAND
# The default command to show in the inject dialog from the event log.
defaultCommand=CheckEventLog Application warn.require.eventType=error warn.require.eventType=warning critical.require.eventType=error critical.exclude.eventType=info truncate=1024 descriptions

[NSClient]
# NSCLIENT PORT NUMBER
# This is the port the NSClientListener.dll will listen to.
port=12489
# PASSWORD
# This is the password (-s) that is required to access NSClient remotely
;password=
# ALLOWED HOST ADDRESSES
# This is a comma-delimited list of IP address of hosts that are allowed to talk to the NRPE daemon.
;allowed_hosts=
 ;adress=w.x.y.z (not yet implemented)

[NRPE]
# NRPE PORT NUMBER
# This is the port the NRPEListener.dll will listen to.
;port=5666
# ALLOWED HOST ADDRESSES
# This is a comma-delimited list of IP address of hosts that are allowed to talk to the NRPE daemon.
;allowed_hosts=
# COMMAND TIMEOUT
# This specifies the maximum number of seconds that the NRPE daemon will allow plug-ins to finish executing before killing them off.
;command_timeout=60
# COMMAND ARGUMENT PROCESSING
# This option determines whether or not the NRPE daemon will allow clients to specify arguments to commands that are executed.
;allow_arguments=0
# COMMAND ALLOW NASTY META CHARS
# This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
;allow_nasty_meta_chars=0
 ;adress=w.x.y.z (not yet implemented)
 ;dont_blame_nrpe (renamed to 'allow_arguments' as it seemd to make more sense)

[NRPE Handlers]
# COMMAND DEFINITIONS
# Command definitions that this daemon will run.
# Can be either NRPE syntax: 
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
# Or simplified syntax:
test=c:\test.bat foo $ARG1$ bar
check_disk1=/usr/local/nagios/libexec/check_disk -w 5 -c 10
# Or even loopback (inject) syntax (to run internal commands)
# This is a way to run "NSClient" commands and other internal module commands such as check eventlog etc.
check_cpu=inject checkCPU warn=80 crit=90 5 10 15
check_eventlog=inject CheckEventLog Application warn.require.eventType=error warn.require.eventType=warning critical.require.eventType=error critical.exclude.eventType=info truncate=1024 descriptions
# But be careful:
; dont_check=inject dont_check This will "loop forever" so be careful with the inject command...

[modules]
# NSCLIENT++ MODULES
# A list with DLLs to load at startup.
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


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Lalu restart : nsclient++ /start

NB ip 192.168.1.103 adalah ipnya server nagios



+++SELESAI DISII CLIENT SEKARANG TAMBAHKAN CODE DISISI SERVER

Configuring Nagios Server and Add Windows Hosts

SET IP CLIENT WINDOWS

Now Login into Nagios Server and add some object definitions in Nagios configuration files to monitor newWindows machine. Open windows.cfg file for editing with Vi editor.
[root@tecmint]# vi /usr/local/nagios/etc/objects/windows.cfg
A sample Windows host definition already defined for the Windows machine, you can simply change the host definition like host_namealias, and address fields to appropriate values of your Windows machine.
###############################################################################
###############################################################################
#
# 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
}
Following services are already added and enabled in windows.cfg file. If you wish to add some more other service definitions that needs to be monitored, you can simple add those definitions to same configuration file. Make sure to change the host_name for these all services with host_name defined in the above step.
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
}
Lastly, uncomment the windows.cfg file in /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
Finally, verify the Nagios configuration files for any erros.
[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
If the verification process throws any error messages, fix those errors until the verification process completes without any error messages. Once’ you fix those errors, restart the Nagios service.
[root@tecmint]# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.
That’s it. Now go to Nagios Monitoring Web interface at “http://Your-server-IP-address/nagios” or “http://FQDN/nagios” and Provide the username “nagiosadmin” and password. Check that the Remote Windows Host was added and is being monitored.

Nagios Monitor Windows Host

Tidak ada komentar:

Posting Komentar