--- projects/libstatgrab/examples/page_stats.c 2003/11/07 18:43:56 1.2 +++ projects/libstatgrab/examples/page_stats.c 2004/01/19 16:49:19 1.6 @@ -1,7 +1,7 @@ /* * i-scream central monitoring system * http://www.i-scream.org - * Copyright (C) 2000-2003 i-scream + * Copyright (C) 2000-2004 i-scream * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -16,6 +16,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id: page_stats.c,v 1.6 2004/01/19 16:49:19 tdb Exp $ */ #include @@ -24,22 +26,31 @@ #include int main(int argc, char **argv){ - + extern char *optarg; - extern int optind; - int c; + extern int optind; + int c; int delay = 1; page_stat_t *page_stats; while ((c = getopt(argc, argv, "d:")) != -1){ - switch (c){ - case 'd': - delay = atoi(optarg); - break; + switch (c){ + case 'd': + delay = atoi(optarg); + break; } } + /* Initialise statgrab */ + statgrab_init(); + + /* Drop setuid/setgid privileges. */ + if (statgrab_drop_privileges() != 0) { + perror("Error. Failed to drop privileges"); + return 1; + } + while( (page_stats = get_page_stats_diff()) != NULL){ printf("Pages in : %lld\n", page_stats->pages_pagein); printf("Pages out : %lld\n", page_stats->pages_pageout); @@ -48,6 +59,3 @@ int main(int argc, char **argv){ exit(0); } - - -