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.
Maintenace Downtime
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Maintenace Downtime
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
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" > $pipeRe: Maintenace Downtime
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.
#!/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.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Maintenace Downtime
you didn't include $service in the main command
/bin/echo "[$now] $dtCommand;$host;$service;$start;$end;1;0;$duration;$username;$message" > $pipe
/bin/echo "[$now] $dtCommand;$host;$service;$start;$end;1;0;$duration;$username;$message" > $pipe
Re: Maintenace Downtime
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.
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.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Maintenace Downtime
These times are is in the past...
Re: Maintenace Downtime
I just tried it with the following and still no luck.
start=1335180600
end=1335184200
Thanks.
start=1335180600
end=1335184200
Thanks.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Maintenace Downtime
Again these times are in the past.... almost 18344 seconds
As of this second the current time is
As of this second the current time is
Code: Select all
# date +%s
1335198944