Skip to content
Snippets Groups Projects
Commit d74e4fe4 authored by David Schmitz's avatar David Schmitz
Browse files

fix/wrong_ratelimit_stats: extend auto-zero/null handling to both, read and drop metric

parent 7e1295b8
No related branches found
No related tags found
No related merge requests found
...@@ -305,17 +305,22 @@ def poll_snmp_statistics(): ...@@ -305,17 +305,22 @@ def poll_snmp_statistics():
# proper update history # proper update history
samplecount = settings.SNMP_MAX_SAMPLECOUNT samplecount = settings.SNMP_MAX_SAMPLECOUNT
for rule in newdata: for rule in newdata:
counter=None
for xtype in newdata[rule]: for xtype in newdata[rule]:
key = "value" key = "value"
if xtype!="counter": if xtype!="counter":
key = "value-"+str(xtype) key = "value-"+str(xtype)
#counter = {"ts": nowstr, "value": newdata[rule]['counter']} if counter==None:
counter = {"ts": nowstr, key: newdata[rule][xtype]} #counter = {"ts": nowstr, "value": newdata[rule]['counter']}
if rule in history: counter = {"ts": nowstr, key: newdata[rule][xtype]}
history[rule].insert(0, counter) if rule in history:
history[rule] = history[rule][:samplecount] history[rule].insert(0, counter)
history[rule] = history[rule][:samplecount]
else:
history[rule] = [counter]
else: else:
history[rule] = [counter] counter[key] = newdata[rule][xtype]
#logger.info("poll_snmp_statistics(): reused existing rule x xtype entry:"+str(counter))
# check for old rules and remove them # check for old rules and remove them
toremove = [] toremove = []
...@@ -362,8 +367,13 @@ def poll_snmp_statistics(): ...@@ -362,8 +367,13 @@ def poll_snmp_statistics():
#rule_last_updated = str(ruleobj.last_updated) # e.g. 2018-06-21 08:03:21+00:00 #rule_last_updated = str(ruleobj.last_updated) # e.g. 2018-06-21 08:03:21+00:00
#rule_last_updated = datetime.strptime(str(ruleobj.last_updated), '%Y-%m-%d %H:%M:%S+00:00') # TODO TZ offset assumed to be 00:00 #rule_last_updated = datetime.strptime(str(ruleobj.last_updated), '%Y-%m-%d %H:%M:%S+00:00') # TODO TZ offset assumed to be 00:00
rule_last_updated = helper_rule_ts_parse(str(ruleobj.last_updated)) rule_last_updated = helper_rule_ts_parse(str(ruleobj.last_updated))
counter_null = {"ts": rule_last_updated.isoformat(), "value": null_measurement }
counter_zero = {"ts": rule_last_updated.isoformat(), "value": zero_measurement } if xtype==xtype_default:
counter_null = {"ts": rule_last_updated.isoformat(), "value": null_measurement }
counter_zero = {"ts": rule_last_updated.isoformat(), "value": zero_measurement }
else:
counter_null = {"ts": rule_last_updated.isoformat(), "value": null_measurement, "value-counter": null_measurement }
counter_zero = {"ts": rule_last_updated.isoformat(), "value": zero_measurement, "value-counter": zero_measurement }
#logger.info("snmpstats: STATISTICS_PER_RULE ruleobj="+str(ruleobj)) #logger.info("snmpstats: STATISTICS_PER_RULE ruleobj="+str(ruleobj))
#logger.info("snmpstats: STATISTICS_PER_RULE ruleobj.type="+str(type(ruleobj))) #logger.info("snmpstats: STATISTICS_PER_RULE ruleobj.type="+str(type(ruleobj)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment