fix date parsing

This commit is contained in:
Cyberes 2024-01-13 20:54:53 -07:00
parent b8a23b9a96
commit 8958481637
2 changed files with 6 additions and 6 deletions

View File

@ -3,10 +3,10 @@ import argparse
import subprocess
import sys
from datetime import datetime, timedelta
import pytz
from typing import List
import requests
import pandas as pd
import pytz
from checker import nagios
from checker.http import fetch_with_retry
@ -80,8 +80,8 @@ def main(args):
# For testing
# smart_health['data']['device']['UpdatedAt'] = '2023-04-28T23:00:03.071184465Z'
last_updated = datetime.strptime(smart_health['data']['device']['UpdatedAt'][:-10] + smart_health['data']['device']['UpdatedAt'][-6:], '%Y-%m-%dT%H:%M:%S.%f%z')
if datetime.now(pytz.utc) - timedelta(hours=args.time_delta_limit) > last_updated:
last_updated = pd.to_datetime(smart_health['data']['device']['UpdatedAt']) # , '%Y-%m-%dT%H:%M:%S.%fZ')
if datetime.now(pytz.utc) - timedelta(hours=args.time_delta_limit) > last_updated.replace(tzinfo=pytz.utc):
metrics_out_of_date = True
if smart_health and len(smart_health['data']['smart_results']):

View File

@ -12,7 +12,6 @@ aiofiles~=0.6.0
markdown~=3.4.1
psutil~=5.9.4
hurry.filesize
certifi~=2022.12.7
cloudflarepycli~=1.7.0
zfslib~=0.11.0
dnspython~=2.3.0
@ -22,4 +21,5 @@ proxmoxer==2.0.1
gunicorn
redis
flask-caching
pysnmp==4.4.12
pysnmp==4.4.12
pandas==2.0.3