Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FoD
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Schmitz
FoD
Commits
d74e4fe4
Commit
d74e4fe4
authored
1 year ago
by
David Schmitz
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
flowspec/snmpstats.py
+18
-8
18 additions, 8 deletions
flowspec/snmpstats.py
with
18 additions
and
8 deletions
flowspec/snmpstats.py
+
18
−
8
View file @
d74e4fe4
...
@@ -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)))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment