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