Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
km3mon
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
Container Registry
Model registry
Operate
Environments
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
km3py
km3mon
Commits
a333a725
Commit
a333a725
authored
5 years ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Add time sync monitoring script
parent
29ad926e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/timesync_monitor.py
+77
-0
77 additions, 0 deletions
scripts/timesync_monitor.py
with
77 additions
and
0 deletions
scripts/timesync_monitor.py
0 → 100644
+
77
−
0
View file @
a333a725
#!/usr/bin/env python
# coding=utf-8
# Filename: timesync_monitor.py
# Author: Tamas Gal <tgal@km3net.de>
# vim: ts=4 sw=4 et
"""
Monitors the time sync of DOMs using the MSG of the CLB DOM STATUS 1 field
from the supernova timeslice stream (IO_TSSN).
Usage:
timesync_monitor.py [options]
timesync_monitor.py (-h | --help)
Options:
-l LIGIER_IP The IP of the ligier [default: 127.0.0.1].
-p LIGIER_PORT The port of the ligier [default: 5553].
-m LOGGING_LIGIER_IP The IP of the logging ligier [default: 127.0.0.1].
-q LOGGING_LIGIER_PORT The port of the logging ligier [default: 5553].
-h --help Show this screen.
"""
import
datetime
import
km3pipe
as
kp
class
TimeSyncChecker
(
kp
.
Module
):
def
configure
(
self
):
logging_ligier
=
self
.
require
(
"
logging_ligier_ip
"
)
logging_ligier_port
=
self
.
require
(
"
logging_ligier_port
"
)
self
.
ch_client
=
kp
.
controlhost
.
Client
(
logging_ligier
,
port
=
logging_ligier_port
)
self
.
alert
=
kp
.
time
.
Cuckoo
(
interval
=
10
,
callback
=
self
.
_alert
)
def
_alert
(
self
,
msg
):
date
=
datetime
.
datetime
.
utcnow
().
strftime
(
"
%c
"
)
msg
=
f
"
ALERT (MONITORING)
{
date
}
:
{
msg
}
"
print
(
msg
)
self
.
ch_client
.
put_message
(
"
MSG
"
,
"
Monitoring Test
"
)
def
process
(
self
,
blob
):
dom_ids
=
[]
for
dom_id
,
frameinfo
in
blob
[
'
TimesliceFrameInfos
'
].
items
():
valid_time_sync
=
bool
(
frameinfo
.
dom_status
[
0
]
&
(
1
<<
(
32
-
1
)))
if
not
valid_time_sync
:
dom_ids
.
append
(
dom_id
)
if
dom_ids
:
self
.
alert
(
"
invalid time sync for DOM ID: {}
"
.
format
(
'
,
'
.
join
(
map
(
str
,
dom_ids
))))
return
blob
def
finish
(
self
):
self
.
ch_client
.
_disconnect
()
def
main
():
from
docopt
import
docopt
args
=
docopt
(
__doc__
)
ligier_ip
=
args
[
'
-l
'
]
ligier_port
=
int
(
args
[
'
-p
'
])
logging_ligier_ip
=
args
[
'
-m
'
]
logging_ligier_port
=
int
(
args
[
'
-q
'
])
pipe
=
kp
.
Pipeline
()
pipe
.
attach
(
kp
.
io
.
ch
.
CHPump
,
host
=
ligier_ip
,
port
=
ligier_port
,
tags
=
"
IO_TSSN
"
)
pipe
.
attach
(
kp
.
io
.
daq
.
TimesliceParser
)
pipe
.
attach
(
TimeSyncChecker
,
logging_ligier_ip
=
logging_ligier_ip
,
logging_ligier_port
=
logging_ligier_port
)
pipe
.
drain
()
if
__name__
==
'
__main__
'
:
main
()
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