1 |
Memory stats are accessed through get_memory_stats() call. This |
2 |
returns a pointer to a static mem_stat_t |
3 |
|
4 |
typedef struct{ |
5 |
long long total; |
6 |
long long free; |
7 |
long long used; |
8 |
long long cache; |
9 |
}mem_stat_t; |
10 |
|
11 |
total contains the total memory in bytes. |
12 |
free is the total free memory in bytes. |
13 |
used is the total used memory in bytes. |
14 |
cache is the cache used in bytes. |
15 |
|
16 |
cache is not available in all operating systems. Solaris being a key |
17 |
one that it isn't. free memory and cache memory can sometimes be |
18 |
linked. |
19 |
|
20 |
Swap stats are accessed through get_swap_stats() call. This returns a |
21 |
pointer to a static swap_stat_t |
22 |
|
23 |
typedef struct{ |
24 |
long long total; |
25 |
long long used; |
26 |
long long free; |
27 |
}swap_stat_t; |
28 |
|
29 |
|
30 |
Freebsd requires kmem privilages to be able to do this call. Making the |
31 |
program setgid kmem should be sufficent. |
32 |
|
33 |
TODO |
34 |
Add a function to hold open the FD to kmem privilages could be dropped. |