Page 1 of 1

Adding scripts to NRDS plugins dir for Windows

Posted: Wed Apr 13, 2016 10:55 am
by DennisPR
Hi I would like the add a powershell script (cpu_usage.ps1) to my NRDS config dir as mentionned in the post below
https://support.nagios.com/forum/viewto ... 4&start=10

My NRDS config works fine until I add the powershell command to the config
This is my config.ini file before adding the powershell script

Code: Select all

[settings]
CONFIG_VERSION=1.4
CONFIG_OS=Windows (64-bit)
CONFIG_NAME=test
URL=https://ap-dco67-mon.bel.centric.lan/nrdp/
TOKEN=MyToken
PLUGIN_DIR=C:\Program Files\Nagios\NRDS_Win\plugins
SEND_NRDP=
TMPDIR=
COMMAND_PREFIX=
LOG_FILE=C:\Program Files\Nagios\NRDS_Win\logs\NRDS_Debug.log
IGNORE_SSL_CERTIFICATE_ERRORS=1
UPDATE_CONFIG=1
UPDATE_PLUGINS=1


[services]
command[__HOST__] = $PLUGIN_DIR$\check_winping.exe -H 10.75.1.21 --warning 200,40% --critical 400,80%
command[nrpe_process] = $PLUGIN_DIR$\cpuload_nrpe_nt.exe 70 90
command[Windows : SVC spooler] = $PLUGIN_DIR$\service_nrpe_nt.exe "Print Spooler"
command[Windows : Diskspace C 90-95] = $PLUGIN_DIR$\check_pdm.exe --disk --drive C: -w 90 -c 95
command[Windows : Diskspace D 90-95] = $PLUGIN_DIR$\check_pdm.exe --disk --drive D: -w 90 -c 95
command[Windows : Memory Usage] = $PLUGIN_DIR$\check_pdm.exe --memory -w 85 -c 90
command[Windows : Page file] = $PLUGIN_DIR$\check_pdm.exe --memory pagefile -w 80 -c 95
command[Windows : CPU Load] = $PLUGIN_DIR$\cpu_usage.ps1


[extensions]
vbs = cscript //nologo $CHECK_COMMAND$
ps1 = powershell -ExecutionPolicy Bypass -File $CHECK_COMMAND$
The I added the following line to NRDS on Nagios

Code: Select all

command[Windows : CPU Load] = $PLUGIN_DIR$\cpu_usage.ps1
I have saved the cpu_usage.ps1 script to /usr/local/nagiosxi/html/includes/components/nrdsconfigmanager/nrds/plugins/Windows on my Nagios server.
The next time that the agent runs I get the following in the log file

Code: Select all

13/04/2016 17:44:00 ---Starting NRDS Transaction--- : 
13/04/2016 17:44:00 Diagnostic mode : False
13/04/2016 17:44:00 base NRDP address locked and loaded : https://ap-dco67-mon.bel.centric.lan/nrdp//?token=MyToken&cmd=
13/04/2016 17:44:00 XML being passed to check for updates : https://ap-dco67-mon.bel.centric.lan/nrdp//?token=MyToken&cmd=updatenrds&XMLDATA=<?xml version='1.0' ?><configs><config><name>test</name><version>1.3</version></config></configs>
13/04/2016 17:44:00 running Post routine.. : 
13/04/2016 17:44:00 ignoring certificate errors : 13056
13/04/2016 17:44:00 Post Data.... : 
13/04/2016 17:44:00 address..... : https://ap-dco67-mon.bel.centric.lan/nrdp//?token=MyToken&cmd=updatenrds&XMLDATA=<?xml version='1.0' ?><configs><config><name>test</name><version>1.3</version></config></configs>
13/04/2016 17:44:00 NRDP response to update query : <?xml version="1.0" encoding="utf-8"?>
<result>
  <status>1</status>
  <message>Version 1.4 available</message>
    <meta>
       <output></output>
    </meta>
  <config>
CONFIG_VERSION=1.4
CONFIG_OS=Windows (64-bit)
CONFIG_NAME=test
URL=https://ap-dco67-mon.bel.centric.lan/nrdp/
TOKEN=MyToken
PLUGIN_DIR=C:\Program Files\Nagios\NRDS_Win\plugins
SEND_NRDP=
TMPDIR=
COMMAND_PREFIX=
LOG_FILE=C:\Program Files\Nagios\NRDS_Win\logs\NRDS_Debug.log
IGNORE_SSL_CERTIFICATE_ERRORS=1
UPDATE_CONFIG=1
UPDATE_PLUGINS=1


command[__HOST__] = $PLUGIN_DIR$\check_winping.exe -H 10.75.1.21 --warning 200,40% --critical 400,80%
command[nrpe_process] = $PLUGIN_DIR$\cpuload_nrpe_nt.exe 70 90
command[Windows : SVC spooler] = $PLUGIN_DIR$\service_nrpe_nt.exe "Print Spooler"
command[Windows : Diskspace C 90-95] = $PLUGIN_DIR$\check_pdm.exe --disk --drive C: -w 90 -c 95
command[Windows : Diskspace D 90-95] = $PLUGIN_DIR$\check_pdm.exe --disk --drive D: -w 90 -c 95
command[Windows : Memory Usage] = $PLUGIN_DIR$\check_pdm.exe --memory -w 85 -c 90
command[Windows : Page file] = $PLUGIN_DIR$\check_pdm.exe --memory pagefile -w 80 -c 95
[b]command[Windows : CPU Load] = $PLUGIN_DIR$\cpu_usage.ps1[/b]


  </config>
</result>

13/04/2016 17:44:00 Config update availability : True
13/04/2016 17:44:00 downloading new config : https://ap-dco67-mon.bel.centric.lan/nrdp//?token=MyToken&cmd=getconfig&configname=test&os=Windows&os_ver=6.1.7601&arch=AMD64
13/04/2016 17:44:00 downloading new file : https://ap-dco67-mon.bel.centric.lan/nrdp//?token=MyToken&cmd=getconfig&configname=test&os=Windows&os_ver=6.1.7601&arch=AMD64
13/04/2016 17:44:00 running Post routine.. : 
13/04/2016 17:44:00 ignoring certificate errors : 13056
13/04/2016 17:44:00 Post Data.... : 
13/04/2016 17:44:00 address..... : https://ap-dco67-mon.bel.centric.lan/nrdp//?token=MyToken&cmd=getconfig&configname=test&os=Windows&os_ver=6.1.7601&arch=AMD64
13/04/2016 17:44:00 new plugins available : cpu_usage.ps1
13/04/2016 17:44:00 downloading plugin to : C:\PROGRA~1\Nagios\NRDS_Win\plugins\cpu_usage.ps1
13/04/2016 17:44:00 downloading new plugin : cpu_usage.ps1
13/04/2016 17:44:00 new plugin URL : https://ap-dco67-mon.bel.centric.lan/nrdp//?token=MyToken&cmd=getplugin&plugin=cpu_usage.ps1&os=Windows&os_ver=6.1.7601&arch=AMD64
13/04/2016 17:44:00 downloading new file : https://ap-dco67-mon.bel.centric.lan/nrdp//?token=MyToken&cmd=getplugin&plugin=cpu_usage.ps1&os=Windows&os_ver=6.1.7601&arch=AMD64
13/04/2016 17:44:00 running Post routine.. : 
13/04/2016 17:44:00 ignoring certificate errors : 13056
13/04/2016 17:44:00 Post Data.... : 
13/04/2016 17:44:00 address..... : https://ap-dco67-mon.bel.centric.lan/nrdp//?token=MyToken&cmd=getplugin&plugin=cpu_usage.ps1&os=Windows&os_ver=6.1.7601&arch=AMD64
I have already tried changing the owner and group of the cpu_usage.ps1 to nagios:nagios and changing the rights on the file to RWXRX---- just like all to the other files in that dir

Code: Select all

drwxrwx--- 2 nagios nagios    4096 Nov 28  2012 AMD64
-rwxrwx--- 1 nagios nagios 1306708 May 18  2011 check_pdm.exe
-rwxrwx--- 1 nagios nagios 1220692 Jul 23  2012 check_winping.exe
-rwxrwx--- 1 nagios nagios 1220692 Jul 23  2012 check_winprocess.exe
-rwxrwx--- 1 nagios nagios   61440 Jul 23  2012 cpuload_nrpe_nt.exe
-rwxrwx--- 1 nagios nagios     406 Apr 13 11:31 cpu_usage.ps1
-rwxrwx--- 1 nagios nagios   57344 Jul 23  2012 diskspace_nrpe_nt.exe
-rwxrwx--- 1 nagios nagios   57344 Jul 23  2012 eventlog_nrpe_nt.exe
-rwxrwx--- 1 nagios nagios   49152 Jul 23  2012 memload_nrpe_nt.exe
drwxrwx--- 2 nagios nagios    4096 Nov 28  2012 plugin_documents
-rwxrwx--- 1 nagios nagios   49152 Jul 23  2012 service_nrpe_nt.exe
drwxrwx--- 2 nagios nagios    4096 Nov 28  2012 x86
But that doesn't solve my problem.
Can someone help me out pls ?

Re: Adding scripts to NRDS plugins dir for Windows

Posted: Wed Apr 13, 2016 4:15 pm
by tmcdonald
When you say "The[n] I added the following line to NRDS on Nagios" do you mean you edited the file on the command line, or you used the web interface to update the NRDS config? I don't think just doing it on the CLI will work.

Re: Adding scripts to NRDS plugins dir for Windows

Posted: Thu Apr 14, 2016 2:47 am
by DennisPR
I've added the line through the NRDS Config Manager

Re: Adding scripts to NRDS plugins dir for Windows

Posted: Thu Apr 14, 2016 12:26 pm
by tgriep
After editing the NRDS in the XI interface, did all of the checks stop running or just the new one didn't work?
Did you go to Admin > Unconfigured Objects in the XI GUI to see if the new check is in there needing to be configured?

Did the Powershell script copy over to the Windows system in this folder?

Code: Select all

C:\Program Files\Nagios\NRDS_Win\plugins
Did the config.ini in this folder get updated with the changes?

Code: Select all

C:\Program Files\Nagios\NRDS_Win

Re: Adding scripts to NRDS plugins dir for Windows

Posted: Fri Apr 15, 2016 3:37 am
by DennisPR
The config file was updated locally after adding the CPU load command but the script did not download to C:\Program Files\Nagios\NRDS_Win\plugins
The download fails for some reason and the results of the other tests aren't sent to nagios any more.
There are no Unconfigured objets in the XI GUI

When I remove command[Windows : CPU Load] = $PLUGIN_DIR$\cpu_usage.ps1 in the NRDS config manager the config file gets updated again and all the other checks get results in Nagios again.

Re: Adding scripts to NRDS plugins dir for Windows

Posted: Fri Apr 15, 2016 9:05 am
by tgriep
Copy the cpu_usage.ps1 file to this this folder. This is where NRDS looks for Windows files when updating a client.

Code: Select all

/usr/local/nrdp/plugins/Windows/
Set the permissions to 775 and the owner and group to nagios.
Try that and see it this fixes the issue.

Re: Adding scripts to NRDS plugins dir for Windows

Posted: Fri Apr 15, 2016 9:27 am
by DennisPR
That solved the problem thx !
I was copying the scripts to the wrong dir in Nagios :shock: