Classification
nsclient++ to monitor Windows hosts in three ways: Check_nt, Check_nrpe, NSCA. Check_nt comes with a lot of features, but with poor extensibility, Check_nrpe can be extended well by executing scripts that you define (officially recommended).
Principle
The monitoring side sends the instructions to be monitored by check_nrpe to the monitored side, and the monitored side performs the monitoring tasks on the local computer and transmits the results of the execution back to the monitored side.
Realize
In nsclient++0.3, for example, the function of the example is to monitor whether a process is running.
1. Edit the nsclient configuration file Nsc.ini, and remove the ";" number in front of the following lines (remove the comment to make it effective)
Nrpelistener.dllscript_dir=scriptscheckexternalscripts.dll
2. Under the Scripts folder in the Nsclient installation directory, create a new check_run.bat batch file, as follows
File name: Check_run.bat
" %1 " >1010
3. In the Nsc.ini file, add the following line under [External Scripts]:
Check_run=scripts\check_run.bat Chrome.exe
Note : [External scripts] instead of [External script]
4. Restart Nsclinet
5. The directory where the monitored end Check_nrpe is located (the CentOS default installation directory is:/usr/lib64/nagios/plugins/)
./check_nrpe-h hostip-c Check_run
Note :-H after the script just before the machine,-C after the write command, which corresponds to the Check_run in the configuration file
If the results are consistent with expectations, then you can continue to configure the monitoring side.
6. Configure the Monitor side
Modify Commands.cfg
Increase
Define Command { command_name check_fileexistspan command_line /usr/lib64/nagios/plugins/check_nrpe-h Yourip-c Check_fileexistspan }
Modify Windows.cfg
Define Service {Use generic-service-urgent,srv-pnp host_name youip ; IP service_ of the machine to display information about Description check_fileexistspan check_command check_run }
Effect
Nagios uses nsclient++ 's Check_nrpe way to monitor windows with custom scripts