Pages

Saturday, June 16, 2012

Nagios 3 monitoring Windows Servers


Nagios is a Open Source Host. It is a  Network Monitoring Services. Nagios provides an extensible framework, that can monitor pretty much anything. With it you can use diferent plugins, you can monitor any Operating System in Linux, Windows, and Mac. In this post I explain how to monitor Windows Servers in any network.
I assume that at this point you have installed Nagios. If you haven't install Nagios go to:  http://systemadministratorrecipes.blogspot.com/2012/06/scripts-nagios-for-install-on-ubuntu.html

1. Windows Server preparation with NSClient++ 


  • Go to http://www.nsclient.org/nscp/downloads and get the .msi of the last version for win32 or x64
  • After download, on the archive double click for starting installation
    • On the first windows, click Next
    • In End-User License Agreement windows, "I accept the terms in the License Agreement" check mark, and then click Next
    • Select Custom Setup, then click Next
    • In Custom Setup windows, click Next
    • In NSCliente++ Configuration windows, click Next
    • In the new NSClient++ Configuration windows, in the first line type IP Address of the Nagios server
    • In the "Modules to load", click to check mark all modules, and then click Next
    • In the last windows, click Finish
  • Click Start > Administrative tools > Services
  • In NSClient++ service, right click Properties
  • Click on Log On tab, and then click to check mark "Allow service to interact with desktop", then click OK
  • Close Services window
  • Go to "C:\Program Files\NSClient++", and open nsc.ini in Notepad
  • In the modules section, remove semicolons from the modules as show below:
    • FileLogger.dll
    • checkSystem.dll
    • Checkdisk.dll
    • NSClientListener.dll
    • NRPEListener.dll
    • SysTray.dll
    • CheckEventLog.dll
    • CheckHelpers
    • CheckExternalScripts
    • NRPEClient.dll
  • In the settings section, these should be only two line without semicolons as show below:
    • use_file=1
    • allowed_host=10.44.5.223 "Remplace with your Nagios server's IP"
  • That should do it, save the file, and then click to close Notepad
  • Click Start > Administrative Tools > Services
  • In NSCliente++ services right click, and then click to Restart
  • Click to close Services window

2. Go to Nagios configuration host-group for Windows Servers


  • Press Alt+F2, type Terminal, and press Enter
  • In terminal type "gksudo nautilus" (if you don't  have installing Nautilus go to: http://systemadministratorrecipes.blogspot.com/2012/06/open-nautilus-as-root-in-ubuntu.html there you have all step for install it)
  • In the windows click Files system > usr > local > nagios > etc > nagios.cfg
  • Right click in nagios.cfg and select Open with Text Editor in my case "Kate"
  • Find this section:
    • #definitions for monitoring a Windows Machine
    • #cfg_file=/usr/local/nagios/ect/objects/windowss.cfg
  • And delete "#" from the start in the second line, click to Save and Close
  • Go to  /usr/local/nagios/etc/objects/windows.cfg
  • Right click in windows.cfg and select Open with a Text Editor in my case "Kate"
  • First, go to the "Host Definition", we define each host here
e.g

define host{
               use                      windows-server                        ; Inherit default values from template
               host_name           DC-Server.xxxxxxxx.com      ; The name we're giving to this host
               alias                     DC-Server                               ; A longer name associated with the server
               address                192.168.10.10                          ; IP address of the host
               hostgroups           windows-servers                     ; The group or groups we need this server .....
               }

You can add more host here, but remember add the last line "hostgroups        windows-servers"

  • Second, go to the "Host Group Definition", we define hostgroup here
e.g

define hostgroup{
                        hostgroup_name    windows-servers                    ; The name of the hostgroups
                        alias                       Windows Servers                   ;  Long name of the group
                          }

Make sure the hostgroup_name define here and the hostgroups define in each host define above are the same.

  • Finally, go to "Service  Definitions", we define services here
e.g

define service{
                    use                           generic-service
                    hostgroup_name       windows-servers
                    check_command      check_nt!SERVICESTATE!-d SHOWALL -l W#SVC
                     }

Here you change host_name for hostgroup_name. You need to do this for all define services.

  • Save and Quit
Remember, every time you change the Nagios configuration files, you mush check the files before using them:
  • Press Alt+F2, type Terminal, and then press Enter
  • In Terminal, type /etc/init.d/nagios restart
  • After restart, type /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If you receive Total warnings:0 and Total Errors:0. You are ready for starting Nagios.


1 comment:

  1. Finally, took me two hours to get this to work and this was the answer.

    ReplyDelete