24 |
|
|
25 |
|
#include <stdio.h> |
26 |
|
#include "statgrab.h" |
27 |
– |
#ifdef LINUX |
28 |
– |
#include <string.h> |
29 |
– |
#endif |
27 |
|
#ifdef SOLARIS |
28 |
|
#include <unistd.h> |
29 |
|
#include <kstat.h> |
30 |
|
#endif |
34 |
– |
#ifdef FREEBSD |
35 |
– |
#include <sys/types.h> |
36 |
– |
#include <sys/sysctl.h> |
37 |
– |
#include <unistd.h> |
38 |
– |
#endif |
39 |
– |
#include "ukcprog.h" |
31 |
|
|
32 |
|
mem_stat_t *get_memory_stats(){ |
33 |
|
|
62 |
|
if((kn=kstat_data_lookup(ksp, "freemem")) == NULL){ |
63 |
|
return NULL; |
64 |
|
} |
65 |
< |
if((kstat_close(kc)) != 0){ |
66 |
< |
return NULL; |
76 |
< |
} |
65 |
> |
kstat_close(kc); |
66 |
> |
|
67 |
|
mem_stat.total = (long long)totalmem * (long long)pagesize; |
68 |
|
mem_stat.free = ((long long)kn->value.ul) * (long long)pagesize; |
69 |
|
mem_stat.used = mem_stat.total - mem_stat.free; |