--- projects/libstatgrab/examples/vm_stats.c 2004/04/04 22:48:49 1.8 +++ projects/libstatgrab/examples/vm_stats.c 2004/11/06 18:58:23 1.12 @@ -1,5 +1,5 @@ /* - * i-scream central monitoring system + * i-scream libstatgrab * http://www.i-scream.org * Copyright (C) 2000-2004 i-scream * @@ -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: vm_stats.c,v 1.8 2004/04/04 22:48:49 tdb Exp $ + * $Id: vm_stats.c,v 1.12 2004/11/06 18:58:23 tdb Exp $ */ #include @@ -25,23 +25,23 @@ #include #include -int main(int argc, char **argv){ +int main(){ - mem_stat_t *mem_stats; - swap_stat_t *swap_stats; + sg_mem_stats *mem_stats; + sg_swap_stats *swap_stats; long long total, free; /* Initialise statgrab */ - statgrab_init(); + sg_init(); /* Drop setuid/setgid privileges. */ - if (statgrab_drop_privileges() != 0) { + if (sg_drop_privileges() != 0) { perror("Error. Failed to drop privileges"); return 1; } - if( ((mem_stats=get_memory_stats()) != NULL) && (swap_stats=get_swap_stats()) != NULL){ + if( ((mem_stats=sg_get_mem_stats()) != NULL) && (swap_stats=sg_get_swap_stats()) != NULL){ printf("Total memory in bytes : %lld\n", mem_stats->total); printf("Used memory in bytes : %lld\n", mem_stats->used); printf("Cache memory in bytes : %lld\n", mem_stats->cache); @@ -58,7 +58,7 @@ int main(int argc, char **argv){ } else { - printf("Unable to get VM stats.\n"); + printf("Unable to get VM stats: %s\n", sg_str_error(sg_get_error())); exit(1); } exit(0);