mirror of
https://github.com/koush/scrypted.git
synced 2026-05-04 21:30:30 +01:00
server: add python process stats
This commit is contained in:
@@ -25,6 +25,7 @@ import shutil
|
||||
import gc
|
||||
import threading
|
||||
import gi
|
||||
import resource
|
||||
gi.require_version('Gst', '1.0')
|
||||
|
||||
from gi.repository import Gst, GLib
|
||||
@@ -316,6 +317,23 @@ async def async_main(loop: AbstractEventLoop):
|
||||
peer.params['getRemote'] = lambda api, pluginId: PluginRemote(
|
||||
api, pluginId, loop)
|
||||
|
||||
def oob_runner():
|
||||
ptime = round(time.process_time() * 1000000)
|
||||
heapTotal = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
|
||||
oob = {
|
||||
'type': 'stats',
|
||||
'cpuUsage': {
|
||||
'user': ptime,
|
||||
'system': 0,
|
||||
},
|
||||
'memoryUsage': {
|
||||
'heapTotal': heapTotal,
|
||||
},
|
||||
}
|
||||
peer.sendOob(oob)
|
||||
loop.call_later(10, oob_runner)
|
||||
oob_runner()
|
||||
|
||||
await readLoop(loop, peer, reader)
|
||||
|
||||
|
||||
|
||||
@@ -370,3 +370,9 @@ class RpcPeer:
|
||||
}
|
||||
self.send(paramMessage, reject)
|
||||
return await self.createPendingResult(send)
|
||||
|
||||
def sendOob(self, oob: Any):
|
||||
self.send({
|
||||
'type': 'oob',
|
||||
'oob': oob,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user