Restarting Windows Services With NCPA.

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
nadeem
Posts: 3
Joined: Mon May 21, 2018 4:48 am

Restarting Windows Services With NCPA.

Post 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.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Restarting Windows Services With NCPA.

Post 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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
nadeem
Posts: 3
Joined: Mon May 21, 2018 4:48 am

Re: Restarting Windows Services With NCPA.

Post 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.
nadeem
Posts: 3
Joined: Mon May 21, 2018 4:48 am

Re: Restarting Windows Services With NCPA.

Post 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
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Restarting Windows Services With NCPA.

Post by tmcdonald »

Did you have further (related) questions or are we good to lock this up?
Former Nagios employee
Locked