--- projects/libstatgrab/examples/cpu_usage.c 2004/04/06 14:52:56 1.10 +++ projects/libstatgrab/examples/cpu_usage.c 2005/09/24 13:29:22 1.11 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Id: cpu_usage.c,v 1.10 2004/04/06 14:52:56 tdb Exp $ + * $Id: cpu_usage.c,v 1.11 2005/09/24 13:29:22 tdb Exp $ */ #include @@ -40,6 +40,9 @@ int main(int argc, char **argv){ break; } } +#ifdef WIN32 + delay = delay * 1000; +#endif /* Initialise statgrab */ sg_init(); @@ -51,12 +54,14 @@ int main(int argc, char **argv){ } /* Throw away the first reading as thats averaged over the machines uptime */ + sg_snapshot(); cpu_percent = sg_get_cpu_percents(); /* Clear the screen ready for display the cpu usage */ printf("\033[2J"); while( (cpu_percent = sg_get_cpu_percents()) != NULL){ + sg_snapshot(); printf("\033[2;2H%-12s : %6.2f", "User CPU", cpu_percent->user); printf("\033[3;2H%-12s : %6.2f", "Kernel CPU", cpu_percent->kernel); printf("\033[4;2H%-12s : %6.2f", "IOWait CPU", cpu_percent->iowait); @@ -66,6 +71,7 @@ int main(int argc, char **argv){ fflush(stdout); sleep(delay); } + sg_shutdown(); exit(0); }