timezone adjustments for nagios 3
Grant Byers
grant.byers at gmail.com
Tue Oct 23 01:42:24 CEST 2007
Hi all,
Does anyone have opinions on timezone adjustments per host or service?
We are wanting to replace our current in-house monitoring with nagios, but
our single monitoring system pushes thousands of checks out to sites in half
a dozen different timezones every hour. Some of these checks are timezone
sensitive, whilst others aren't.
I propose that service & host have "timezone" & "use_timezone"
attributes. Below is an example of how i'd [poorly] calculate a tz_offset
based on the "timezone" attribute.
Thoughts?
Cheers,
Grant
/* get the timezone difference between local time & the given timezone */
long get_timezone_offset(const char *tz){
char *tzlocal;
struct tm t;
time_t secs_since_epoch;
long local_utc_offset, remote_utc_offset;
/* save existing timezone data, if exists & grab seconds elapsed since
the EPOCH */
tzlocal=getenv("TZ");
secs_since_epoch=time(NULL);
/* get local offset from UTC, in seconds */
tzset();
localtime_r(&secs_since_epoch,&t);
local_utc_offset=secs_since_epoch-mktime(&t);
/* set our timezone to remote timezone */
setenv("TZ",tz,1);
tzset();
localtime_r(&secs_since_epoch,&t);
/* restore original timezone */
if(tzlocal!=NULL)
setenv("TZ",tzlocal,1);
else
unsetenv("TZ");
tzset();
/* get remote offset from UTC, in seconds */
remote_utc_offset=secs_since_epoch-mktime(&t);
return (local_utc_offset-remote_utc_offset);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20071023/aab1fe83/attachment.html>
-------------- next part --------------
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel
More information about the Developers
mailing list