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
2e44c7a6
Commit
2e44c7a6
authored
11 months ago
by
David Schmitz
Browse files
Options
Downloads
Patches
Plain Diff
feature/jusnossnmpstats: renamed flowspec/snmpstats.py to utils/junossnmpstats.py
parent
c38fd44d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flowspec/tasks.py
+5
-5
5 additions, 5 deletions
flowspec/tasks.py
utils/junossnmpstats.py
+10
-10
10 additions, 10 deletions
utils/junossnmpstats.py
with
15 additions
and
15 deletions
flowspec/tasks.py
+
5
−
5
View file @
2e44c7a6
...
...
@@ -412,7 +412,7 @@ def exit_process():
#@shared_task(ignore_result=True, time_limit=580, soft_time_limit=550)
@shared_task
(
ignore_result
=
True
,
max_retries
=
0
)
def
poll_snmp_statistics
():
from
flowspec
import
snmpstats
from
utils
import
junos
snmpstats
if
not
snmp_lock_create
(
0
):
return
...
...
@@ -431,7 +431,7 @@ def poll_snmp_statistics():
pid
=
os
.
getpid
()
logger
.
info
(
"
poll_snmp_statistics(): in child process (pid=
"
+
str
(
pid
)
+
"
, ppid=
"
+
str
(
ppid
)
+
"
)
"
)
try
:
snmpstats
.
poll_snmp_statistics
()
junos
snmpstats
.
poll_snmp_statistics
()
except
Exception
as
e
:
logger
.
error
(
"
poll_snmp_statistics(): exception occured in snmp poll (pid=
"
+
str
(
pid
)
+
"
, ppid=
"
+
str
(
ppid
)
+
"
):
"
+
str
(
e
))
snmp_lock_remove
()
...
...
@@ -481,7 +481,7 @@ def snmp_add_initial_zero_value_inner(routepk, route_id, route, snmpstats, add_i
@shared_task
(
ignore_result
=
True
,
max_retries
=
0
)
def
snmp_add_initial_zero_value
(
routepk
,
route_id
,
add_initial_value
=
True
,
zero_or_null
=
True
,
reset_remember_last_value
=
True
,
update_remember_last_value
=
False
):
from
flowspec
import
snmpstats
from
utils
import
junos
snmpstats
logger
.
info
(
"
snmp_add_initial_zero_value(): routepk=
"
+
str
(
routepk
)
+
"
route_id=
"
+
str
(
route_id
)
+
"
add_initial_value=
"
+
str
(
add_initial_value
)
+
"
zero_or_null=
"
+
str
(
zero_or_null
)
+
"
reset_remember_last_value=
"
+
str
(
reset_remember_last_value
)
+
"
update_remember_last_value=
"
+
str
(
update_remember_last_value
))
route
=
None
...
...
@@ -497,7 +497,7 @@ def snmp_add_initial_zero_value(routepk, route_id, add_initial_value=True, zero_
if
not
use_fork
:
snmp_add_initial_zero_value_inner
(
routepk
,
route_id
,
route
,
snmpstats
,
add_initial_value
=
add_initial_value
,
zero_or_null
=
zero_or_null
,
reset_remember_last_value
=
reset_remember_last_value
,
update_remember_last_value
=
update_remember_last_value
)
snmp_add_initial_zero_value_inner
(
routepk
,
route_id
,
route
,
junos
snmpstats
,
add_initial_value
=
add_initial_value
,
zero_or_null
=
zero_or_null
,
reset_remember_last_value
=
reset_remember_last_value
,
update_remember_last_value
=
update_remember_last_value
)
else
:
signal
.
signal
(
signal
.
SIGCHLD
,
handleSIGCHLD
)
...
...
@@ -514,7 +514,7 @@ def snmp_add_initial_zero_value(routepk, route_id, add_initial_value=True, zero_
pid
=
os
.
getpid
()
logger
.
info
(
"
snmp_add_initial_zero_value(): in child process (pid=
"
+
str
(
pid
)
+
"
, ppid=
"
+
str
(
ppid
)
+
"
)
"
)
snmp_add_initial_zero_value_inner
(
routepk
,
route_id
,
route
,
snmpstats
,
add_initial_value
=
add_initial_value
,
zero_or_null
=
zero_or_null
,
reset_remember_last_value
=
reset_remember_last_value
,
update_remember_last_value
=
update_remember_last_value
)
snmp_add_initial_zero_value_inner
(
routepk
,
route_id
,
route
,
junos
snmpstats
,
add_initial_value
=
add_initial_value
,
zero_or_null
=
zero_or_null
,
reset_remember_last_value
=
reset_remember_last_value
,
update_remember_last_value
=
update_remember_last_value
)
#exit_process()
...
...
This diff is collapsed.
Click to expand it.
flowspec/
snmpstats.py
→
utils/junos
snmpstats.py
+
10
−
10
View file @
2e44c7a6
...
...
@@ -331,7 +331,7 @@ def poll_snmp_statistics():
# get new data
try
:
logger
.
debug
(
"
poll_snmp_statistics(): snmpstats: nowstr=
"
+
str
(
nowstr
))
logger
.
debug
(
"
poll_snmp_statistics():
junos
snmpstats: nowstr=
"
+
str
(
nowstr
))
newdata
=
get_snmp_stats
()
except
Exception
as
e
:
logger
.
error
(
"
poll_snmp_statistics(): get_snmp_stats failed:
"
+
str
(
e
))
...
...
@@ -359,7 +359,7 @@ def poll_snmp_statistics():
except
Exception
as
e
:
logger
.
error
(
"
poll_snmp_statistics(): got exception while trying to access history[_last_poll_time]:
"
+
str
(
e
))
last_poll_no_time
=
None
logger
.
debug
(
"
poll_snmp_statistics(): snmpstats: last_poll_no_time=
"
+
str
(
last_poll_no_time
))
logger
.
debug
(
"
poll_snmp_statistics():
junos
snmpstats: last_poll_no_time=
"
+
str
(
last_poll_no_time
))
history
[
'
_last_poll_no_time
'
]
=
nowstr
try
:
...
...
@@ -369,7 +369,7 @@ def poll_snmp_statistics():
# do actual update
try
:
logger
.
debug
(
"
poll_snmp_statistics(): before store: snmpstats: nowstr=
"
+
str
(
nowstr
)
+
"
, last_poll_no_time=
"
+
str
(
last_poll_no_time
))
logger
.
debug
(
"
poll_snmp_statistics(): before store:
junos
snmpstats: nowstr=
"
+
str
(
nowstr
)
+
"
, last_poll_no_time=
"
+
str
(
last_poll_no_time
))
#newdata = get_snmp_stats()
# proper update history
...
...
@@ -433,7 +433,7 @@ def poll_snmp_statistics():
# xtype=str(limit_rate)
xtype
=
helper_get_countertype_of_rule
(
ruleobj
)
logger
.
debug
(
"
snmpstat
s
: STATISTICS_PER_RULE rule_id=
"
+
str
(
rule_id
)
+
"
rule_status=
"
+
str
(
rule_status
)
+
"
xtype=
"
+
str
(
xtype
))
logger
.
debug
(
"
poll_
snmp
_
stat
istics()
: STATISTICS_PER_RULE rule_id=
"
+
str
(
rule_id
)
+
"
rule_status=
"
+
str
(
rule_status
)
+
"
xtype=
"
+
str
(
xtype
))
#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
=
helper_rule_ts_parse
(
str
(
ruleobj
.
last_updated
))
...
...
@@ -445,12 +445,12 @@ def poll_snmp_statistics():
counter_null
=
{
"
ts
"
:
rule_last_updated
.
isoformat
(),
"
value
"
:
null_measurement
,
"
value_matched
"
:
null_measurement
}
counter_zero
=
{
"
ts
"
:
rule_last_updated
.
isoformat
(),
"
value
"
:
zero_measurement
,
"
value_matched
"
:
zero_measurement
}
#logger.info("snmpstat
s
: STATISTICS_PER_RULE ruleobj="+str(ruleobj))
#logger.info("snmpstat
s
: STATISTICS_PER_RULE ruleobj.type="+str(type(ruleobj)))
#logger.info("snmpstat
s
: STATISTICS_PER_RULE ruleobj.id="+str(rule_id))
#logger.info("snmpstat
s
: STATISTICS_PER_RULE ruleobj.status="+rule_status)
#logger.info("
poll_
snmp
_
stat
istics()
: STATISTICS_PER_RULE ruleobj="+str(ruleobj))
#logger.info("
poll_
snmp
_
stat
istics()
: STATISTICS_PER_RULE ruleobj.type="+str(type(ruleobj)))
#logger.info("
poll_
snmp
_
stat
istics()
: STATISTICS_PER_RULE ruleobj.id="+str(rule_id))
#logger.info("
poll_
snmp
_
stat
istics()
: STATISTICS_PER_RULE ruleobj.status="+rule_status)
flowspec_params_str
=
create_junos_name
(
ruleobj
)
logger
.
debug
(
"
snmpstat
s
: STATISTICS_PER_RULE flowspec_params_str=
"
+
str
(
flowspec_params_str
))
logger
.
debug
(
"
poll_
snmp
_
stat
istics()
: STATISTICS_PER_RULE flowspec_params_str=
"
+
str
(
flowspec_params_str
))
if
rule_status
==
"
ACTIVE
"
:
try
:
...
...
@@ -565,7 +565,7 @@ def poll_snmp_statistics():
history_per_rule
[
rule_id
]
=
rec
[:
samplecount
]
except
Exception
as
e
:
logger
.
error
(
"
snmpstat
s
: 2 STATISTICS_PER_RULE: exception:
"
+
str
(
e
))
logger
.
error
(
"
poll_
snmp
_
stat
istics()
: 2 STATISTICS_PER_RULE: exception:
"
+
str
(
e
))
history
[
'
_per_rule
'
]
=
history_per_rule
...
...
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