DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
flxlibs
scripts
flxrpc
server
felixRPCMonitor.py
Go to the documentation of this file.
1
from
SimpleXMLRPCServer
import
SimpleXMLRPCServer
2
from
SimpleXMLRPCServer
import
SimpleXMLRPCRequestHandler
3
from
subprocess
import
call, Popen, PIPE
4
import
re
5
6
pathBase=
"<felix_dist_dir>"
7
8
def
shell_source
(script):
9
"""Sometime you want to emulate the action of "source" in bash,
10
settings some environment variables. Here is a way to do it."""
11
import
subprocess, os
12
pipe = subprocess.Popen(
". %s; env"
% script, stdout=subprocess.PIPE, shell=
True
)
13
output = pipe.communicate()[0]
14
#print output
15
env = dict((line.split(
"="
, 1)
for
line
in
output.splitlines()))
16
os.environ.update(env)
17
18
def
callSubp
(appDict):
19
p = Popen(appDict, stdin=PIPE, stdout=PIPE, stderr=PIPE)
20
output, err = p.communicate(b
"input data that is passed to subprocess' stdin"
)
21
return
output, err, p.returncode
22
23
shell_source
(
"<felix_dist_dir>/setup.sh"
)
24
25
# Restrict to a particular path.
26
class
RequestHandler
(SimpleXMLRPCRequestHandler):
27
rpc_paths = (
'/RPC2'
,)
28
29
# Create server
30
server = SimpleXMLRPCServer((
"0.0.0.0"
, 10001),requestHandler=RequestHandler)
31
server.register_introspection_functions()
32
33
class
FelixMonitors
:
34
35
def
heartbeat
(self):
36
return
"OK"
37
38
def
lspci
(self, card=0):
39
ret1 =
callSubp
([
"lspci"
])
40
ret1Split = ret1[0].split(
'\n'
)
41
devid = [line
for
line
in
ret1Split
if
"FPGA Card"
in
line]
42
if
not
devid:
43
return
" "
,
" "
,
" "
,
" "
44
ret2 =
callSubp
([
"lspci"
,
"-s"
, devid[0].split(
' '
)[0],
"-vvvvv"
])
45
ret2Split = ret2[0].split(
'\n'
)
46
control = [line
for
line
in
ret2Split
if
"Control"
in
line]
47
status = [line
for
line
in
ret2Split
if
"Status"
in
line]
48
numa = [line
for
line
in
ret2Split
if
"NUMA"
in
line]
49
return
devid, control, status, numa
50
51
def
driver
(self, card=0):
52
ret =
callSubp
([
"/etc/init.d/drivers_flx"
,
"status"
])
53
retSplit = ret[0].split(
'\n'
)
54
version = [line
for
line
in
retSplit
if
"FLX driver"
in
line]
55
cmem = [line
for
line
in
retSplit
if
"GFPBPA"
in
line]
56
githash = [line
for
line
in
retSplit
if
"GIT hash"
in
line]
57
return
version, cmem, githash
58
59
def
links
(self, card=0):
60
c0 =
"-d "
+str(card)
61
c1 =
"-d "
+str(card+1)
62
ret =
callSubp
([pathBase+
"flxcard/flx-info"
,
"GBT"
])
63
return
ret
64
retSplit = ret[0].split(
'\n'
)
65
channel = [line
for
line
in
retSplit
if
"Channel"
in
line]
66
aligned = [line
for
line
in
retSplit
if
"Aligned"
in
line]
67
return
channel, aligned
68
69
server.register_instance(
FelixMonitors
())
70
71
# Run the server's main loop
72
server.serve_forever()
73
74
felixRPCMonitor.FelixMonitors
Definition
felixRPCMonitor.py:33
felixRPCMonitor.FelixMonitors.lspci
lspci(self, card=0)
Definition
felixRPCMonitor.py:38
felixRPCMonitor.FelixMonitors.links
links(self, card=0)
Definition
felixRPCMonitor.py:59
felixRPCMonitor.FelixMonitors.heartbeat
heartbeat(self)
Definition
felixRPCMonitor.py:35
felixRPCMonitor.FelixMonitors.driver
driver(self, card=0)
Definition
felixRPCMonitor.py:51
felixRPCMonitor.RequestHandler
Definition
felixRPCMonitor.py:26
felixRPCMonitor.callSubp
callSubp(appDict)
Definition
felixRPCMonitor.py:18
felixRPCMonitor.shell_source
shell_source(script)
Definition
felixRPCMonitor.py:8
Generated on
for DUNE-DAQ by
1.17.0