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
6974248c
Commit
6974248c
authored
6 years ago
by
David Schmitz
Browse files
Options
Downloads
Patches
Plain Diff
snmp update safty check
parent
35d70a3a
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
+17
-4
17 additions, 4 deletions
flowspec/snmpstats.py
with
17 additions
and
4 deletions
flowspec/snmpstats.py
+
17
−
4
View file @
6974248c
...
...
@@ -193,6 +193,16 @@ def helper_rule_ts_parse(ts_string):
except
Exception
as
e
:
logger
.
info
(
"
helper_rule_ts_parse(): ts_string=
"
+
str
(
ts_string
)
+
"
: got exception
"
+
str
(
e
))
ts
=
None
if
ts
==
None
:
# other db may hav other time fmt:
logger
.
info
(
"
helper_rule_ts_parse(): trying with milli seconds fmt
"
)
try
:
ts
=
datetime
.
strptime
(
ts_string
,
'
%Y-%m-%d %H:%M:%S.%f+00:00
'
)
# TODO TZ offset assumed to be 00:00
except
Exception
as
e
:
logger
.
info
(
"
helper_rule_ts_parse(): ts_string=
"
+
str
(
ts_string
)
+
"
: got exception
"
+
str
(
e
))
ts
=
None
logger
.
info
(
"
helper_rule_ts_parse(): => ts=
"
+
str
(
ts
))
return
ts
def
poll_snmp_statistics
():
...
...
@@ -255,7 +265,8 @@ def poll_snmp_statistics():
toremove
=
[]
for
rule
in
history
:
try
:
if
rule
!=
'
_last_poll_no_time
'
and
rule
!=
"
_per_rule
"
:
#if rule!='_last_poll_no_time' and rule!="_per_rule":
if
rule
[:
1
]
!=
'
_
'
:
#ts = datetime.strptime(history[rule][0]["ts"], '%Y-%m-%dT%H:%M:%S.%f')
ts
=
helper_stats_store_parse_ts
(
history
[
rule
][
0
][
"
ts
"
])
if
ts
!=
None
and
(
now
-
ts
).
total_seconds
()
>=
settings
.
SNMP_REMOVE_RULES_AFTER
:
...
...
@@ -268,7 +279,8 @@ def poll_snmp_statistics():
if
settings
.
STATISTICS_PER_MATCHACTION_ADD_FINAL_ZERO
==
True
:
# for now workaround for low-level rules (by match params, not FoD rule id) no longer have data, typically because of haveing been deactivated
for
rule
in
history
:
if
rule
!=
'
_last_poll_no_time
'
and
rule
!=
"
_per_rule
"
:
#if rule!='_last_poll_no_time' and rule!="_per_rule":
if
rule
[:
1
]
!=
'
_
'
:
ts
=
history
[
rule
][
0
][
"
ts
"
]
if
ts
!=
nowstr
and
ts
==
last_poll_no_time
:
counter
=
{
"
ts
"
:
nowstr
,
"
value
"
:
null_measurement
}
...
...
@@ -298,7 +310,7 @@ def poll_snmp_statistics():
counter
=
{
"
ts
"
:
nowstr
,
"
value
"
:
newdata
[
flowspec_params_str
]}
counter_is_null
=
False
except
Exception
as
e
:
logger
.
info
(
"
poll_snmp_statistics(): STATISTICS_PER_RULE: exception: rule_id=
"
+
str
(
rule_id
)
+
"
:
"
+
str
(
e
))
logger
.
info
(
"
poll_snmp_statistics():
1
STATISTICS_PER_RULE: exception: rule_id=
"
+
str
(
rule_id
)
+
"
newdata for flowspec_params_str=
'"
+
str
(
flowspec_params_str
)
+
"'
missing
:
"
+
str
(
e
))
counter
=
{
"
ts
"
:
nowstr
,
"
value
"
:
null_measurement_missing
}
counter_is_null
=
True
else
:
...
...
@@ -365,8 +377,9 @@ def poll_snmp_statistics():
logger
.
info
(
"
poll_snmp_statistics(): Polling finished.
"
)
except
Exception
as
e
:
logger
.
error
(
e
)
#
logger.error(e)
logger
.
error
(
"
poll_snmp_statistics(): Polling failed. exception:
"
+
str
(
e
))
logger
.
error
(
"
poll_snmp_statistics():
"
,
exc_info
=
True
)
unlock_history_file
()
logger
.
info
(
"
poll_snmp_statistics(): Polling end: last_poll_no_time=
"
+
str
(
last_poll_no_time
))
...
...
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