ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/statgrab.h
Revision: 1.42
Committed: Wed Apr 7 21:08:40 2004 UTC (20 years, 1 month ago) by tdb
Content type: text/plain
Branch: MAIN
Changes since 1.41: +26 -9 lines
Log Message:
The rest of the error handling stuff (except the vector code).

I've been extremely unimaginative with the string names in error.c, but
they're all in one place so much easier to tidy up. I'm also beginning to
wonder if we actually needed an SG_ERROR_SYSTEM_CALL to indicate some call
into the system failed - because the majority of our errors are those :-)

Still to do, then:
 - vector code
 - better string names in error.c
 - deal with arg string in some way
 - make use of the error status in statgrab/saidar/examples

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.42 * $Id: statgrab.h,v 1.41 2004/04/07 19:26:16 tdb Exp $
22 pajs 1.1 */
23    
24 pajs 1.21 #include <sys/types.h>
25    
26 ats 1.33 /* FIXME typedefs for 32/64-bit types */
27     /* FIXME maybe tidy up field names? */
28     /* FIXME tab/space damage */
29     /* FIXME prefixes for util functions too */
30     /* FIXME comments for less obvious fields */
31    
32     int sg_init(void);
33     int sg_drop_privileges(void);
34 tdb 1.36
35     typedef enum {
36 tdb 1.38 SG_ERROR_NONE = 0,
37 tdb 1.42 SG_ERROR_ASPRINTF,
38     SG_ERROR_DEVSTAT_GETDEVS,
39     SG_ERROR_DEVSTAT_SELECTDEVS,
40     SG_ERROR_ENOENT,
41     SG_ERROR_GETIFADDRS,
42     SG_ERROR_GETMNTINFO,
43     SG_ERROR_GETPAGESIZE,
44     SG_ERROR_KSTAT_DATA_LOOKUP,
45     SG_ERROR_KSTAT_LOOKUP,
46     SG_ERROR_KSTAT_OPEN,
47     SG_ERROR_KSTAT_READ,
48     SG_ERROR_KVM_GETSWAPINFO,
49     SG_ERROR_KVM_OPENFILES,
50 tdb 1.39 SG_ERROR_MALLOC,
51     SG_ERROR_OPEN,
52 tdb 1.42 SG_ERROR_OPENDIR,
53 tdb 1.41 SG_ERROR_PARSE,
54 tdb 1.42 SG_ERROR_SETEGID,
55     SG_ERROR_SETEUID,
56 tdb 1.41 SG_ERROR_SETMNTENT,
57 tdb 1.42 SG_ERROR_SOCKET,
58     SG_ERROR_SWAPCTL,
59     SG_ERROR_SYSCONF,
60     SG_ERROR_SYSCTL,
61     SG_ERROR_SYSCTLBYNAME,
62     SG_ERROR_SYSCTLNAMETOMIB,
63     SG_ERROR_UNAME,
64     SG_ERROR_UNSUPPORTED,
65     SG_ERROR_XSW_VER_MISMATCH
66 tdb 1.36 } sg_error;
67    
68     void sg_set_error(sg_error code, const char *arg);
69     sg_error sg_get_error();
70 ats 1.37 const char *sg_str_error(sg_error code);
71 ats 1.33
72     typedef struct {
73     char *os_name;
74     char *os_release;
75     char *os_version;
76     char *platform;
77     char *hostname;
78     time_t uptime;
79     } sg_host_info;
80    
81     sg_host_info *sg_get_host_info();
82    
83     typedef struct {
84 tdb 1.39 long long user;
85     long long kernel;
86     long long idle;
87     long long iowait;
88     long long swap;
89     long long nice;
90     long long total;
91     time_t systime;
92 ats 1.33 } sg_cpu_stats;
93 pajs 1.1
94 ats 1.33 sg_cpu_stats *sg_get_cpu_stats();
95     sg_cpu_stats *sg_get_cpu_stats_diff();
96    
97     typedef struct {
98 tdb 1.39 float user;
99     float kernel;
100     float idle;
101     float iowait;
102     float swap;
103     float nice;
104 pajs 1.1 time_t time_taken;
105 ats 1.33 } sg_cpu_percents;
106    
107     sg_cpu_percents *sg_get_cpu_percents();
108 pajs 1.1
109 ats 1.33 typedef struct {
110 pajs 1.1 long long total;
111     long long free;
112     long long used;
113     long long cache;
114 ats 1.33 } sg_mem_stats;
115    
116     sg_mem_stats *sg_get_mem_stats();
117 pajs 1.1
118 ats 1.33 typedef struct {
119 pajs 1.1 double min1;
120     double min5;
121     double min15;
122 ats 1.33 } sg_load_stats;
123    
124     sg_load_stats *sg_get_load_stats();
125 pajs 1.1
126 ats 1.33 typedef struct {
127 pajs 1.8 char *name_list;
128 pajs 1.1 int num_entries;
129 ats 1.33 } sg_user_stats;
130    
131     sg_user_stats *sg_get_user_stats();
132 pajs 1.1
133 ats 1.33 typedef struct {
134 pajs 1.1 long long total;
135     long long used;
136     long long free;
137 ats 1.33 } sg_swap_stats;
138 pajs 1.1
139 ats 1.33 sg_swap_stats *sg_get_swap_stats();
140 pajs 1.1
141     typedef struct {
142 tdb 1.39 char *device_name;
143 pajs 1.1 char *fs_type;
144 tdb 1.39 char *mnt_point;
145     long long size;
146     long long used;
147     long long avail;
148     long long total_inodes;
149 pajs 1.1 long long used_inodes;
150 tdb 1.39 long long free_inodes;
151 ats 1.33 } sg_fs_stats;
152    
153     sg_fs_stats *sg_get_fs_stats(int *entries);
154 pajs 1.1
155 ats 1.33 typedef struct {
156 pajs 1.4 char *disk_name;
157     long long read_bytes;
158     long long write_bytes;
159     time_t systime;
160 ats 1.33 } sg_disk_io_stats;
161 pajs 1.4
162 ats 1.33 sg_disk_io_stats *sg_get_disk_io_stats(int *entries);
163     sg_disk_io_stats *sg_get_disk_io_stats_diff(int *entries);
164 pajs 1.1
165 ats 1.33 typedef struct {
166 pajs 1.1 char *interface_name;
167     long long tx;
168     long long rx;
169 tdb 1.28 long long ipackets;
170     long long opackets;
171     long long ierrors;
172     long long oerrors;
173     long long collisions;
174 pajs 1.1 time_t systime;
175 ats 1.33 } sg_network_io_stats;
176    
177     sg_network_io_stats *sg_get_network_io_stats(int *entries);
178     sg_network_io_stats *sg_get_network_io_stats_diff(int *entries);
179 pajs 1.24
180 ats 1.33 typedef enum {
181     SG_IFACE_DUPLEX_FULL,
182     SG_IFACE_DUPLEX_HALF,
183     SG_IFACE_DUPLEX_UNKNOWN
184     } sg_iface_duplex;
185 pajs 1.24
186 ats 1.33 typedef struct {
187 pajs 1.24 char *interface_name;
188     int speed; /* In megabits/sec */
189 ats 1.33 sg_iface_duplex dup;
190 pajs 1.27 int up;
191 ats 1.33 } sg_network_iface_stats;
192    
193     sg_network_iface_stats *sg_get_network_iface_stats(int *entries);
194 pajs 1.1
195 ats 1.33 typedef struct {
196 pajs 1.2 long long pages_pagein;
197     long long pages_pageout;
198 pajs 1.1 time_t systime;
199 ats 1.33 } sg_page_stats;
200    
201     sg_page_stats *sg_get_page_stats();
202     sg_page_stats *sg_get_page_stats_diff();
203 pajs 1.29
204 ats 1.33 typedef enum {
205     SG_PROCESS_STATE_RUNNING,
206     SG_PROCESS_STATE_SLEEPING,
207     SG_PROCESS_STATE_STOPPED,
208     SG_PROCESS_STATE_ZOMBIE,
209     SG_PROCESS_STATE_UNKNOWN
210     } sg_process_state;
211 pajs 1.30
212 ats 1.33 typedef struct {
213 pajs 1.29 char *process_name;
214     char *proctitle;
215    
216     pid_t pid;
217     pid_t parent; /* Parent pid */
218     pid_t pgid; /* process id of process group leader */
219    
220     uid_t uid;
221     uid_t euid;
222     gid_t gid;
223     gid_t egid;
224    
225     unsigned long long proc_size; /* in bytes */
226     unsigned long long proc_resident; /* in bytes */
227 tdb 1.31 time_t time_spent; /* time running in seconds */
228 pajs 1.29 double cpu_percent;
229     int nice;
230 ats 1.33 sg_process_state state;
231     } sg_process_stats;
232 pajs 1.29
233 ats 1.33 sg_process_stats *sg_get_process_stats(int *entries);
234 pajs 1.1
235 ats 1.33 typedef struct {
236     int total;
237     int running;
238     int sleeping;
239     int stopped;
240     int zombie;
241     } sg_process_count;
242 pajs 1.14
243 ats 1.33 sg_process_count *sg_get_process_count();
244 tdb 1.35
245     #ifdef SG_ENABLE_DEPRECATED
246     #include <statgrab_deprecated.h>
247     #endif
248 ats 1.18