Format of downtime.log file and creating reoccurring downtimes

mshirley at ysi.com mshirley at ysi.com
Mon Jun 14 18:30:24 CEST 2004


>From the archives this has been asked a few times but no one seems to know
the answer and there is no specifics on the website.  I have a reoccurring
downtime every week when a computer goes down for backups.  There is some
script in the "extras" section that supposedly does it but the syntax it's
using and the files it's trying to write to seem like it was written for a
version long long past.  I've got no problem writing my own scripts and
crons but I need to figure out how the HOST_DOWNTIME external command
works.  Here are 2 examples of downtimes that were created using the cgi.

[1087216929] HOST_DOWNTIME;8;host;1087218000;1087221600;1;3600;mark;test
[1087217063] HOST_DOWNTIME;9;host;1087225200;1087228800;1;3600;mark;test

These two downtimes were created for testing purposes each for one hour
first from 09:00:00 to 10:00:00 and the other from 11:00:00 to 12:00:00.
>From what i can tell by comparing this output and the supposed output of
the broken script obviously HOST_DOWNTIME is the command, 8 and 9 are the
downtime id's, host is the host, then 2 sets of numbers that make no sense
to me at all,1 for fixed,3600 for the length of downtime in seconds,
author, and comment.

After looking more carefully it seems the script transforms a standard
'date' from something like 2004-06-14 into 1087185600.  The command used is
'date -d "040614 HH:MM:SS" +%s'.  From the date manpage 'date -d "string"'
simply takes a date string input and turns it into a date, the real magic
is done using the +%s format which seems to be "number of seconds since
1970-01-01 UTC".  The first set of numbers 1087216929 i believe is the time
the downtime was created.  The second set of numbers 1087218000 is the
start time of the first downtime 'date -d "20040614 09:00:00" +%s'.  The
third set of numbers 1087221600 is the end time of the first downtime 'expr
1087218000 + 3600' where 1087218000 is the start time, 3600 is the number
of seconds the downtime will continue (that's one hour).

So to brief it all out and give an example of what it all consists of ....

[date +%s] HOST_DOWNTIME;downtime id;host;date "start date start time"
+%s;expr 'date "start date start time" +%s' + duration of downtime;1 or 0
fixed;duration;author;comment

[current date] downtime command;downtime id;host;start date time in +%s
format;start date time in +%s plus the number of seconds for downtime;1 or
0 fixed;duration;author;comment

Also, after changes have been made to the downtime.log they don't seem to
take 100% effect until nagios is reloaded.  They show up when you goto the
downtime cgi but they do not show up as activated for that particular host.

The service downtime looks very similar with a few different fields but
could easily be adapted the same as host_downtime.

So in the time it's taken me to write this email it seems i might have just
answered my own question but since no one else has been able to answer it
or i haven't been able to find anything on it then i suppose I'll post this
anyway.  Just in case someone else is looking for the same answer.  The
writing of a script should be pretty easy so if anyone has anything to add
then by all means.

Mark Shirley
IT Helpdesk
YSI Incorporated




-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
>From Windows to Linux, servers to mobile, InstallShield X is the
one installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list