summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/check-sth.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/check-sth.py b/tools/check-sth.py
index 85e4661..708a438 100755
--- a/tools/check-sth.py
+++ b/tools/check-sth.py
@@ -9,7 +9,7 @@ import argparse
import json
import errno
import shutil
-from datetime import datetime, timedelta
+from datetime import datetime, timedelta, tzinfo
from certtools import get_sth
NAGIOS_OK = 0
@@ -59,14 +59,22 @@ def mv_file(fromfn, tofn):
def write_file(fn, sth):
open(fn, 'w').write(json.dumps(sth))
+class UTC(tzinfo):
+ def utcoffset(self, dt):
+ return timedelta(hours=0)
+ def dst(self, dt):
+ return timedelta(0)
+
def check_age(sth):
- now = datetime.now()
- sth_time = datetime.fromtimestamp(sth['timestamp'] / 1000)
+ now = datetime.now(UTC())
+ sth_time = datetime.fromtimestamp(sth['timestamp'] / 1000, UTC())
if now > sth_time + timedelta(0, 6 * 3600):
- print "CRITICAL: STH older than 6h: ", sth_time
+ print "CRITICAL: %s is older than 6h: %s" % \
+ (sth['sha256_root_hash'], sth_time)
sys.exit(NAGIOS_CRIT)
if now > sth_time + timedelta(0, 2 * 3600):
- print "WARNING: STH older than 2h: ", sth_time
+ print "WARNING: %s is older than 2h: %s" % \
+ (sth['sha256_root_hash'], sth_time)
sys.exit(NAGIOS_WARN)
def check_treesize(cur, prev):