1sg_get_mem_stats(3)        Library Functions Manual        sg_get_mem_stats(3)
2
3
4

NAME

6       sg_get_mem_stats, sg_get_swap_stats - get VM statistics
7

SYNOPSIS

9       #include <statgrab.h>
10
11
12       sg_mem_stats *sg_get_mem_stats(void);
13
14       sg_swap_stats *sg_get_swap_stats(void);
15

DESCRIPTION

17       Memory  statistics  are accessed through the sg_get_mem_stats function.
18       It returns a pointer to a static sg_mem_stats.
19
20       The sg_get_swap_stats returns returns swap  statistics.  It  returns  a
21       pointer to a static sg_swap_stats.
22
23       On  the  FreeBSD  operating  system elevated privileges are required to
24       access the swap statistics. Making the program setgid  kmem  should  be
25       sufficient. Programs running as root will not have this problem.
26

RETURN VALUES

28       The  VM system calls can return a pointer to either a sg_mem_stats or a
29       sg_swap_stats.
30
31       typedef struct{
32               long long total;
33               long long free;
34               long long used;
35               long long cache;
36       }sg_mem_stats;
37
38
39       total  The total amount of memory in bytes.
40
41       free   The total free memory in bytes.
42
43       used   The total used memory in bytes.
44
45       cache  The amount of cache used in bytes.
46
47       typedef struct{
48               long long total;
49               long long used;
50               long long free;
51       }sg_swap_stats;
52
53
54       total  The total swap space in bytes.
55
56       used   The used swap in bytes.
57
58       free   The free swap in bytes.
59

TODO

61       Add a function to hold open the file descriptor to  the  kernel  memory
62       structures.  Doing  this  would  allow  the  elevated  privileges to be
63       dropped early on.
64

SEE ALSO

66       statgrab(3)
67

WEBSITE

69       http://www.i-scream.org/libstatgrab/
70
71
72
73i-scream                 $Date: 2005/04/25 11:25:45 $      sg_get_mem_stats(3)
Impressum