HI there, I’ve discovered DTrace few days ago and I’m currently stuck on a cpu stats problem. I’m trying to poll the cpu_t.cpu_acct[] array to pull idle, system and user values. So, I made this little script: ------------------------------------------------------------------------------------------------------ #!/usr/sbin/dtrace -s #pragma D option quiet
this uint64_t start; this hrtime_t timeidle; this hrtime_t timeuser; this hrtime_t timesystem; this hrtime_t timewait; this int in; dtrace:::BEGIN { this -> start = timestamp; this -> timeidle = 0; this -> timeuser = 0; this -> timesystem = 0; this -> timewait = 0; this -> in = 0; } sched:::on-cpu { this -> timeidle = curthread -> t_cpu -> cpu_acct[2]; this -> timeuser = curthread -> t_cpu -> cpu_acct[0]; this -> timesystem = curthread -> t_cpu -> cpu_acct[1]; this -> in = 1; } sched:::off-cpu /this->in/ { @user = sum(curthread->t_cpu->cpu_acct[0] - this -> timeuser); @system = sum(curthread->t_cpu->cpu_acct[1] - this -> timesystem); @idle = sum(curthread->t_cpu->cpu_acct[2] - this -> timeidle); } dtrace:::END { printf("elapsed time : %u\n",(timestamp - this -> start)); } ---------------------------------------------------------------------------------------------------------------- I’m not sure that’s the best way to get those values, but it’s the only one I found. The main problem is that the [EMAIL PROTECTED] value is higher than the “timestamp – this -> start” one, meaning that the cpu has spent more time in idle state than the whole duration of the script. What did I do wrong ? Thanks for your help :) This message posted from opensolaris.org _______________________________________________ opensolaris-discuss mailing list opensolaris-discuss@opensolaris.org