Mercurial > code > home > repos > homeauto
view lib/standardservice/scalessetup.py @ 1529:0e0713fd23e7
build: place generated nim in its own dir
Ignore-this: 89c9a75595f0465d4efc44ef1b96abd7
darcs-hash:6a695011fe841ce7d6c020ebc33b6099ff26d964
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Thu, 23 Jan 2020 23:59:41 -0800 |
parents | 2e0c4ba9d7cf |
children |
line wrap: on
line source
import time from greplin import scales from twisted.internet import task import psutil def gatherProcessStats(): procStats = scales.collection('/process', scales.DoubleStat('time'), scales.DoubleStat('cpuPercent'), scales.DoubleStat('memMb'), ) proc = psutil.Process() lastCpu = [0.] def updateTimeStat(): now = time.time() procStats.time = round(now, 3) if now - lastCpu[0] > 3: procStats.cpuPercent = round(proc.cpu_percent(), 6) # (since last call) lastCpu[0] = now procStats.memMb = round(proc.memory_info().rss / 1024 / 1024, 6) task.LoopingCall(updateTimeStat).start(.1)