From 8f3612ae239a0323c81c6be7083ce1fe032b8ef3 Mon Sep 17 00:00:00 2001 From: liaozhaoyan Date: Mon, 10 Jul 2023 15:35:18 +0800 Subject: [PATCH] correct some rem. --- .../unity/collector/guard/guardSched.lua | 4 +- .../tools/monitor/unity/test/unix/pyunix.py | 2 +- .../monitor/unity/test/unix/uniServer.py | 38 +++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 source/tools/monitor/unity/test/unix/uniServer.py diff --git a/source/tools/monitor/unity/collector/guard/guardSched.lua b/source/tools/monitor/unity/collector/guard/guardSched.lua index e248ea1c..46c21d14 100644 --- a/source/tools/monitor/unity/collector/guard/guardSched.lua +++ b/source/tools/monitor/unity/collector/guard/guardSched.lua @@ -15,7 +15,7 @@ function CguardSched:_init_(tid, procs, names, jperiod) self._jperiod = jperiod self._procs = procs self._names = names - self._limit = 1e5*5 -- 500 ms + self._limit = 1e5 * 5 -- 500 ms end function CguardSched:proc(t, lines) @@ -38,7 +38,7 @@ function CguardSched:proc(t, lines) if stop - start - overTime >= self._limit then -- print(stop - start) local j2 = self._stat:jiffies() - if j2 - j1 >= self._limit / 1e6 * self._jperiod * 3 / 4 then -- 3/4 time used bye plugin + if j2 - j1 >= self._limit / 1e6 * self._jperiod * 3 / 4 then -- 3/4 time used by plugin table.insert(toRemove, i) end end diff --git a/source/tools/monitor/unity/test/unix/pyunix.py b/source/tools/monitor/unity/test/unix/pyunix.py index c215808a..2355837f 100644 --- a/source/tools/monitor/unity/test/unix/pyunix.py +++ b/source/tools/monitor/unity/test/unix/pyunix.py @@ -23,6 +23,6 @@ if __name__ == "__main__": nf = CnfPut() i = 10 while True: - nf.puts('io_burst,disk=/dev/vda1 limit=10.0,max=%d,log="io log burst"' % i) + print(nf.puts('io_burst,disk=/dev/vda1 limit=10.0,max=%d,log="io log burst"' % i)) i += 1 time.sleep(5) \ No newline at end of file diff --git a/source/tools/monitor/unity/test/unix/uniServer.py b/source/tools/monitor/unity/test/unix/uniServer.py new file mode 100644 index 00000000..38a5fc2d --- /dev/null +++ b/source/tools/monitor/unity/test/unix/uniServer.py @@ -0,0 +1,38 @@ +import os +import socket +import select + +class SocketServer(object): + def __init__(self, sFile): + super(SocketServer, self).__init__() + + server_address = sFile + socket_family = socket.AF_UNIX + socket_type = socket.SOCK_DGRAM + self._sock = socket.socket(socket_family, socket_type) + self._sock.bind(server_address) + + def loop(self, cb): + fd = self._sock.fileno() + with select.epoll() as poll: + poll.register(fd, select.EPOLLIN) + while True: + events = poll.poll(-1) + for fd, event in events: + if event & select.EPOLLIN: + s = os.read(fd, 128 * 1024).decode() + cb(s) + if event & (select.EPOLLHUP | select.EPOLLERR): + return -1 + + def __del__(self): + self._sock.close() + + +def cbTest(s): + print("recv: %s" % s) + + +if __name__ == "__main__": + s = SocketServer("/tmp/sysom") + s.loop(cbTest) \ No newline at end of file -- Gitee