Restarting Windows Services With NCPA.
Posted: Tue May 22, 2018 6:46 am
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.
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.