ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/statgrab.h
Revision: 1.59
Committed: Sun Oct 3 18:35:58 2010 UTC (13 years, 7 months ago) by tdb
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.58: +5 -2 lines
Log Message:
Add support for AIX 5.x - 9.x.

Many thanks to Jens Rehsack <rehsack@googlemail.com> for providing the
patch for this work. Thanks!

File Contents

# User Rev Content
1 tdb 1.22 /*
2 tdb 1.34 * i-scream libstatgrab
3 tdb 1.13 * http://www.i-scream.org
4 tdb 1.22 * Copyright (C) 2000-2004 i-scream
5 pajs 1.1 *
6 tdb 1.22 * 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 pajs 1.1 *
11 tdb 1.22 * This library is distributed in the hope that it will be useful,
12 pajs 1.1 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 tdb 1.22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14     * Lesser General Public License for more details.
15 pajs 1.1 *
16 tdb 1.22 * 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 tdb 1.23 *
21 tdb 1.59 * $Id: statgrab.h,v 1.58 2006/03/11 13:11:21 tdb Exp $
22 pajs 1.1 */
23    
24 tdb 1.50 #ifndef STATGRAB_H
25     #define STATGRAB_H
26    
27 tdb 1.58 #ifdef __cplusplus
28     extern "C" {
29     #endif
30    
31 pajs 1.21 #include <sys/types.h>
32    
33 ats 1.33 /* FIXME typedefs for 32/64-bit types */
34     /* FIXME maybe tidy up field names? */
35     /* FIXME comments for less obvious fields */
36    
37     int sg_init(void);
38 tdb 1.57 int sg_snapshot();
39     int sg_shutdown();
40 ats 1.33 int sg_drop_privileges(void);
41 tdb 1.36
42     typedef enum {
43 tdb 1.38 SG_ERROR_NONE = 0,
44 tdb 1.42 SG_ERROR_ASPRINTF,
45 tdb 1.57 SG_ERROR_DEVICES,
46 tdb 1.42 SG_ERROR_DEVSTAT_GETDEVS,
47     SG_ERROR_DEVSTAT_SELECTDEVS,
48 tdb 1.57 SG_ERROR_DISKINFO,
49 tdb 1.42 SG_ERROR_ENOENT,
50     SG_ERROR_GETIFADDRS,
51     SG_ERROR_GETMNTINFO,
52     SG_ERROR_GETPAGESIZE,
53 tdb 1.57 SG_ERROR_HOST,
54 tdb 1.42 SG_ERROR_KSTAT_DATA_LOOKUP,
55     SG_ERROR_KSTAT_LOOKUP,
56     SG_ERROR_KSTAT_OPEN,
57     SG_ERROR_KSTAT_READ,
58     SG_ERROR_KVM_GETSWAPINFO,
59     SG_ERROR_KVM_OPENFILES,
60 tdb 1.39 SG_ERROR_MALLOC,
61 tdb 1.57 SG_ERROR_MEMSTATUS,
62 tdb 1.39 SG_ERROR_OPEN,
63 tdb 1.42 SG_ERROR_OPENDIR,
64 tdb 1.41 SG_ERROR_PARSE,
65 tdb 1.57 SG_ERROR_PDHADD,
66     SG_ERROR_PDHCOLLECT,
67     SG_ERROR_PDHOPEN,
68     SG_ERROR_PDHREAD,
69     SG_ERROR_PERMISSION,
70     SG_ERROR_PSTAT,
71 tdb 1.42 SG_ERROR_SETEGID,
72     SG_ERROR_SETEUID,
73 tdb 1.41 SG_ERROR_SETMNTENT,
74 tdb 1.42 SG_ERROR_SOCKET,
75     SG_ERROR_SWAPCTL,
76     SG_ERROR_SYSCONF,
77     SG_ERROR_SYSCTL,
78     SG_ERROR_SYSCTLBYNAME,
79     SG_ERROR_SYSCTLNAMETOMIB,
80     SG_ERROR_UNAME,
81     SG_ERROR_UNSUPPORTED,
82 tdb 1.59 SG_ERROR_XSW_VER_MISMATCH,
83     SG_ERROR_GETMSG,
84     SG_ERROR_PUTMSG
85 tdb 1.36 } sg_error;
86    
87     void sg_set_error(sg_error code, const char *arg);
88 tdb 1.52 void sg_set_error_with_errno(sg_error code, const char *arg);
89 tdb 1.36 sg_error sg_get_error();
90 ats 1.43 const char *sg_get_error_arg();
91 ats 1.53 int sg_get_error_errno();
92 ats 1.37 const char *sg_str_error(sg_error code);
93 ats 1.33
94     typedef struct {
95     char *os_name;
96     char *os_release;
97     char *os_version;
98     char *platform;
99     char *hostname;
100     time_t uptime;
101     } sg_host_info;
102    
103     sg_host_info *sg_get_host_info();
104    
105     typedef struct {
106 tdb 1.39 long long user;
107     long long kernel;
108     long long idle;
109     long long iowait;
110     long long swap;
111     long long nice;
112     long long total;
113     time_t systime;
114 ats 1.33 } sg_cpu_stats;
115 pajs 1.1
116 ats 1.33 sg_cpu_stats *sg_get_cpu_stats();
117     sg_cpu_stats *sg_get_cpu_stats_diff();
118    
119     typedef struct {
120 tdb 1.39 float user;
121     float kernel;
122     float idle;
123     float iowait;
124     float swap;
125     float nice;
126 pajs 1.1 time_t time_taken;
127 ats 1.33 } sg_cpu_percents;
128    
129     sg_cpu_percents *sg_get_cpu_percents();
130 pajs 1.1
131 ats 1.33 typedef struct {
132 pajs 1.1 long long total;
133     long long free;
134     long long used;
135     long long cache;
136 ats 1.33 } sg_mem_stats;
137    
138     sg_mem_stats *sg_get_mem_stats();
139 pajs 1.1
140 ats 1.33 typedef struct {
141 pajs 1.1 double min1;
142     double min5;
143     double min15;
144 ats 1.33 } sg_load_stats;
145    
146     sg_load_stats *sg_get_load_stats();
147 pajs 1.1
148 ats 1.33 typedef struct {
149 pajs 1.8 char *name_list;
150 pajs 1.1 int num_entries;
151 ats 1.33 } sg_user_stats;
152    
153     sg_user_stats *sg_get_user_stats();
154 pajs 1.1
155 ats 1.33 typedef struct {
156 pajs 1.1 long long total;
157     long long used;
158     long long free;
159 ats 1.33 } sg_swap_stats;
160 pajs 1.1
161 ats 1.33 sg_swap_stats *sg_get_swap_stats();
162 pajs 1.1
163     typedef struct {
164 tdb 1.39 char *device_name;
165 pajs 1.1 char *fs_type;
166 tdb 1.39 char *mnt_point;
167     long long size;
168     long long used;
169     long long avail;
170     long long total_inodes;
171 pajs 1.1 long long used_inodes;
172 tdb 1.39 long long free_inodes;
173 tdb 1.56 long long avail_inodes;
174     long long io_size;
175     long long block_size;
176     long long total_blocks;
177     long long free_blocks;
178     long long used_blocks;
179     long long avail_blocks;
180 ats 1.33 } sg_fs_stats;
181    
182     sg_fs_stats *sg_get_fs_stats(int *entries);
183 pajs 1.1
184 ats 1.49 int sg_fs_compare_device_name(const void *va, const void *vb);
185     int sg_fs_compare_mnt_point(const void *va, const void *vb);
186    
187 ats 1.33 typedef struct {
188 pajs 1.4 char *disk_name;
189     long long read_bytes;
190     long long write_bytes;
191     time_t systime;
192 ats 1.33 } sg_disk_io_stats;
193 pajs 1.4
194 ats 1.33 sg_disk_io_stats *sg_get_disk_io_stats(int *entries);
195     sg_disk_io_stats *sg_get_disk_io_stats_diff(int *entries);
196 pajs 1.1
197 ats 1.49 int sg_disk_io_compare_name(const void *va, const void *vb);
198    
199 ats 1.33 typedef struct {
200 pajs 1.1 char *interface_name;
201     long long tx;
202     long long rx;
203 tdb 1.28 long long ipackets;
204     long long opackets;
205     long long ierrors;
206     long long oerrors;
207     long long collisions;
208 pajs 1.1 time_t systime;
209 ats 1.33 } sg_network_io_stats;
210    
211     sg_network_io_stats *sg_get_network_io_stats(int *entries);
212     sg_network_io_stats *sg_get_network_io_stats_diff(int *entries);
213 pajs 1.24
214 ats 1.49 int sg_network_io_compare_name(const void *va, const void *vb);
215    
216 ats 1.33 typedef enum {
217     SG_IFACE_DUPLEX_FULL,
218     SG_IFACE_DUPLEX_HALF,
219     SG_IFACE_DUPLEX_UNKNOWN
220     } sg_iface_duplex;
221 pajs 1.24
222 ats 1.33 typedef struct {
223 pajs 1.24 char *interface_name;
224     int speed; /* In megabits/sec */
225 tdb 1.55 sg_iface_duplex duplex;
226     #ifdef SG_ENABLE_DEPRECATED
227 ats 1.33 sg_iface_duplex dup;
228 tdb 1.55 #endif
229 pajs 1.27 int up;
230 ats 1.33 } sg_network_iface_stats;
231    
232     sg_network_iface_stats *sg_get_network_iface_stats(int *entries);
233 pajs 1.1
234 ats 1.49 int sg_network_iface_compare_name(const void *va, const void *vb);
235    
236 ats 1.33 typedef struct {
237 pajs 1.2 long long pages_pagein;
238     long long pages_pageout;
239 pajs 1.1 time_t systime;
240 ats 1.33 } sg_page_stats;
241    
242     sg_page_stats *sg_get_page_stats();
243     sg_page_stats *sg_get_page_stats_diff();
244 pajs 1.29
245 tdb 1.59 /* Recommend to add SG_PROCESS_STATE_IDLE */
246 ats 1.33 typedef enum {
247     SG_PROCESS_STATE_RUNNING,
248     SG_PROCESS_STATE_SLEEPING,
249     SG_PROCESS_STATE_STOPPED,
250     SG_PROCESS_STATE_ZOMBIE,
251     SG_PROCESS_STATE_UNKNOWN
252     } sg_process_state;
253 pajs 1.30
254 ats 1.33 typedef struct {
255 pajs 1.29 char *process_name;
256     char *proctitle;
257    
258     pid_t pid;
259     pid_t parent; /* Parent pid */
260     pid_t pgid; /* process id of process group leader */
261    
262 tdb 1.57 /* Windows does not have uid_t or gid_t types */
263     #ifndef WIN32
264 pajs 1.29 uid_t uid;
265     uid_t euid;
266     gid_t gid;
267     gid_t egid;
268 tdb 1.57 #else
269     int uid;
270     int euid;
271     int gid;
272     int egid;
273     #endif
274 pajs 1.29
275     unsigned long long proc_size; /* in bytes */
276     unsigned long long proc_resident; /* in bytes */
277 tdb 1.31 time_t time_spent; /* time running in seconds */
278 pajs 1.29 double cpu_percent;
279     int nice;
280 ats 1.33 sg_process_state state;
281     } sg_process_stats;
282 pajs 1.29
283 ats 1.33 sg_process_stats *sg_get_process_stats(int *entries);
284 pajs 1.1
285 ats 1.49 int sg_process_compare_name(const void *va, const void *vb);
286 ats 1.48 int sg_process_compare_pid(const void *va, const void *vb);
287     int sg_process_compare_uid(const void *va, const void *vb);
288     int sg_process_compare_gid(const void *va, const void *vb);
289     int sg_process_compare_size(const void *va, const void *vb);
290     int sg_process_compare_res(const void *va, const void *vb);
291     int sg_process_compare_cpu(const void *va, const void *vb);
292     int sg_process_compare_time(const void *va, const void *vb);
293    
294 ats 1.33 typedef struct {
295     int total;
296     int running;
297     int sleeping;
298     int stopped;
299     int zombie;
300     } sg_process_count;
301 pajs 1.14
302 ats 1.33 sg_process_count *sg_get_process_count();
303 tdb 1.35
304     #ifdef SG_ENABLE_DEPRECATED
305     #include <statgrab_deprecated.h>
306 tdb 1.58 #endif
307    
308     #ifdef __cplusplus
309     }
310 tdb 1.35 #endif
311 ats 1.18
312 tdb 1.50 #endif