Hello,
I have a Nagios server that needs to restart some Windows services, and/or do other things. When I issue the following command on the Nagios server, I get back this:
[root@ubitmon-hf libexec]# ./check_nrpe -H 10.23.241.210 -p 5666 -c runcmd -a spooler
C:\Program Files\NSClient++>net stop $ARG1$
The service name is invalid.
More help is available by typing NET HELPMSG 2185.
C:\Program Files\NSClient++>net start $ARG1$
The service name is invalid.
More help is available by typing NET HELPMSG 2185.
C:\Program Files\NSClient++>rem @exit 0
[root@ubitmon-hf libexec]#
This tells me the bat file is running. It appears that $ARG1$ isn't getting picked up as a variable. So, I recompiled the check_nrpe with --./configure --enable-command-args
Same response. Also, I edited the nsclient.ini file and added the following:
[/settings/External Scripts/Scripts]
runcmd = scripts\runcmd.bat $ARG1$
[/settings/NRPE/server]
allow arguments = 1
I am lost as to how to get this to work! The documentation I can find was outdated, I had to really fish around just to find the correct stuff to put in nsclient.ini. Has anybody ran into this? Any help is appreciated.
Regards,
Randy.
Check_nrpe Arguments fail to pass through $ARGx$ vars
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Check_nrpe Arguments fail to pass through $ARGx$ vars
The documentation is up to date for this, and it should contain everything you need to get this check up and running. I just ran through it again myself and had no issues, this is what I did. Once I knew NSClient++ was configured to run properly with NRPE checks through Nagios I added a file named:
to the nsclient++ scripts directory, this file was converted to a batch file.
I then opened the NSC.ini file and added the following to a bone stock external scripts portion:
I then restarted the NSClient++ service and tested the command from the Nagios server with the following:
And got the following as a return:
Did you go through all these steps?
Code: Select all
runcmdI then opened the NSC.ini file and added the following to a bone stock external scripts portion:
Code: Select all
[External Scripts]
;check_es_long=scripts\long.bat
;check_es_ok=scripts\ok.bat
;check_es_nok=scripts\nok.bat
;check_vbs_sample=cscript.exe //T:30 //NoLogo scripts\check_vb.vbs
;check_powershell_warn=cmd /c echo scripts\powershell.ps1 | powershell.exe -command -
check_updates=cmd /c echo scripts\check_windows_updates.ps1; exit $LastExitCode | powershell.exe -command-
check_test= cmd /c echo test
runcmd= scripts\runcmd.bat $ARG1$Code: Select all
./check_nrpe -H 192.168.5.63 -p 5666 -c runcmd -a poolerCode: Select all
The Print Spooler service is stopping.
The Print Spooler service was stopped successfully.
The Print Spooler service is starting.
The Print Spooler service was started successfully.Re: Check_nrpe Arguments fail to pass through $ARGx$ vars
Thanks for the fast reply. I did set up my system like you showed. However, there are some differences:
1. I am using the x64 version of the NSCLIENT.
2. There is not nsc.ini, it is nsclient.ini.
3. The section headings are totally different.
4. My bat file just does a simple net stop %1, net start %1. It runs. It just is being passed $ARG1$ as a literal instead of substituting $ARG1$ for its string value.
This is the newest client build that is from the stable released branch. It includes a .pdf also that shows how to do the install you described, but it doesn't match the nsclient.ini file shipped with the installation. Could I have the wrong version?
Regards,
Randy.
1. I am using the x64 version of the NSCLIENT.
2. There is not nsc.ini, it is nsclient.ini.
3. The section headings are totally different.
4. My bat file just does a simple net stop %1, net start %1. It runs. It just is being passed $ARG1$ as a literal instead of substituting $ARG1$ for its string value.
This is the newest client build that is from the stable released branch. It includes a .pdf also that shows how to do the install you described, but it doesn't match the nsclient.ini file shipped with the installation. Could I have the wrong version?
Regards,
Randy.
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Check_nrpe Arguments fail to pass through $ARGx$ vars
The latest version of NSClient++ is not highly recommended for production use as it can be quite buggy. I recommend re-installing with version 0.3.9x 64-bit with the MSI and then configuring this. It should work fine with the 64-bit version as that is what I used when I wrote the plugin/handler/guide
.