ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/statgrab.h
Revision: 1.54
Committed: Mon Nov 1 18:30:17 2004 UTC (19 years, 6 months ago) by tdb
Content type: text/plain
Branch: MAIN
CVS Tags: LIBSTATGRAB_0_11_1, LIBSTATGRAB_0_11
Changes since 1.53: +3 -2 lines
Log Message:
Merge in patch to provide support for HP-UX 11.11.

Contributed by Roy Keene - thanks Roy!

File Contents

# Content
1 /*
2 * i-scream libstatgrab
3 * http://www.i-scream.org
4 * Copyright (C) 2000-2004 i-scream
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 * 02111-1307 USA
20 *
21 * $Id: statgrab.h,v 1.53 2004/07/18 20:44:01 ats Exp $
22 */
23
24 #ifndef STATGRAB_H
25 #define STATGRAB_H
26
27 #include <sys/types.h>
28
29 /* FIXME typedefs for 32/64-bit types */
30 /* FIXME maybe tidy up field names? */
31 /* FIXME comments for less obvious fields */
32
33 int sg_init(void);
34 int sg_drop_privileges(void);
35
36 typedef enum {
37 SG_ERROR_NONE = 0,
38 SG_ERROR_ASPRINTF,
39 SG_ERROR_DEVSTAT_GETDEVS,
40 SG_ERROR_DEVSTAT_SELECTDEVS,
41 SG_ERROR_ENOENT,
42 SG_ERROR_GETIFADDRS,
43 SG_ERROR_GETMNTINFO,
44 SG_ERROR_GETPAGESIZE,
45 SG_ERROR_KSTAT_DATA_LOOKUP,
46 SG_ERROR_KSTAT_LOOKUP,
47 SG_ERROR_KSTAT_OPEN,
48 SG_ERROR_KSTAT_READ,
49 SG_ERROR_KVM_GETSWAPINFO,
50 SG_ERROR_KVM_OPENFILES,
51 SG_ERROR_MALLOC,
52 SG_ERROR_OPEN,
53 SG_ERROR_OPENDIR,
54 SG_ERROR_PARSE,
55 SG_ERROR_SETEGID,
56 SG_ERROR_SETEUID,
57 SG_ERROR_SETMNTENT,
58 SG_ERROR_SOCKET,
59 SG_ERROR_SWAPCTL,
60 SG_ERROR_SYSCONF,
61 SG_ERROR_SYSCTL,
62 SG_ERROR_SYSCTLBYNAME,
63 SG_ERROR_SYSCTLNAMETOMIB,
64 SG_ERROR_UNAME,
65 SG_ERROR_UNSUPPORTED,
66 SG_ERROR_XSW_VER_MISMATCH,
67 SG_ERROR_PSTAT
68 } sg_error;
69
70 void sg_set_error(sg_error code, const char *arg);
71 void sg_set_error_with_errno(sg_error code, const char *arg);
72 sg_error sg_get_error();
73 const char *sg_get_error_arg();
74 int sg_get_error_errno();
75 const char *sg_str_error(sg_error code);
76
77 typedef struct {
78 char *os_name;
79 char *os_release;
80 char *os_version;
81 char *platform;
82 char *hostname;
83 time_t uptime;
84 } sg_host_info;
85
86 sg_host_info *sg_get_host_info();
87
88 typedef struct {
89 long long user;
90 long long kernel;
91 long long idle;
92 long long iowait;
93 long long swap;
94 long long nice;
95 long long total;
96 time_t systime;
97 } sg_cpu_stats;
98
99 sg_cpu_stats *sg_get_cpu_stats();
100 sg_cpu_stats *sg_get_cpu_stats_diff();
101
102 typedef struct {
103 float user;
104 float kernel;
105 float idle;
106 float iowait;
107 float swap;
108 float nice;
109 time_t time_taken;
110 } sg_cpu_percents;
111
112 sg_cpu_percents *sg_get_cpu_percents();
113
114 typedef struct {
115 long long total;
116 long long free;
117 long long used;
118 long long cache;
119 } sg_mem_stats;
120
121 sg_mem_stats *sg_get_mem_stats();
122
123 typedef struct {
124 double min1;
125 double min5;
126 double min15;
127 } sg_load_stats;
128
129 sg_load_stats *sg_get_load_stats();
130
131 typedef struct {
132 char *name_list;
133 int num_entries;
134 } sg_user_stats;
135
136 sg_user_stats *sg_get_user_stats();
137
138 typedef struct {
139 long long total;
140 long long used;
141 long long free;
142 } sg_swap_stats;
143
144 sg_swap_stats *sg_get_swap_stats();
145
146 typedef struct {
147 char *device_name;
148 char *fs_type;
149 char *mnt_point;
150 long long size;
151 long long used;
152 long long avail;
153 long long total_inodes;
154 long long used_inodes;
155 long long free_inodes;
156 } sg_fs_stats;
157
158 sg_fs_stats *sg_get_fs_stats(int *entries);
159
160 int sg_fs_compare_device_name(const void *va, const void *vb);
161 int sg_fs_compare_mnt_point(const void *va, const void *vb);
162
163 typedef struct {
164 char *disk_name;
165 long long read_bytes;
166 long long write_bytes;
167 time_t systime;
168 } sg_disk_io_stats;
169
170 sg_disk_io_stats *sg_get_disk_io_stats(int *entries);
171 sg_disk_io_stats *sg_get_disk_io_stats_diff(int *entries);
172
173 int sg_disk_io_compare_name(const void *va, const void *vb);
174
175 typedef struct {
176 char *interface_name;
177 long long tx;
178 long long rx;
179 long long ipackets;
180 long long opackets;
181 long long ierrors;
182 long long oerrors;
183 long long collisions;
184 time_t systime;
185 } sg_network_io_stats;
186
187 sg_network_io_stats *sg_get_network_io_stats(int *entries);
188 sg_network_io_stats *sg_get_network_io_stats_diff(int *entries);
189
190 int sg_network_io_compare_name(const void *va, const void *vb);
191
192 typedef enum {
193 SG_IFACE_DUPLEX_FULL,
194 SG_IFACE_DUPLEX_HALF,
195 SG_IFACE_DUPLEX_UNKNOWN
196 } sg_iface_duplex;
197
198 typedef struct {
199 char *interface_name;
200 int speed; /* In megabits/sec */
201 sg_iface_duplex dup;
202 int up;
203 } sg_network_iface_stats;
204
205 sg_network_iface_stats *sg_get_network_iface_stats(int *entries);
206
207 int sg_network_iface_compare_name(const void *va, const void *vb);
208
209 typedef struct {
210 long long pages_pagein;
211 long long pages_pageout;
212 time_t systime;
213 } sg_page_stats;
214
215 sg_page_stats *sg_get_page_stats();
216 sg_page_stats *sg_get_page_stats_diff();
217
218 typedef enum {
219 SG_PROCESS_STATE_RUNNING,
220 SG_PROCESS_STATE_SLEEPING,
221 SG_PROCESS_STATE_STOPPED,
222 SG_PROCESS_STATE_ZOMBIE,
223 SG_PROCESS_STATE_UNKNOWN
224 } sg_process_state;
225
226 typedef struct {
227 char *process_name;
228 char *proctitle;
229
230 pid_t pid;
231 pid_t parent; /* Parent pid */
232 pid_t pgid; /* process id of process group leader */
233
234 uid_t uid;
235 uid_t euid;
236 gid_t gid;
237 gid_t egid;
238
239 unsigned long long proc_size; /* in bytes */
240 unsigned long long proc_resident; /* in bytes */
241 time_t time_spent; /* time running in seconds */
242 double cpu_percent;
243 int nice;
244 sg_process_state state;
245 } sg_process_stats;
246
247 sg_process_stats *sg_get_process_stats(int *entries);
248
249 int sg_process_compare_name(const void *va, const void *vb);
250 int sg_process_compare_pid(const void *va, const void *vb);
251 int sg_process_compare_uid(const void *va, const void *vb);
252 int sg_process_compare_gid(const void *va, const void *vb);
253 int sg_process_compare_size(const void *va, const void *vb);
254 int sg_process_compare_res(const void *va, const void *vb);
255 int sg_process_compare_cpu(const void *va, const void *vb);
256 int sg_process_compare_time(const void *va, const void *vb);
257
258 typedef struct {
259 int total;
260 int running;
261 int sleeping;
262 int stopped;
263 int zombie;
264 } sg_process_count;
265
266 sg_process_count *sg_get_process_count();
267
268 #ifdef SG_ENABLE_DEPRECATED
269 #include <statgrab_deprecated.h>
270 #endif
271
272 #endif