diff options
author | Peter (pir) Radcliffe <pir-gitweb.com@pir.net> | 2015-11-25 13:58:30 +0000 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2016-11-07 22:42:40 +0100 |
commit | 2f2b2f1987d63cb4b31b2ef4c95cf8c8ab1d83c6 (patch) | |
tree | 241c1345032f3e7f650f188d02ebee8b092d0290 /plugins/sslutils.c | |
parent | 06059ecd0ebf4646cda5e24c31e9d17672e2c295 (diff) | |
download | monitoring-plugins-2f2b2f1987d63cb4b31b2ef4c95cf8c8ab1d83c6.tar.gz |
GMT expiry display
Change solution to display GMT time in the local display format with
the offset number of hours from GMT to be clear about what timezone
this is if the local display format does not include offset.
Diffstat (limited to 'plugins/sslutils.c')
-rw-r--r-- | plugins/sslutils.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/plugins/sslutils.c b/plugins/sslutils.c index 6437289f..b412ef3d 100644 --- a/plugins/sslutils.c +++ b/plugins/sslutils.c @@ -197,6 +197,7 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ X509_NAME *subj=NULL; char timestamp[50] = ""; char cn[MAX_CN_LENGTH]= ""; + char *tz; int cnlen =-1; int status=STATE_UNKNOWN; @@ -267,7 +268,15 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ tm_t = timegm(&stamp); time_left = difftime(tm_t, time(NULL)); days_left = time_left / 86400; - strftime(timestamp, 50, "%F %R %z/%Z", localtime(&tm_t)); + tz = getenv("TZ"); + setenv("TZ", "GMT", 1); + tzset(); + strftime(timestamp, 50, "%c %z", localtime(&tm_t)); + if (tz) + setenv("TZ", tz, 1); + else + unsetenv("TZ"); + tzset(); if (days_left > 0 && days_left <= days_till_exp_warn) { printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); |