[Nagios-devel] timezone adjustments for nagios 3

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] timezone adjustments for nagios 3

Post by Guest »

------=_Part_4493_10061040.1193096544446
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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);
}

------=_Part_4493_10061040.1193096544446
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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);} 

------=_Part_4493_10061040.1193096544446--





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked