Fix for multiple connect_time values, #12
This commit is contained in:
parent
abaa555a7a
commit
9144e64be6
1 changed files with 6 additions and 6 deletions
|
@ -203,7 +203,7 @@ def logparse(
|
|||
ip_type = ipadd(ip).iptype()
|
||||
if ip_type in monitored_ip_types and ip:
|
||||
info = gi.city(ip)
|
||||
if info is not None:
|
||||
if info:
|
||||
geohash = encode(info.location.latitude, info.location.longitude)
|
||||
geohash_fields['count'] = 1
|
||||
geohash_tags['geohash'] = geohash
|
||||
|
@ -234,15 +234,15 @@ def logparse(
|
|||
data = search(log, line)
|
||||
if ip_type in monitored_ip_types and ip:
|
||||
info = gi.city(ip)
|
||||
if info is not None:
|
||||
if info:
|
||||
datadict = data.groupdict()
|
||||
log_data_fields['count'] = 1
|
||||
log_data_fields['bytes_sent'] = int(datadict['bytes_sent'])
|
||||
log_data_fields['request_time'] = float(datadict['request_time'])
|
||||
if datadict['connect_time'] == '-':
|
||||
log_data_fields['connect_time'] = 0.0
|
||||
else:
|
||||
log_data_fields['connect_time'] = float(datadict['connect_time'])
|
||||
try:
|
||||
log_data_fields['connect_time'] = float(datadict['connect_time']) if datadict['connect_time'] != '-' else 0.0
|
||||
except ValueError:
|
||||
log_data_fields['connect_time'] = str(datadict['connect_time'])
|
||||
log_data_tags['ip'] = datadict['ipaddress']
|
||||
log_data_tags['datetime'] = datetime.strptime(datadict['dateandtime'], '%d/%b/%Y:%H:%M:%S %z')
|
||||
log_data_tags['remote_user'] = datadict['remote_user']
|
||||
|
|
Loading…
Reference in a new issue