ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/swap_stats.c
Revision: 1.2
Committed: Thu Feb 20 13:19:52 2003 UTC (21 years, 3 months ago) by tdb
Content type: text/plain
Branch: MAIN
CVS Tags: LIBSTATGRAB_0_2
Changes since 1.1: +0 -1 lines
Log Message:
Removed references to ukcprog.h.
Fixed a missing * in the disk stats.
And removed a block of linux stuff that shouldn't have been there :-)
All with Pete's approval, of course.

File Contents

# Content
1 /*
2 * i-scream central monitoring system
3 * http://www.i-scream.org.uk
4 * Copyright (C) 2000-2002 i-scream
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include <stdio.h>
26 #include "statgrab.h"
27 #ifdef SOLARIS
28 #include <sys/stat.h>
29 #include <sys/swap.h>
30 #include <unistd.h>
31 #endif
32
33 swap_stat_t *get_swap_stats(){
34
35 static swap_stat_t swap_stat;
36
37 struct anoninfo ai;
38 int pagesize;
39
40 if((pagesize=sysconf(_SC_PAGESIZE)) == -1){
41 return NULL;
42 }
43 if (swapctl(SC_AINFO, &ai) == -1) {
44 return NULL;
45 }
46 swap_stat.total = (long long)ai.ani_max * (long long)pagesize;
47 swap_stat.used = (long long)ai.ani_resv * (long long)pagesize;
48 swap_stat.free = swap_stat.total - swap_stat.used;
49
50 return &swap_stat;
51
52 }