Page 1 of 1

Restarting Windows Services With NCPA.

Posted: Tue May 22, 2018 6:46 am
by nadeem
Hello,

I have installed & configured NCPA agent on Windows Server 2012. Then I created a batch file restart_service.bat having following commands:

@echo off
net stop %1
net start %1
@exit 0

I copied this restart_service.bat file on Windows Server 2012 machine in following folder:
C:\Program Files (x86)\Nagios\NCPA\plugins\

Then On Nagios Server, I executed the following commands to test these commands from Nagios XI server:

cd /usr/local/nagios/libexec
./check_ncpa.py -H 192.168.0.142 -p 5693 -t welcome -M 'plugins/restart_service.bat' -a spooler

It gives following error message:
UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.

Then I executed the following command:
./check_ncpa.py -H 192.168.0.142 -p 5693 -t welcome -M 'plugins/restart_service.bat' -a spooler -v

Connecting to: https://192.168.0.142:5693/api/plugins/ ... me&check=1
File returned contained:
{
"returncode": 0,
"stdout": "The Print Spooler service is stopping.\nThe Print Spooler service was stopped successfully.\n\nThe Print Spooler service is starting.\nThe Print Spooler service was started successfully."
}
An error occurred:zero length field name in format
{root@localhost libexec]#

Kindly guide how I can fix this zero length field name in format error.

Thanks.
Muhammad Nadeem.

Re: Restarting Windows Services With NCPA.

Posted: Tue May 22, 2018 12:00 pm
by npolovenko
@nadeem, Do the other checks work with NCPA? This seems like a plugin issue.
What version of it are you running?

Code: Select all

 cat /usr/local/nagios/libexec/check_ncpa.py | grep "__VERSION__ ="
And what version of python do you have installed?

Code: Select all

python -v
Did you upgrade python manually by any chance?

Re: Restarting Windows Services With NCPA.

Posted: Wed May 23, 2018 12:25 am
by nadeem
Hello Npolovenko,

Thanks for your reply.

I can access the NCPA GUI interface through https://192.168.0.142:5693/ and can login with token. The GUI interface shows the agent version as 2.1.4.

The output from your provided commands is given below:

cat /usr/local/nagios/libexec/check_ncpa.py | grep "__VERSION__ ="

__VERSION__ = '1.1.2'

python -v

Python 2.6.6

No I didn't upgrade python manually.

Re: Restarting Windows Services With NCPA.

Posted: Wed May 23, 2018 4:03 am
by nadeem
I have resolved the issue. The problem with below command:

./check_ncpa.py -H 10.25.14.3 -p 5693 -t Str0ngT0k3n -M 'plugins/service_restart.bat' -a spooler

In the above command, when I used -P instead of -p then problem fixed.

So the correct command is:

./check_ncpa.py -H 10.25.14.3 -P 5693 -t Str0ngT0k3n -M 'plugins/service_restart.bat' -a spooler

Re: Restarting Windows Services With NCPA.

Posted: Wed May 23, 2018 12:30 pm
by tmcdonald
Did you have further (related) questions or are we good to lock this up?