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