external command update is failing
Posted: Fri Feb 03, 2017 12:28 pm
I have the following code which should put all of a host's services in downtime, but I'm getting an error. Can you please help?
This produces an error in nagios.log when it runs.
[1486142396] Error: External command failed -> SCHEDULE_HOST_SVC_DOWNTIME;myhost.mathworks.com;1486142396;1486149596;1;0;0;nagiosadmin;Host being retired
[1486142396] External command error: Command failed
Code: Select all
#! /usr/local/bin/python2.7
import time
host = "myhost.mathworks.com"
CommandFile = "/usr/local/nagios/var/rw/nagios.cmd"
with open(CommandFile,"a") as nagiosCmd:
now = int(time.time())
later = now + 7200
commandString = "[" + str(now) + "] SCHEDULE_HOST_SVC_DOWNTIME;" + host + ";" + str(now) + ";" + str(later) + ";1;0;
0;nagiosadmin;Host being retired\n"
print (commandString)
nagiosCmd.write(commandString)[1486142396] Error: External command failed -> SCHEDULE_HOST_SVC_DOWNTIME;myhost.mathworks.com;1486142396;1486149596;1;0;0;nagiosadmin;Host being retired
[1486142396] External command error: Command failed