On Thu, Jan 14, 2010 at 10:50 PM, Sebastian Spies
<sebastian.sp...@de-cix.net> wrote:
> Aaron Mason wrote:
>> different exit value for each error condition.  It's usually good
>> practice to send a numeric error code and let your script handle the
>> error itself.  By all means keep the message there, but don't make it
>> impossible to use in a script.
>>
>> </offtopic>
>>
>> Try info->p_pctcpu instead.
>>
> u_int32_t p_pctcpu;             /* FIXPT_T: %cpu for this process during
> p_swtime */
> u_int32_t p_swtime;             /* U_INT: Time swapped in or out. */
>
> My understanding is, that pctcpu is a normalized value over swtime,
> which is useless for me.

You want the load of a process on a per second basis - that actually is.

Consider this diff:

--- cpucalc-old.c       Fri Jan 15 21:46:32 2010
+++ cpucalc.c   Fri Jan 15 21:44:55 2010
@@ -30,7 +30,7 @@
                exit(1);
        }

-       printf("%x\n",info->p_cpticks);
+       printf("%x in %x\n",info->p_pctcpu, info->p_swtime);

        exit(0);
 }

And this test run:

# while sleep 1; do ./cpucalc 21380; done
0 in 15ca3
0 in 15ca4
0 in 15ca5
^C

So there it is - it already is calculated on a per second basis for you.

HTH

>
> --
> Sebastian Spies                      e-mail: sebastian.sp...@de-cix.net
> DE-CIX Management GmbH
> Lindleystr. 12, 60314 Frankfurt      Mobile: +49 1577 7830883
> Geschaeftsfuehrer Harald A. Summa    Fax: +49 69 4056 2716
> Registergericht AG Koeln, HRB 51135  http://www.de-cix.net
> Zentrale: Lichtstr. 43i, 50825 Koeln
>
>
>



--
Aaron Mason - Programmer, open source addict
I've taken my software vows - for beta or for worse

Reply via email to