ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/statgrab.h
Revision: 1.57
Committed: Sat Sep 24 13:29:22 2005 UTC (18 years, 8 months ago) by tdb
Content type: text/plain
Branch: MAIN
Changes since 1.56: +22 -3 lines
Log Message:
Add WIN32 support via MINGW. We'll need to add stuff to the README file
about what this requires to build.

All the hard work done by: skel

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