ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/statgrab.h
Revision: 1.41
Committed: Wed Apr 7 19:26:16 2004 UTC (20 years, 1 month ago) by tdb
Content type: text/plain
Branch: MAIN
Changes since 1.40: +9 -2 lines
Log Message:
Error reporting for disk_stats.

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