1 |
|
/* |
2 |
|
* i-scream central monitoring system |
3 |
< |
* http://www.i-scream.org.uk |
4 |
< |
* Copyright (C) 2000-2002 i-scream |
3 |
> |
* http://www.i-scream.org |
4 |
> |
* Copyright (C) 2000-2003 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 |
23 |
|
#endif |
24 |
|
|
25 |
|
#include "statgrab.h" |
26 |
+ |
#include "tools.h" |
27 |
|
#include <time.h> |
28 |
|
#ifdef SOLARIS |
29 |
|
#include <kstat.h> |
32 |
|
#endif |
33 |
|
#ifdef LINUX |
34 |
|
#include <stdio.h> |
34 |
– |
#include "tools.h" |
35 |
|
#endif |
36 |
+ |
#ifdef FREEBSD |
37 |
+ |
#include <sys/types.h> |
38 |
+ |
#include <sys/sysctl.h> |
39 |
+ |
#endif |
40 |
|
|
37 |
– |
|
41 |
|
static page_stat_t page_stats; |
42 |
|
static int page_stats_uninit=1; |
43 |
|
|
51 |
|
FILE *f; |
52 |
|
char *line_ptr; |
53 |
|
#endif |
54 |
+ |
#ifdef FREEBSD |
55 |
+ |
size_t size; |
56 |
+ |
#endif |
57 |
+ |
#ifdef NETBSD |
58 |
+ |
struct uvmexp *uvm; |
59 |
+ |
#endif |
60 |
|
|
61 |
+ |
page_stats.systime = time(NULL); |
62 |
|
page_stats.pages_pagein=0; |
63 |
|
page_stats.pages_pageout=0; |
64 |
|
|
76 |
|
page_stats.pages_pageout+=(long long)cs.cpu_vminfo.pgpgout; |
77 |
|
} |
78 |
|
|
69 |
– |
page_stats.systime=time(NULL); |
70 |
– |
|
79 |
|
kstat_close(kc); |
80 |
|
#endif |
81 |
|
#ifdef LINUX |
89 |
|
if((sscanf(line_ptr, "page %lld %lld", &page_stats.pages_pagein, &page_stats.pages_pageout))!=2){ |
90 |
|
return NULL; |
91 |
|
} |
84 |
– |
page_stats.systime=time(NULL); |
92 |
|
fclose(f); |
93 |
|
|
94 |
+ |
#endif |
95 |
+ |
#ifdef FREEBSD |
96 |
+ |
size = sizeof page_stats.pages_pagein; |
97 |
+ |
if (sysctlbyname("vm.stats.vm.v_swappgsin", &page_stats.pages_pagein, &size, NULL, 0) < 0){ |
98 |
+ |
return NULL; |
99 |
+ |
} |
100 |
+ |
size = sizeof page_stats.pages_pageout; |
101 |
+ |
if (sysctlbyname("vm.stats.vm.v_swappgsout", &page_stats.pages_pageout, &size, NULL, 0) < 0){ |
102 |
+ |
return NULL; |
103 |
+ |
} |
104 |
+ |
#endif |
105 |
+ |
#ifdef NETBSD |
106 |
+ |
if ((uvm = get_uvmexp()) == NULL) { |
107 |
+ |
return NULL; |
108 |
+ |
} |
109 |
+ |
page_stats.pages_pagein = uvm->pgswapin; |
110 |
+ |
page_stats.pages_pageout = uvm->pgswapout; |
111 |
|
#endif |
112 |
|
|
113 |
|
return &page_stats; |