Nagios uses nsclient++ to monitor Windows hosts

Source: Internet
Author: User

There is check_nt this plugin under Nagios's libexec, which is used to check the services of Windows machines. Its function is similar to Check_nrpe. But it also needs to be paired with another software nsclient++, which is similar to Nrpe. We need to download the appropriate version of Nsclient and install it on the monitored Windows host.

Overview of NRPE

The principle of nsclient++ is as follows:

You can see that the biggest difference between nsclient and Nrpe is:

    • NRPE: The monitor is installed with NRPE, and there are plug-ins, the final monitoring is carried out by these plug-ins. When the monitoring host sends the monitoring request to Nrpe, the Nrpe invokes the plugin to complete the monitoring.

    • nsclient++: nsclient++ is different, only installed nsclient on the monitor machine, there is no plug-in. When the monitoring host sends the monitoring request to nsclient++, Nsclient directly completes the monitoring, and all the monitoring is done by nsclient.

This also illustrates a big problem with nsclient++: inflexible, non-scalable. It can only complete its own monitoring operations, can not be extended by some plug-ins. Fortunately nsclient++ has done a good job, basically can fully meet our monitoring needs.

1. Install nsclient++ on a monitored Windows host

Download nsclient++ from Http://www.nsclient.org/nscp/downloads. The installation process is similar to the installation process for other Windows applications, and next we have the option to keep the default. The installation process needs to fill in the IP address and password of the monitoring side, and the following modules all tick.

After the installation is complete, we see if 5666 and 12489 ports are enabled, and if so, the Nsclient service is up and running.

In "Run", enter services.msc, open "service"

If you see nsclient++, the instructions are normal.

2. Edit the nsclient++ configuration file

The default is installed in the C:\Program files\nsclient++ directory, Nsclient.ini is the configuration file for the Nsclient service, generally we do not need to modify, but when we monitor the IP address changes, or the password forgotten, that can be modified here.

So that the external can be accessed?

Wrong!

The firewall also wants to open TCP port 12489, otherwise Nagios will error when checking the service.

So the configuration of the monitor is done, it waits for Nagios to issue a monitoring request, and then it performs a request to send the monitored results back to the Nagios monitoring host.

3, in the monitoring side operation, detect whether the normal work

[[email protected] ~]# cd /usr/local/nagios/libexec/#  viewing use Help [[email protected]  libexec]# ./check_nt -h#  if no port is specified, 1248 is used by default to connect [[email protected] libexec]#  ./check_nt -h 192.168.11.105 -v uptimeconnect to address 192.168.11.105  and port 1248: Connection refusedcould not fetch information  from server#  no Password specified [[email protected] libexec]# ./check_nt -h  192.168.11.105 -p 12489 -v uptimensclient - error: invalid password.#  ok[[email protected] libexec]# ./check_nt -h 192.168.11.105 -p 12489  -s 123456 -v uptimesystem uptime - 0 day (s)  0 hour (s)   51 minute (s)  |uptime=51[[email protected] libexec]# ./check_nt -H  192.168.11.105 -p 12489 -s 123456 -v cpuload -w 80 -c 90 -l 5,80,90cpu load 21%   (5 min average)  |    ' 5 min avg load ' =21%;80;90;0;100#  -w  warning scale  -c  emergency proportional   -l (lowercase l)   mean for the last 5 minutes, 80% for warning, 90% for emergency # ./check_nt -h  192.168.1.5 -p 12489 -s -v useddiskspace -w 80 -c 90 - l c c:\ - total: 50.01 gb - used: 18.94 gb  (38%)  -  free 31.07 Gb  (62%)  |  ' C:\ used space ' =18.94gb;40.01;45.01;0.00;50.01 ###  Information Echo format General Information  |  resource performance information between them output to use | separate, if you develop plug-ins must use this format, if only output general Information line.

4, define the host, service, command

[Email protected] ~]# cd/etc/nagios/monitor/

(1) Defining commands

# vi commands.cfg define command{command_name check_win command_line $USER 1$/check_nt-h "$HOSTADDRES S $ "-p 12489-s 123456-v $ARG 1$ $ARG 2$}# $. $ represents the system built-in macros, that is, the so-called variable # $USER 1$ indicates the directory in which the plugin is located #-h specifies the host address # $HOSTADDRESS to which host to use, the address of the host that is used $ARG 1$ pass parameters, formal parameter #-s to specify the password, if necessary add, such as the above installation When the password is set to 123456

(2) Define the host

# vim Hosts.cfgdefine host{use windows-server host_name win-192.168.11.105 alias My win server address 192.168.11.105}

(3) Defining the service

# vi services.cfgdefine service{        use                       generic-service        host_name                win-192.168.11.105         service_description     NSClient++ Version         check_command            check_win! clientversion  ; The first parameter passed to the-v  parameter          }define  service{        use                      generic-service         host_name                win-192.168.11.105        service_description      Uptime        check_command            check_win! uptime        }define service{         use                      generic-service        host_ name                win-192.168.11.105        service_description      cpu load        check_command           check_win! cpuload!-l 5,80,90 ; Pass two arguments! cpuload  and-! -L 5,80,90         }

5. View Results

Since the configuration file has been modified, we'd better check the syntax of the configuration file first.

#/usr/local/nagios/bin/nagios-v/etc/nagios/nagios.cfg# If there is no problem, you can restart the Nagios service # service Nagios restart

Now open the Nagios Web monitoring page to see the relevant information.

Nagios uses nsclient++ to monitor Windows hosts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.