[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cronjobs and top not getting along




> 181     int user = Procinfo::cpu_time[Procinfo::CPU_USER]
> 182                - Procinfo::old_cpu_time[Procinfo::CPU_USER];
> 183     int nice = Procinfo::cpu_time[Procinfo::CPU_NICE]
> 184                - Procinfo::old_cpu_time[Procinfo::CPU_NICE];
> 185     int system = Procinfo::cpu_time[Procinfo::CPU_SYSTEM]
> 186                  - Procinfo::old_cpu_time[Procinfo::CPU_SYSTEM];
> 187     int idle = Procinfo::cpu_time[Procinfo::CPU_IDLE]
> 188                - Procinfo::old_cpu_time[Procinfo::CPU_IDLE];
> 
> Then it does a couple calculations:
> 
> 196         float tot = (float)(user + nice + system + idle) / 100;
> 197         s.sprintf("cpu %.1f%% user, %.1f%% nice\n%.1f%% system,
> %.1f%% idle",
> 198                   user / tot, nice / tot, system / tot, idle / tot);
> 
> That should do it.
> 

	Not to seem ungrateful, but that is great for understanding
	top's development, but it doesnt look as though it can be 
	used within a shell script, unless of course, I am missing
	it in my rudimentary ability to script :)


--
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.