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.
Restarting Windows Services With NCPA.
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Restarting Windows Services With NCPA.
@nadeem, Do the other checks work with NCPA? This seems like a plugin issue.
What version of it are you running?
And what version of python do you have installed?
Did you upgrade python manually by any chance?
What version of it are you running?
Code: Select all
cat /usr/local/nagios/libexec/check_ncpa.py | grep "__VERSION__ ="Code: Select all
python -vAs of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Restarting Windows Services With NCPA.
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.
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.
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
./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.
Did you have further (related) questions or are we good to lock this up?
Former Nagios employee