Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

pcp pidstat fixes #98

Merged
merged 3 commits into from Jul 7, 2016
@@ -131,7 +131,7 @@ def system_percent(self):
def total_percent(self):
if self.user_percent() is not None and self.guest_percent() is not None and self.system_percent() is not None:
- return self.user_percent()+self.guest_percent()+self.system_percent()
+ return float("%.2f"%(self.user_percent()+self.guest_percent()+self.system_percent()))
else:
return None
@@ -460,28 +460,35 @@ def extraOptions(self, opt,optarg, index):
elif opt == 'U':
PidstatOptions.show_process_user = True
PidstatOptions.filtered_process_user = optarg
- elif opt == 'P':
+ elif opt == 'p':
if optarg == "ALL" or optarg == "SELF":
PidstatOptions.pid_filter = optarg
else:
PidstatOptions.pid_filter = "ALL"
try:
- PidstatOptions.pid_list = map(lambda x:int(x),optarg.split(','))
+ PidstatOptions.pid_list = list(map(lambda x:int(x),optarg.split(',')))
except ValueError as e:
print ("Invalid Process Id List: use comma separated pids without whitespaces")
sys.exit(1)
+ def override(self, opt):
+ """ Override standard PCP options to match pidstat(1) """
+ if (opt == 'p'):
+ return 1
+ return 0
+
def __init__(self):
- pmapi.pmOptions.__init__(self,"a:s:t:G:IU::P:RrkV?")
+ pmapi.pmOptions.__init__(self,"a:s:t:G:IU::p:RrkV?")
self.pmSetOptionCallback(self.extraOptions)
+ self.pmSetOverrideCallback(self.override)
self.pmSetLongOptionHeader("General options")
self.pmSetLongOptionArchive()
self.pmSetLongOptionSamples()
self.pmSetLongOptionInterval()
self.pmSetLongOption("process-name",1,"G","NAME","Select process names using regular expression.")
self.pmSetLongOption("",0,"I","","In SMP environment, show CPU usage per processor.")
self.pmSetLongOption("user-name",2,"U","[USERNAME]","Show real user name of the tasks and optionally filter by user name.")
- self.pmSetLongOption("pid-list",1,"P","PID1,PID2.. ","Show stats for specified pids, Use SELF for current process and ALL for all processes.")
+ self.pmSetLongOption("pid-list",1,"p","PID1,PID2.. ","Show stats for specified pids, Use SELF for current process and ALL for all processes.")
self.pmSetLongOption("",0,"R","","Report realtime priority and scheduling policy information.")
self.pmSetLongOption("",0,"r","","Report page faults and memory utilization.")
self.pmSetLongOption("",0,"k","","Report stack utilization.")