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.2 by pajs, Tue Feb 18 23:12:08 2003 UTC vs.
Revision 1.53 by ats, Sun Jul 18 20:44:01 2004 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines