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.15 by ats, Fri Oct 24 17:00:26 2003 UTC vs.
Revision 1.59 by tdb, Sun Oct 3 18:35:58 2010 UTC

# Line 1 | Line 1
1 < /*
2 < * i-scream central monitoring system
1 > /*
2 > * i-scream libstatgrab
3   * http://www.i-scream.org
4 < * Copyright (C) 2000-2003 i-scream
4 > * Copyright (C) 2000-2004 i-scream
5   *
6 < * This program is free software; you can redistribute it and/or
7 < * modify it under the terms of the GNU General Public License
8 < * as published by the Free Software Foundation; either version 2
9 < * of the License, or (at your option) any later version.
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 program is distributed in the hope that it will be useful,
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
14 < * GNU General Public License for more details.
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 General Public License
17 < * along with this program; if not, write to the Free Software
18 < * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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$
22   */
23  
24 < #include <sys/types.h>
25 < #ifdef NETBSD
26 < #include <limits.h>
24 > #ifndef STATGRAB_H
25 > #define STATGRAB_H
26 >
27 > #ifdef __cplusplus
28 > extern "C" {
29   #endif
30  
31 < typedef struct{
27 <        long long user;
28 <        long long kernel;
29 <        long long idle;
30 <        long long iowait;
31 <        long long swap;
32 <        long long nice;
33 <        long long total;
34 <        time_t systime;
35 < }cpu_states_t;
31 > #include <sys/types.h>
32  
33 < typedef struct{
34 <        float user;
35 <        float kernel;
36 <        float idle;
37 <        float iowait;
38 <        float swap;
39 <        float nice;
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 > int sg_snapshot();
39 > int sg_shutdown();
40 > int sg_drop_privileges(void);
41 >
42 > typedef enum {
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 {
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 >        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;
126          time_t time_taken;
127 < }cpu_percent_t;
127 > } sg_cpu_percents;
128  
129 < typedef struct{
129 > sg_cpu_percents *sg_get_cpu_percents();
130 >
131 > typedef struct {
132          long long total;
133          long long free;
134          long long used;
135          long long cache;
136 < }mem_stat_t;
136 > } sg_mem_stats;
137  
138 < typedef struct{
138 > sg_mem_stats *sg_get_mem_stats();
139 >
140 > typedef struct {
141          double min1;
142          double min5;
143          double min15;
144 < }load_stat_t;
144 > } sg_load_stats;
145  
146 < #ifdef SOLARIS
61 < #define MAX_LOGIN_NAME_SIZE 8
62 < #endif
63 < #if defined(LINUX) || defined(FREEBSD)
64 < #define MAX_LOGIN_NAME_SIZE UT_NAMESIZE
65 < #endif
66 < #ifdef NETBSD
67 < #define MAX_LOGIN_NAME_SIZE _POSIX_LOGIN_NAME_MAX
68 < #endif
146 > sg_load_stats *sg_get_load_stats();
147  
148 < typedef struct{
148 > typedef struct {
149          char *name_list;
150          int num_entries;
151 < }user_stat_t;
151 > } sg_user_stats;
152  
153 < typedef struct{
153 > sg_user_stats *sg_get_user_stats();
154 >
155 > typedef struct {
156          long long total;
157          long long used;
158          long long free;
159 < }swap_stat_t;
159 > } sg_swap_stats;
160  
161 < typedef struct{
82 <        char *os_name;
83 <        char *os_release;
84 <        char *os_version;
85 <        char *platform;
86 <        char *hostname;
87 <        time_t uptime;
88 < }general_stat_t;
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;
173 < }disk_stat_t;
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 < typedef struct{
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;
190          long long write_bytes;
191          time_t systime;
192 < }diskio_stat_t;
192 > } sg_disk_io_stats;
193  
194 < typedef struct{
195 <        int total;
111 <        int running;
112 <        int sleeping;
113 <        int stopped;
114 <        int zombie;
115 < }process_stat_t;
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 < typedef struct{
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;
202          long long rx;
203 +        long long ipackets;
204 +        long long opackets;
205 +        long long ierrors;
206 +        long long oerrors;
207 +        long long collisions;
208          time_t systime;
209 < }network_stat_t;
209 > } sg_network_io_stats;
210  
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,
219 >        SG_IFACE_DUPLEX_UNKNOWN
220 > } sg_iface_duplex;
221 >
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;
239          time_t systime;
240 < }page_stat_t;
240 > } sg_page_stats;
241  
242 < cpu_states_t *get_cpu_totals();
243 < cpu_states_t *get_cpu_diff();
132 < cpu_percent_t *cpu_percent_usage();
242 > sg_page_stats *sg_get_page_stats();
243 > sg_page_stats *sg_get_page_stats_diff();
244  
245 < mem_stat_t *get_memory_stats();
245 > /* Recommend to add SG_PROCESS_STATE_IDLE */
246 > 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  
254 < load_stat_t *get_load_stats();
254 > typedef struct {
255 >        char *process_name;
256 >        char *proctitle;
257  
258 < user_stat_t *get_user_stats();
258 >        pid_t pid;
259 >        pid_t parent; /* Parent pid */
260 >        pid_t pgid;   /* process id of process group leader */
261  
262 < swap_stat_t *get_swap_stats();
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 < general_stat_t *get_general_stats();
275 >        unsigned long long proc_size; /* in bytes */
276 >        unsigned long long proc_resident; /* in bytes */
277 >        time_t time_spent; /* time running in seconds */
278 >        double cpu_percent;
279 >        int nice;
280 >        sg_process_state state;
281 > } sg_process_stats;
282  
283 < disk_stat_t *get_disk_stats(int *entries);
145 < diskio_stat_t *get_diskio_stats(int *entries);
146 < diskio_stat_t *get_diskio_stats_diff(int *entries);
283 > sg_process_stats *sg_get_process_stats(int *entries);
284  
285 < process_stat_t *get_process_stats();
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 < network_stat_t *get_network_stats(int *entries);
295 < network_stat_t *get_network_stats_diff(int *entries);
294 > typedef struct {
295 >        int total;
296 >        int running;
297 >        int sleeping;
298 >        int stopped;
299 >        int zombie;
300 > } sg_process_count;
301  
302 < page_stat_t *get_page_stats();
154 < page_stat_t *get_page_stats_diff();
302 > sg_process_count *sg_get_process_count();
303  
304 < int statgrab_init(void);
304 > #ifdef SG_ENABLE_DEPRECATED
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