Mercurial > code > home > repos > homeauto
view lib/standardservice/scalessetup.py @ 1404:025c91f8baa4
frontwindow display config, move keys out
Ignore-this: 1d725d6548558e8cbcba30768c604c9f
darcs-hash:0e084d33fda38aa2689131cb5c746bbc202b05af
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Tue, 23 Jul 2019 10:25:56 -0700 |
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)