Page 2 of 2

Re: Maintenace Downtime

Posted: Thu Apr 05, 2012 1:58 pm
by tgfde
Doe anyone know how to get this work?

I want to be able to schedule host downtime from an external script when a website goes down via script.

Thanks.

Re: Maintenace Downtime

Posted: Fri Apr 06, 2012 1:33 pm
by scottwilkerson
In the example we gave you, you need to modify the start and end parameters to the unix timestamp you want it to start and end.. The command you ran scheduled downtime in the past...

Here is a different example, showing how to make it start immediately and last 60 minutes

Code: Select all

#!/bin/sh

now=`date +%s`
dtCommand=SCHEDULE_HOST_DOWNTIME
pipe='/usr/local/nagios/var/rw/nagios.cmd'
duration=3600 #60 minutes
start=`date +%s`
end=`expr $start + $duration`
username=tgfde
message="This host is in scheduled downtime"
host=epmqowcs3

/bin/echo "[$now] $dtCommand;$host;$start;$end;1;0;$duration;$username;$message" > $pipe

Re: Maintenace Downtime

Posted: Fri Apr 13, 2012 11:21 am
by tgfde
How about scheduling a service down time? I have the following command but it is now working.

#!/bin/sh

now=`date +%s`
dtCommand=SCHEDULE_SVC_DOWNTIME
pipe='/usr/local/nagios/var/rw/nagios.cmd'
start=1334334038
end=1334336738
duration=3600 #60 minutes
username=tgfde
message="This service is in scheduled downtime"
host=cordmon1
service=Daccs_Q1

/bin/echo "[$now] $dtCommand;$host;$start;$end;1;0;$duration;$username;$message" > $pipe


Thanks.

Re: Maintenace Downtime

Posted: Fri Apr 13, 2012 12:11 pm
by scottwilkerson
you didn't include $service in the main command

/bin/echo "[$now] $dtCommand;$host;$service;$start;$end;1;0;$duration;$username;$message" > $pipe

Re: Maintenace Downtime

Posted: Fri Apr 20, 2012 1:51 pm
by tgfde
Hi,

I'm still getting no result after adding service in the main command.

#!/bin/sh

now=`date +%s`
dtCommand=SCHEDULE_SVC_DOWNTIME
pipe='/usr/local/nagios/var/rw/nagios.cmd'
start=1334929500
end=1334934000
duration=3600 #60 minutes
username=tgfde
message="This service is in scheduled downtime"
host=cordmon1
service=Daccs_Q2

/bin/echo "[$now] $dtCommand;$host;$service;$start;$end;1;0;$duration;$username;$message" > $pipe


Thanks.

Re: Maintenace Downtime

Posted: Fri Apr 20, 2012 3:10 pm
by scottwilkerson
These times are is in the past...

Re: Maintenace Downtime

Posted: Mon Apr 23, 2012 11:10 am
by tgfde
I just tried it with the following and still no luck.

start=1335180600
end=1335184200

Thanks.

Re: Maintenace Downtime

Posted: Mon Apr 23, 2012 11:36 am
by scottwilkerson
Again these times are in the past.... almost 18344 seconds

As of this second the current time is

Code: Select all

# date +%s
1335198944