title: Automate schedule and Cancel downtime in Nagios
body: <p>I am trying to <strong>schedule and cancel downtime in Nagios core 4.x.</strong></p>
  
  <p>I could schedule a downtime for a host using the following cmd:</p>
  
  <pre><code>curl --silent --show-error  --data cmd_typ=55 --data cmd_mod=2 --data host=automichost1  --data "com_data=Updating+application" --data trigger=0 --data "start_time=05-15-2016 19:00:00" --data "end_time=05-15-2016 19:15:00" --data fixed=1 --data btnSubmit=Commit --insecure http://localhost:80/nagios/cgi-bin/cmd.cgi -u "nagiosadmin:XXXXXX"
  </code></pre>
  
  <p>This cmd does not return the <strong>downtime id</strong> generated and simply returns a html file.</p>
  
  <p>but to cancel the schedule downtime  i need to use following</p>
  
  <pre><code>curl --silent --show-error  --data cmd_typ=78 --data cmd_mod=2 --data down_id=2  --data "com_data=Updating+application" --data btnSubmit=Commit --insecure http://localhost:80/nagios/cgi-bin/cmd.cgi -u "nagiosadmin:xxxxxxx"
  </code></pre>
  
  <p>Here I need down_id to Cancel a downtime. In an automation script there is no way to get this downtime id from any nagios external command. I also tried the following external command mentioned on <a href="http://docs.icinga.org/latest/en/cgiparams.html" rel="nofollow">http://docs.icinga.org/latest/en/cgiparams.html</a>
  <strong>CMD_DEL_DOWNTIME_BY_HOST_NAME                      171</strong></p>
  
  <p>but this is not working on Nagios and gives message "Sorry, but you are not authorized to commit the specified command.".</p>
  
  <p>I am stuck now and cannot move forward. does anyone knows how to acheive this?</p>