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.18 by ats, Mon Jan 5 17:20:29 2004 UTC vs.
Revision 1.50 by tdb, Fri Jul 2 11:21:30 2004 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 + #ifndef STATGRAB_H
25 + #define STATGRAB_H
26 +
27   #include <sys/types.h>
22 #ifdef NETBSD
23 #include <limits.h>
24 #endif
25 #ifdef CYGWIN
26 #include <sys/unistd.h>
27 #endif
28  
29 < typedef struct{
30 <        long long user;
31 <        long long kernel;
32 <        long long idle;
33 <        long long iowait;
34 <        long long swap;
35 <        long long nice;
36 <        long long total;
37 <        time_t systime;
38 < }cpu_states_t;
29 > /* FIXME typedefs for 32/64-bit types */
30 > /* FIXME maybe tidy up field names? */
31 > /* FIXME comments for less obvious fields */
32  
33 < typedef struct{
34 <        float user;
35 <        float kernel;
36 <        float idle;
37 <        float iowait;
38 <        float swap;
39 <        float nice;
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;
68 >
69 > void sg_set_error(sg_error code, const char *arg);
70 > sg_error sg_get_error();
71 > const char *sg_get_error_arg();
72 > const char *sg_str_error(sg_error code);
73 >
74 > typedef struct {
75 >        char *os_name;
76 >        char *os_release;
77 >        char *os_version;
78 >        char *platform;
79 >        char *hostname;
80 >        time_t uptime;
81 > } sg_host_info;
82 >
83 > sg_host_info *sg_get_host_info();
84 >
85 > typedef struct {
86 >        long long user;
87 >        long long kernel;
88 >        long long idle;
89 >        long long iowait;
90 >        long long swap;
91 >        long long nice;
92 >        long long total;
93 >        time_t systime;
94 > } sg_cpu_stats;
95 >
96 > sg_cpu_stats *sg_get_cpu_stats();
97 > sg_cpu_stats *sg_get_cpu_stats_diff();
98 >
99 > typedef struct {
100 >        float user;
101 >        float kernel;
102 >        float idle;
103 >        float iowait;
104 >        float swap;
105 >        float nice;
106          time_t time_taken;
107 < }cpu_percent_t;
107 > } sg_cpu_percents;
108  
109 < typedef struct{
109 > sg_cpu_percents *sg_get_cpu_percents();
110 >
111 > typedef struct {
112          long long total;
113          long long free;
114          long long used;
115          long long cache;
116 < }mem_stat_t;
116 > } sg_mem_stats;
117  
118 < typedef struct{
118 > sg_mem_stats *sg_get_mem_stats();
119 >
120 > typedef struct {
121          double min1;
122          double min5;
123          double min15;
124 < }load_stat_t;
124 > } sg_load_stats;
125  
126 < #ifdef SOLARIS
64 < #define MAX_LOGIN_NAME_SIZE 8
65 < #endif
66 < #if defined(LINUX) || defined(FREEBSD)
67 < #define MAX_LOGIN_NAME_SIZE UT_NAMESIZE
68 < #endif
69 < #ifdef NETBSD
70 < #define MAX_LOGIN_NAME_SIZE _POSIX_LOGIN_NAME_MAX
71 < #endif
72 < #if defined(CYGWIN)
73 < #define MAX_LOGIN_NAME_SIZE _SC_LOGIN_NAME_MAX
74 < #endif
126 > sg_load_stats *sg_get_load_stats();
127  
128 < typedef struct{
128 > typedef struct {
129          char *name_list;
130          int num_entries;
131 < }user_stat_t;
131 > } sg_user_stats;
132  
133 < typedef struct{
133 > sg_user_stats *sg_get_user_stats();
134 >
135 > typedef struct {
136          long long total;
137          long long used;
138          long long free;
139 < }swap_stat_t;
139 > } sg_swap_stats;
140  
141 < typedef struct{
88 <        char *os_name;
89 <        char *os_release;
90 <        char *os_version;
91 <        char *platform;
92 <        char *hostname;
93 <        time_t uptime;
94 < }general_stat_t;
141 > sg_swap_stats *sg_get_swap_stats();
142  
143   typedef struct {
144 <        char *device_name;
144 >        char *device_name;
145          char *fs_type;
146 <        char *mnt_point;
147 <        long long size;
148 <        long long used;
149 <        long long avail;
150 <        long long total_inodes;
146 >        char *mnt_point;
147 >        long long size;
148 >        long long used;
149 >        long long avail;
150 >        long long total_inodes;
151          long long used_inodes;
152 <        long long free_inodes;
153 < }disk_stat_t;
152 >        long long free_inodes;
153 > } sg_fs_stats;
154  
155 < typedef struct{
155 > sg_fs_stats *sg_get_fs_stats(int *entries);
156 >
157 > int sg_fs_compare_device_name(const void *va, const void *vb);
158 > int sg_fs_compare_mnt_point(const void *va, const void *vb);
159 >
160 > typedef struct {
161          char *disk_name;
162          long long read_bytes;
163          long long write_bytes;
164          time_t systime;
165 < }diskio_stat_t;
165 > } sg_disk_io_stats;
166  
167 < typedef struct{
168 <        int total;
117 <        int running;
118 <        int sleeping;
119 <        int stopped;
120 <        int zombie;
121 < }process_stat_t;
167 > sg_disk_io_stats *sg_get_disk_io_stats(int *entries);
168 > sg_disk_io_stats *sg_get_disk_io_stats_diff(int *entries);
169  
170 < typedef struct{
170 > int sg_disk_io_compare_name(const void *va, const void *vb);
171 >
172 > typedef struct {
173          char *interface_name;
174          long long tx;
175          long long rx;
176 +        long long ipackets;
177 +        long long opackets;
178 +        long long ierrors;
179 +        long long oerrors;
180 +        long long collisions;
181          time_t systime;
182 < }network_stat_t;
182 > } sg_network_io_stats;
183  
184 < typedef struct{
184 > sg_network_io_stats *sg_get_network_io_stats(int *entries);
185 > sg_network_io_stats *sg_get_network_io_stats_diff(int *entries);
186 >
187 > int sg_network_io_compare_name(const void *va, const void *vb);
188 >
189 > typedef enum {
190 >        SG_IFACE_DUPLEX_FULL,
191 >        SG_IFACE_DUPLEX_HALF,
192 >        SG_IFACE_DUPLEX_UNKNOWN
193 > } sg_iface_duplex;
194 >
195 > typedef struct {
196 >        char *interface_name;
197 >        int speed;      /* In megabits/sec */
198 >        sg_iface_duplex dup;
199 >        int up;
200 > } sg_network_iface_stats;
201 >
202 > sg_network_iface_stats *sg_get_network_iface_stats(int *entries);
203 >
204 > int sg_network_iface_compare_name(const void *va, const void *vb);
205 >
206 > typedef struct {
207          long long pages_pagein;
208          long long pages_pageout;
209          time_t systime;
210 < }page_stat_t;
210 > } sg_page_stats;
211  
212 < cpu_states_t *get_cpu_totals();
213 < cpu_states_t *get_cpu_diff();
138 < cpu_percent_t *cpu_percent_usage();
212 > sg_page_stats *sg_get_page_stats();
213 > sg_page_stats *sg_get_page_stats_diff();
214  
215 < mem_stat_t *get_memory_stats();
215 > typedef enum {
216 >        SG_PROCESS_STATE_RUNNING,
217 >        SG_PROCESS_STATE_SLEEPING,
218 >        SG_PROCESS_STATE_STOPPED,
219 >        SG_PROCESS_STATE_ZOMBIE,
220 >        SG_PROCESS_STATE_UNKNOWN
221 > } sg_process_state;
222  
223 < load_stat_t *get_load_stats();
223 > typedef struct {
224 >        char *process_name;
225 >        char *proctitle;
226  
227 < user_stat_t *get_user_stats();
227 >        pid_t pid;
228 >        pid_t parent; /* Parent pid */
229 >        pid_t pgid;   /* process id of process group leader */
230  
231 < swap_stat_t *get_swap_stats();
231 >        uid_t uid;
232 >        uid_t euid;
233 >        gid_t gid;
234 >        gid_t egid;
235  
236 < general_stat_t *get_general_stats();
236 >        unsigned long long proc_size; /* in bytes */
237 >        unsigned long long proc_resident; /* in bytes */
238 >        time_t time_spent; /* time running in seconds */
239 >        double cpu_percent;
240 >        int nice;
241 >        sg_process_state state;
242 > } sg_process_stats;
243  
244 < disk_stat_t *get_disk_stats(int *entries);
151 < diskio_stat_t *get_diskio_stats(int *entries);
152 < diskio_stat_t *get_diskio_stats_diff(int *entries);
244 > sg_process_stats *sg_get_process_stats(int *entries);
245  
246 < process_stat_t *get_process_stats();
246 > int sg_process_compare_name(const void *va, const void *vb);
247 > int sg_process_compare_pid(const void *va, const void *vb);
248 > int sg_process_compare_uid(const void *va, const void *vb);
249 > int sg_process_compare_gid(const void *va, const void *vb);
250 > int sg_process_compare_size(const void *va, const void *vb);
251 > int sg_process_compare_res(const void *va, const void *vb);
252 > int sg_process_compare_cpu(const void *va, const void *vb);
253 > int sg_process_compare_time(const void *va, const void *vb);
254  
255 < network_stat_t *get_network_stats(int *entries);
256 < network_stat_t *get_network_stats_diff(int *entries);
255 > typedef struct {
256 >        int total;
257 >        int running;
258 >        int sleeping;
259 >        int stopped;
260 >        int zombie;
261 > } sg_process_count;
262  
263 < page_stat_t *get_page_stats();
160 < page_stat_t *get_page_stats_diff();
263 > sg_process_count *sg_get_process_count();
264  
265 < int statgrab_init(void);
266 < int statgrab_drop_privileges(void);
265 > #ifdef SG_ENABLE_DEPRECATED
266 > #include <statgrab_deprecated.h>
267 > #endif
268  
269 + #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines