ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/statgrab.h
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/statgrab.h (file contents):
Revision 1.37 by ats, Tue Apr 6 22:09:22 2004 UTC vs.
Revision 1.59 by tdb, Sun Oct 3 18:35:58 2010 UTC

# Line 21 | Line 21
21   * $Id$
22   */
23  
24 + #ifndef STATGRAB_H
25 + #define STATGRAB_H
26 +
27 + #ifdef __cplusplus
28 + extern "C" {
29 + #endif
30 +
31   #include <sys/types.h>
32  
33   /* FIXME typedefs for 32/64-bit types */
34   /* FIXME maybe tidy up field names? */
28 /* FIXME tab/space damage */
29 /* FIXME prefixes for util functions too */
35   /* FIXME comments for less obvious fields */
36  
37   int sg_init(void);
38 + int sg_snapshot();
39 + int sg_shutdown();
40   int sg_drop_privileges(void);
41  
42   typedef enum {
43 <        SG_ERROR_NONE = 0
43 >        SG_ERROR_NONE = 0,
44 >        SG_ERROR_ASPRINTF,
45 >        SG_ERROR_DEVICES,
46 >        SG_ERROR_DEVSTAT_GETDEVS,
47 >        SG_ERROR_DEVSTAT_SELECTDEVS,
48 >        SG_ERROR_DISKINFO,
49 >        SG_ERROR_ENOENT,
50 >        SG_ERROR_GETIFADDRS,
51 >        SG_ERROR_GETMNTINFO,
52 >        SG_ERROR_GETPAGESIZE,
53 >        SG_ERROR_HOST,
54 >        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 >        SG_ERROR_MALLOC,
61 >        SG_ERROR_MEMSTATUS,
62 >        SG_ERROR_OPEN,
63 >        SG_ERROR_OPENDIR,
64 >        SG_ERROR_PARSE,
65 >        SG_ERROR_PDHADD,
66 >        SG_ERROR_PDHCOLLECT,
67 >        SG_ERROR_PDHOPEN,
68 >        SG_ERROR_PDHREAD,
69 >        SG_ERROR_PERMISSION,
70 >        SG_ERROR_PSTAT,
71 >        SG_ERROR_SETEGID,
72 >        SG_ERROR_SETEUID,
73 >        SG_ERROR_SETMNTENT,
74 >        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 >        SG_ERROR_XSW_VER_MISMATCH,
83 >        SG_ERROR_GETMSG,
84 >        SG_ERROR_PUTMSG
85   } sg_error;
86  
87   void sg_set_error(sg_error code, const char *arg);
88 + void sg_set_error_with_errno(sg_error code, const char *arg);
89   sg_error sg_get_error();
90 + const char *sg_get_error_arg();
91 + int sg_get_error_errno();
92   const char *sg_str_error(sg_error code);
93  
94   typedef struct {
# Line 52 | Line 103 | typedef struct {
103   sg_host_info *sg_get_host_info();
104  
105   typedef struct {
106 <        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;
106 >        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   } sg_cpu_stats;
115  
116   sg_cpu_stats *sg_get_cpu_stats();
117   sg_cpu_stats *sg_get_cpu_stats_diff();
118  
119   typedef struct {
120 <        float user;
121 <        float kernel;
122 <        float idle;
123 <        float iowait;
124 <        float swap;
125 <        float nice;
120 >        float user;
121 >        float kernel;
122 >        float idle;
123 >        float iowait;
124 >        float swap;
125 >        float nice;
126          time_t time_taken;
127   } sg_cpu_percents;
128  
# Line 110 | Line 161 | typedef struct {
161   sg_swap_stats *sg_get_swap_stats();
162  
163   typedef struct {
164 <        char *device_name;
164 >        char *device_name;
165          char *fs_type;
166 <        char *mnt_point;
167 <        long long size;
168 <        long long used;
169 <        long long avail;
170 <        long long total_inodes;
166 >        char *mnt_point;
167 >        long long size;
168 >        long long used;
169 >        long long avail;
170 >        long long total_inodes;
171          long long used_inodes;
172 <        long long free_inodes;
172 >        long long free_inodes;
173 >        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   } sg_fs_stats;
181  
182   sg_fs_stats *sg_get_fs_stats(int *entries);
183  
184 + 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   typedef struct {
188          char *disk_name;
189          long long read_bytes;
# Line 133 | Line 194 | typedef struct {
194   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  
197 + int sg_disk_io_compare_name(const void *va, const void *vb);
198 +
199   typedef struct {
200          char *interface_name;
201          long long tx;
# Line 148 | Line 211 | typedef struct {
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  
214 + int sg_network_io_compare_name(const void *va, const void *vb);
215 +
216   typedef enum {
217          SG_IFACE_DUPLEX_FULL,
218          SG_IFACE_DUPLEX_HALF,
# Line 157 | Line 222 | typedef enum {
222   typedef struct {
223          char *interface_name;
224          int speed;      /* In megabits/sec */
225 +        sg_iface_duplex duplex;
226 + #ifdef SG_ENABLE_DEPRECATED
227          sg_iface_duplex dup;
228 + #endif
229          int up;
230   } sg_network_iface_stats;
231  
232   sg_network_iface_stats *sg_get_network_iface_stats(int *entries);
233  
234 + int sg_network_iface_compare_name(const void *va, const void *vb);
235 +
236   typedef struct {
237          long long pages_pagein;
238          long long pages_pageout;
# Line 172 | Line 242 | typedef struct {
242   sg_page_stats *sg_get_page_stats();
243   sg_page_stats *sg_get_page_stats_diff();
244  
245 + /* Recommend to add SG_PROCESS_STATE_IDLE */
246   typedef enum {
247          SG_PROCESS_STATE_RUNNING,
248          SG_PROCESS_STATE_SLEEPING,
# Line 188 | Line 259 | typedef struct {
259          pid_t parent; /* Parent pid */
260          pid_t pgid;   /* process id of process group leader */
261  
262 + /* Windows does not have uid_t or gid_t types */
263 + #ifndef WIN32
264          uid_t uid;
265          uid_t euid;
266          gid_t gid;
267          gid_t egid;
268 + #else
269 +        int uid;
270 +        int euid;
271 +        int gid;
272 +        int egid;
273 + #endif
274  
275          unsigned long long proc_size; /* in bytes */
276          unsigned long long proc_resident; /* in bytes */
# Line 203 | Line 282 | typedef struct {
282  
283   sg_process_stats *sg_get_process_stats(int *entries);
284  
285 + int sg_process_compare_name(const void *va, const void *vb);
286 + 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   typedef struct {
295          int total;
296          int running;
# Line 217 | Line 305 | sg_process_count *sg_get_process_count();
305   #include <statgrab_deprecated.h>
306   #endif
307  
308 + #ifdef __cplusplus
309 + }
310 + #endif
311 +
312 + #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines