@cryptotaxi247 / netdata-1 / commits / 8ab43b428

epoch time format and ifinite lease cases

wungad committed Nov 22, 2017 at 12:57 UTC 8ab43b4280b8afc1c3db912522979970dc1ec8e7
1 file changed +10 -2
python.d/isc_dhcpd.chart.py
+10 -2
@@ -56,7 +56,6 @@ class Service(SimpleService):
56
57 # Will work only with 'default' db-time-format (weekday year/month/day hour:minute:second)
58 # TODO: update algorithm to parse correctly 'local' db-time-format
59 - # (epoch <seconds-since-epoch>; # <day-name> <month-name> <day-number> <hours>:<minutes>:<seconds> <year>)
59 # Also only ipv4 supported
60
61 def check(self):
@@ -147,7 +146,16 @@ class Service(SimpleService):
146
147
148 def binding_active(lease_end_time, current_time):
150 - return mktime(strptime(lease_end_time, '%w %Y/%m/%d %H:%M:%S')) - current_time > 0
149 + # lease_end_time might be epoch
150 + if lease_end_time.startswith('epoch'):
151 + epoch = int(lease_end_time.split()[1].replace(';',''))
152 + return epoch - current_time > 0
153 + # max. int for lease-time causes lease to expire in year 2038.
154 + # dhcpd puts 'never' in the ends section of active lease
155 + elif lease_end_time == 'never':
156 + return True
157 + else:
158 + return mktime(strptime(lease_end_time, '%w %Y/%m/%d %H:%M:%S')) - current_time > 0
159
160
161 def find_lease(value):