ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/statgrab.h
Revision: 1.56
Committed: Wed Jul 13 13:01:24 2005 UTC (18 years, 10 months ago) by tdb
Content type: text/plain
Branch: MAIN
CVS Tags: LIBSTATGRAB_0_12
Changes since 1.55: +8 -1 lines
Log Message:
Add more fs stats.

Patches provided by: Roman Neuhauser

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