Skip Menu |

This queue is for tickets about the Proc-ProcessTable CPAN distribution.

Report information
The Basics
Id: 80391
Status: resolved
Priority: 0/
Queue: Proc-ProcessTable

People
Owner: Nobody in particular
Requestors: thatsafunnyname [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.46
Fixed in: (no value)



Subject: Process::Process pctcpu does not include system CPU time
Hello and thank you for Proc-ProcessTable-0.46 I noticed in Process::Process "pctcpu percent cpu used since process started" but in Os.c in the calc_prec function the percentage is only using the user CPU time and not the system CPU time. Changing: << float pctcpu = 100.0f * ( (prs->utime) / 1e6) / (time(NULL) - prs- Show quoted text
>start_time);
>> float pctcpu = 100.0f * ( (prs->utime + prs->stime) / 1e6) /
(time(NULL) - prs->start_time); Fixes this. I am on linux kernel 2.6.18-308.11.1.el5. Cheers, Peter (Stig) Edwards
Subject: Re: [rt.cpan.org #80391] Process::Process pctcpu does not include system CPU time
Date: Fri, 26 Oct 2012 12:55:07 +0200
To: bug-Proc-ProcessTable [...] rt.cpan.org
From: Jens Rehsack <rehsack [...] gmail.com>
2012/10/25 Peter (Stig) Edwards via RT <bug-Proc-ProcessTable@rt.cpan.org>: Show quoted text
> Thu Oct 25 10:19:58 2012: Request 80391 was acted upon. > Transaction: Ticket created by thatsafunnyname > Queue: Proc-ProcessTable > Subject: Process::Process pctcpu does not include system CPU time > Broken in: 0.46 > Severity: (no value) > Owner: Nobody > Requestors: thatsafunnyname@gmail.com > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=80391 > > > > Hello and thank you for Proc-ProcessTable-0.46 > > I noticed in Process::Process > > "pctcpu percent cpu used since process started" > > but in Os.c in the calc_prec function the percentage is only using the > user CPU time and not the system CPU time. > > Changing: > > << float pctcpu = 100.0f * ( (prs->utime) / 1e6) / (time(NULL) - prs-
>>start_time);
>>> float pctcpu = 100.0f * ( (prs->utime + prs->stime) / 1e6) /
> (time(NULL) - prs->start_time); > > Fixes this. I am on linux kernel 2.6.18-308.11.1.el5. > > Cheers, > Peter (Stig) Edwards
Hi Peter, I can tell you only the same like I tell all others: There're some prerequisites not fulfilled needed for proper P::PT rewrite fixing all (or most) reported issues. Depending on your requirements please check out libstatgrab (patched) at http://www.netbsd.org/~sno/smart-snmpd/ That code is widely tested and should be easy to integrate. /Jens
From: thatsafunnyname [...] gmail.com
Hello Jens, Thanks for the reply. As a workaround for pctcpu, in place of: $p->{'pctcpu'} I am using: pctcpu($p) with this sub defined: my $TIME = time; sub pctcpu{ my $p = shift; my $t_diff = $TIME - $p->{'start'}; if (0==$t_diff){ return 0; } return sprintf '%.2f', ( $p->{'utime'} + $p->{'stime'} ) / ($t_diff*10000); } I'll have to take a look at: http://www.i-scream.org/libstatgrab/ http://search.cpan.org/dist/Unix-Statgrab/ sometime. RHEL[56] packages are available from: http://fedoraproject.org/wiki/EPEL so that is convenient for me. Thank you.