mirror of
https://github.com/drewkerrigan/nagios-http-json.git
synced 2025-05-10 01:43:45 +02:00
fix: timezone
This commit is contained in:
parent
f4cc490b98
commit
b3907a63c8
@ -9,7 +9,7 @@ import ssl
|
||||
from pprint import pprint
|
||||
from urllib.error import HTTPError
|
||||
from urllib.error import URLError
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
plugin_description = \
|
||||
"""
|
||||
@ -364,12 +364,12 @@ class JsonRuleProcessor:
|
||||
(key, alias)
|
||||
|
||||
try:
|
||||
timestamp = datetime.fromisoformat(self.helper.get(key)).replace(tzinfo=None)
|
||||
timestamp = datetime.fromisoformat(self.helper.get(key))
|
||||
except:
|
||||
return " Value (%s) for key %s is not a Date in ISO format." % \
|
||||
(self.helper.get(key), alias)
|
||||
|
||||
now = datetime.now()
|
||||
now = datetime.now(timezone.utc)
|
||||
age = now - timestamp
|
||||
|
||||
if not negative:
|
||||
@ -732,4 +732,4 @@ if __name__ == "__main__":
|
||||
# Program entry point
|
||||
main(sys.argv[1:])
|
||||
|
||||
#EOF
|
||||
#EOF
|
Loading…
Reference in New Issue
Block a user