sg_get_mem_stats
Section: C Library Functions (3)
Updated: $Date: 2005/04/25 11:25:45 $
Index
Return to Main Contents
NAME
sg_get_mem_stats, sg_get_swap_stats - get VM statistics
SYNOPSIS
#include <statgrab.h>
sg_mem_stats *sg_get_mem_stats(void);
sg_swap_stats *sg_get_swap_stats(void);
DESCRIPTION
Memory statistics are accessed through the
sg_get_mem_stats function. It returns a
pointer to a static sg_mem_stats.
The sg_get_swap_stats returns returns swap
statistics. It returns a pointer to a static
sg_swap_stats.
On the FreeBSD operating system elevated privileges are required
to access the swap statistics. Making the program setgid kmem
should be sufficient. Programs running as root will not have this
problem.
RETURN VALUES
The VM system calls can return a pointer to either a
sg_mem_stats or a
sg_swap_stats.
typedef struct{
long long total;
long long free;
long long used;
long long cache;
}sg_mem_stats;
- total
-
The total amount of memory in bytes.
- free
-
The total free memory in bytes.
- used
-
The total used memory in bytes.
- cache
-
The amount of cache used in bytes.
typedef struct{
long long total;
long long used;
long long free;
}sg_swap_stats;
- total
-
The total swap space in bytes.
- used
-
The used swap in bytes.
- free
-
The free swap in bytes.
TODO
Add a function to hold open the file descriptor to the kernel
memory structures. Doing this would allow the elevated privileges
to be dropped early on.
SEE ALSO
statgrab(3)
WEBSITE
http://www.i-scream.org/libstatgrab/