2 from __future__
import print_function
5 from resource
import getrusage, RUSAGE_SELF, RUSAGE_CHILDREN
6 from time
import sleep, time
8 PROCMONVERSION=
"$Id: DQProcMonitor.py 359096 2011-04-15 13:25:36Z kama $"
11 fieldnames=[
"utime",
"stime",
"maxrss",
"shrmem",
"ushrmem",
"ushrstk",
"minflt",
12 "majflt",
"nswap",
"inblock",
"oublock",
"msgsnd",
"msgrcv",
13 "nsignals",
"nvcontsw",
"nivcontsw"]
14 return ", ".
join([
"=".
join([n,
"%s"%v]
if isinstance(v, int)
else [n,
"%f"%v])
for n,v
in zip(fieldnames,rusage)])
20 pollPeriod = kwargs.pop(
"poll_period", 1.0)
23 filename = kwargs.pop(
"file_name",
"DQResourceUtilization.txt")
24 print(
"Monitoring thread poll period=",pollPeriod,
"seconds, output file name=\"%s\""%filename)
25 with open(filename,
'w')
as resoutfile:
28 ru=getrusage(RUSAGE_SELF)
29 cru=getrusage(RUSAGE_CHILDREN)
40 from threading
import Thread
41 ResMon=Thread(target=DQProcMon,args=[],kwargs={
'poll_period':pollPeriod,
42 'file_name':file_name})
45 print(
"========Starting DQProcMonThread==============")