Skip to content

Commit 2315184

Browse files
authored
Wrapping bytes_to_datetime in a try except decorator
1 parent 07445c7 commit 2315184

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

snmpexporter/prometheus.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,12 @@ def bytes_to_datetime(b):
120120
utc_hour=hour-int(b[9])
121121
utc_minutes=minutes-int(b[10])
122122

123-
ct = datetime.datetime(year,month,day,utc_hour,utc_minutes,seconds,
123+
try:
124+
ct = datetime.datetime(year,month,day,utc_hour,utc_minutes,seconds,
124125
tzinfo=datetime.timezone.utc).timestamp()
125-
return ct
126+
return ct
127+
except:
128+
return float('nan')
126129

127130

128131
CONVERTERS = {

0 commit comments

Comments
 (0)