9 |
|
<date>$Date$</date> |
10 |
|
<releaseinfo>$Id$</releaseinfo> |
11 |
|
</refentryinfo> |
12 |
< |
|
12 |
> |
|
13 |
|
<refmeta> |
14 |
|
<refentrytitle>statgrab</refentrytitle> |
15 |
|
<manvolnum>3</manvolnum> |
16 |
|
<refmiscinfo>i-scream</refmiscinfo> |
17 |
|
</refmeta> |
18 |
< |
|
18 |
> |
|
19 |
|
<refnamediv> |
20 |
|
<refname>statgrab</refname> |
21 |
|
<refpurpose>get system statistics</refpurpose> |
22 |
|
</refnamediv> |
23 |
< |
|
23 |
> |
|
24 |
|
<refsynopsisdiv> |
25 |
|
<funcsynopsis> |
26 |
|
<funcsynopsisinfo>#include <statgrab.h></funcsynopsisinfo> |
27 |
|
|
28 |
|
<funcprototype> |
29 |
< |
<funcdef>int <function>statgrab_init</function></funcdef> |
29 |
> |
<funcdef>int <function>sg_init</function></funcdef> |
30 |
|
<void/> |
31 |
|
</funcprototype> |
32 |
+ |
<funcprototype> |
33 |
+ |
<funcdef>int <function>sg_drop_privileges</function></funcdef> |
34 |
+ |
<void/> |
35 |
+ |
</funcprototype> |
36 |
|
|
37 |
|
<funcprototype> |
38 |
< |
<funcdef>cpu_percent_t *<function>cpu_percent_usage</function></funcdef> |
38 |
> |
<funcdef>sg_cpu_stats *<function>sg_get_cpu_stats</function></funcdef> |
39 |
|
<void/> |
40 |
|
</funcprototype> |
41 |
|
<funcprototype> |
42 |
< |
<funcdef>cpu_states_t *<function>get_cpu_totals</function></funcdef> |
42 |
> |
<funcdef>sg_cpu_stats *<function>sg_get_cpu_stats_diff</function></funcdef> |
43 |
|
<void/> |
44 |
|
</funcprototype> |
45 |
|
<funcprototype> |
46 |
< |
<funcdef>cpu_states_t *<function>get_cpu_diff</function></funcdef> |
46 |
> |
<funcdef>sg_cpu_percents *<function>sg_get_cpu_percents</function></funcdef> |
47 |
|
<void/> |
48 |
|
</funcprototype> |
49 |
|
|
50 |
|
<funcprototype> |
51 |
< |
<funcdef>diskio_stat_t *<function>get_diskio_stats</function></funcdef> |
51 |
> |
<funcdef>sg_disk_io_stats *<function>sg_get_disk_io_stats</function></funcdef> |
52 |
|
<paramdef>int *<parameter>entries</parameter></paramdef> |
53 |
|
</funcprototype> |
54 |
|
<funcprototype> |
55 |
< |
<funcdef>diskio_stat_t *<function>get_diskio_stats_diff</function></funcdef> |
55 |
> |
<funcdef>sg_disk_io_stats *<function>sg_get_disk_io_stats_diff</function></funcdef> |
56 |
|
<paramdef>int *<parameter>entries</parameter></paramdef> |
57 |
|
</funcprototype> |
58 |
|
|
59 |
|
<funcprototype> |
60 |
< |
<funcdef>general_stat_t *<function>get_general_stats</function></funcdef> |
60 |
> |
<funcdef>sg_host_info *<function>sg_get_host_info</function></funcdef> |
61 |
|
<void/> |
62 |
|
</funcprototype> |
63 |
|
|
64 |
|
<funcprototype> |
65 |
< |
<funcdef>load_stat_t *<function>get_load_stats</function></funcdef> |
65 |
> |
<funcdef>sg_load_stats *<function>sg_get_load_stats</function></funcdef> |
66 |
|
<void/> |
67 |
|
</funcprototype> |
68 |
|
|
69 |
|
<funcprototype> |
70 |
< |
<funcdef>mem_stat_t *<function>get_memory_stats</function></funcdef> |
70 |
> |
<funcdef>sg_mem_stats *<function>sg_get_mem_stats</function></funcdef> |
71 |
|
<void/> |
72 |
|
</funcprototype> |
73 |
|
<funcprototype> |
74 |
< |
<funcdef>swap_stat_t *<function>get_swap_stats</function></funcdef> |
74 |
> |
<funcdef>sg_swap_stats *<function>sg_get_swap_stats</function></funcdef> |
75 |
|
<void/> |
76 |
|
</funcprototype> |
77 |
|
|
78 |
|
<funcprototype> |
79 |
< |
<funcdef>network_stat_t *<function>get_network_stats</function></funcdef> |
79 |
> |
<funcdef>sg_network_io_stats *<function>sg_get_network_io_stats</function></funcdef> |
80 |
|
<paramdef>int *<parameter>entries</parameter></paramdef> |
81 |
|
</funcprototype> |
82 |
|
<funcprototype> |
83 |
< |
<funcdef>network_stat_t *<function>get_network_stats_diff</function></funcdef> |
83 |
> |
<funcdef>sg_network_io_stats *<function>sg_get_network_io_stats_diff</function></funcdef> |
84 |
|
<paramdef>int *<parameter>entries</parameter></paramdef> |
85 |
|
</funcprototype> |
86 |
|
|
87 |
|
<funcprototype> |
88 |
< |
<funcdef>page_stat_t *<function>get_page_stats</function></funcdef> |
88 |
> |
<funcdef>sg_network_iface_stats *<function>sg_get_network_iface_stats</function></funcdef> |
89 |
> |
<paramdef>int *<parameter>entries</parameter></paramdef> |
90 |
> |
</funcprototype> |
91 |
> |
|
92 |
> |
<funcprototype> |
93 |
> |
<funcdef>sg_page_stats *<function>sg_get_page_stats</function></funcdef> |
94 |
|
<void/> |
95 |
|
</funcprototype> |
96 |
|
<funcprototype> |
97 |
< |
<funcdef>page_stat_t *<function>get_page_stats_diff</function></funcdef> |
97 |
> |
<funcdef>sg_page_stats *<function>sg_get_page_stats_diff</function></funcdef> |
98 |
|
<void/> |
99 |
|
</funcprototype> |
100 |
|
|
101 |
|
<funcprototype> |
102 |
< |
<funcdef>process_stat_t *<function>get_process_stats</function></funcdef> |
102 |
> |
<funcdef>sg_process_count *<function>sg_get_process_stats</function></funcdef> |
103 |
|
<void/> |
104 |
|
</funcprototype> |
105 |
|
|
106 |
|
<funcprototype> |
107 |
< |
<funcdef>user_stat_t *<function>get_user_stats</function></funcdef> |
107 |
> |
<funcdef>sg_user_stats *<function>sg_get_user_stats</function></funcdef> |
108 |
|
<void/> |
109 |
|
</funcprototype> |
110 |
|
|
111 |
|
</funcsynopsis> |
112 |
|
</refsynopsisdiv> |
113 |
< |
|
113 |
> |
|
114 |
|
<refsect1> |
115 |
|
<title>Description</title> |
116 |
|
<para> |
117 |
< |
The statgrab library provides a cross platform interface to getting |
117 |
> |
The statgrab library provides a cross-platform interface to getting |
118 |
|
system statistics. Each of the function calls returns a structure |
119 |
|
containing statistics. See the manual page for each individual |
120 |
|
function for more details on usage. |
121 |
|
</para> |
122 |
|
<para> |
123 |
< |
<function>statgrab_init(void)</function> should be the first |
124 |
< |
function you call before you start to use libstatgrab. This |
125 |
< |
function on *bsd systems opens up the kernel structures and |
126 |
< |
leaves them open for future use. Because of this, any special |
127 |
< |
privileges the program has (e.g. setgid kmem) can be dropped |
128 |
< |
after this call, and all the libstatgrab calls should continue to |
129 |
< |
work. |
123 |
> |
<function>sg_init</function> must be the first |
124 |
> |
function you call before you start to use libstatgrab; it performs all |
125 |
> |
the one-time initialisation operations that need setuid/setgid |
126 |
> |
privileges. For instance, on *BSD it opens a descriptor to be able to |
127 |
> |
read kernel structures later on, and on Solaris it reads the device |
128 |
> |
mappings that in some cases are only accessible by root (machines with |
129 |
> |
a /dev/osa). Once this has run, the other libstatgrab functions no longer |
130 |
> |
need elevated privileges. It is therefore a good idea to call |
131 |
> |
<function>sg_drop_privileges</function>, which discards |
132 |
> |
setuid and setgid privileges, immediately after you call |
133 |
> |
<function>sg_init</function>, unless your application has |
134 |
> |
another reason for needing setuid or setgid privileges. |
135 |
|
</para> |
136 |
|
<para> |
137 |
< |
<function>statgrab_init</function> returns 0 on success, and |
137 |
> |
<function>sg_init</function> and |
138 |
> |
<function>sg_drop_privileges</function> return 0 on success, and |
139 |
|
non-zero on failure. |
140 |
|
</para> |
141 |
|
<para> |
142 |
< |
The library was originally written to support the i-scream central |
143 |
< |
monitoring system, but has since become a standalone package. It |
144 |
< |
has been ported to work on Linux, FreeBSD, and Solaris. |
142 |
> |
The library was originally written to support the i-scream |
143 |
> |
central monitoring system, but has since become a standalone |
144 |
> |
package. It has been ported to work on Linux, NetBSD, FreeBSD, |
145 |
> |
OpenBSD, DragonFly BSD, Solaris and Cygwin. |
146 |
|
</para> |
147 |
|
</refsect1> |
148 |
< |
|
148 |
> |
|
149 |
|
<refsect1> |
150 |
|
<title>See Also</title> |
151 |
|
|
152 |
|
<simplelist type="inline"> |
153 |
|
<member> |
154 |
|
<citerefentry> |
155 |
< |
<refentrytitle>cpu_percent_usage</refentrytitle> |
155 |
> |
<refentrytitle>sg_get_cpu_percents</refentrytitle> |
156 |
|
<manvolnum>3</manvolnum> |
157 |
|
</citerefentry> |
158 |
|
<citerefentry> |
159 |
< |
<refentrytitle>get_diskio_stats</refentrytitle> |
159 |
> |
<refentrytitle>sg_get_disk_io_stats</refentrytitle> |
160 |
|
<manvolnum>3</manvolnum> |
161 |
|
</citerefentry> |
162 |
|
<citerefentry> |
163 |
< |
<refentrytitle>get_general_stats</refentrytitle> |
163 |
> |
<refentrytitle>sg_get_host_info</refentrytitle> |
164 |
|
<manvolnum>3</manvolnum> |
165 |
|
</citerefentry> |
166 |
|
<citerefentry> |
167 |
< |
<refentrytitle>get_load_stats</refentrytitle> |
167 |
> |
<refentrytitle>sg_get_load_stats</refentrytitle> |
168 |
|
<manvolnum>3</manvolnum> |
169 |
|
</citerefentry> |
170 |
|
<citerefentry> |
171 |
< |
<refentrytitle>get_memory_stats</refentrytitle> |
171 |
> |
<refentrytitle>sg_get_mem_stats</refentrytitle> |
172 |
|
<manvolnum>3</manvolnum> |
173 |
|
</citerefentry> |
174 |
|
<citerefentry> |
175 |
< |
<refentrytitle>get_network_stats</refentrytitle> |
175 |
> |
<refentrytitle>sg_get_network_io_stats</refentrytitle> |
176 |
|
<manvolnum>3</manvolnum> |
177 |
|
</citerefentry> |
178 |
|
<citerefentry> |
179 |
< |
<refentrytitle>get_page_stats</refentrytitle> |
179 |
> |
<refentrytitle>sg_get_network_iface_stats</refentrytitle> |
180 |
|
<manvolnum>3</manvolnum> |
181 |
|
</citerefentry> |
182 |
|
<citerefentry> |
183 |
< |
<refentrytitle>get_process_stats</refentrytitle> |
183 |
> |
<refentrytitle>sg_get_page_stats</refentrytitle> |
184 |
|
<manvolnum>3</manvolnum> |
185 |
|
</citerefentry> |
186 |
|
<citerefentry> |
187 |
< |
<refentrytitle>get_user_stats</refentrytitle> |
187 |
> |
<refentrytitle>sg_get_process_stats</refentrytitle> |
188 |
|
<manvolnum>3</manvolnum> |
189 |
|
</citerefentry> |
190 |
+ |
<citerefentry> |
191 |
+ |
<refentrytitle>sg_get_user_stats</refentrytitle> |
192 |
+ |
<manvolnum>3</manvolnum> |
193 |
+ |
</citerefentry> |
194 |
|
</member> |
195 |
|
</simplelist> |
196 |
|
</refsect1> |
197 |
< |
|
197 |
> |
|
198 |
|
<refsect1> |
199 |
|
<title>Website</title> |
200 |
< |
|
200 |
> |
|
201 |
|
<simplelist type="vert"> |
202 |
|
<member> |
203 |
< |
<ulink url="http://www.i-scream.org">http://www.i-scream.org</ulink> |
203 |
> |
<ulink url="http://www.i-scream.org/libstatgrab/"> |
204 |
> |
http://www.i-scream.org/libstatgrab/ |
205 |
> |
</ulink> |
206 |
|
</member> |
207 |
|
</simplelist> |
208 |
|
</refsect1> |