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

# Content
1 /*
2 * i-scream libstatgrab
3 * http://www.i-scream.org
4 * Copyright (C) 2000-2004 i-scream
5 *
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 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 GNU
14 * Lesser General Public License for more details.
15 *
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: statgrab.h,v 1.38 2004/04/07 09:44:08 tdb Exp $
22 */
23
24 #include <sys/types.h>
25
26 /* 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
35 typedef enum {
36 SG_ERROR_NONE = 0,
37 SG_ERROR_MALLOC,
38 SG_ERROR_KSTAT_OPEN,
39 SG_ERROR_OPEN,
40 SG_ERROR_SYSCTLBYNAME,
41 SG_ERROR_PARSE
42 } sg_error;
43
44 void sg_set_error(sg_error code, const char *arg);
45 sg_error sg_get_error();
46 const char *sg_str_error(sg_error code);
47
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 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 } sg_cpu_stats;
69
70 sg_cpu_stats *sg_get_cpu_stats();
71 sg_cpu_stats *sg_get_cpu_stats_diff();
72
73 typedef struct {
74 float user;
75 float kernel;
76 float idle;
77 float iowait;
78 float swap;
79 float nice;
80 time_t time_taken;
81 } sg_cpu_percents;
82
83 sg_cpu_percents *sg_get_cpu_percents();
84
85 typedef struct {
86 long long total;
87 long long free;
88 long long used;
89 long long cache;
90 } sg_mem_stats;
91
92 sg_mem_stats *sg_get_mem_stats();
93
94 typedef struct {
95 double min1;
96 double min5;
97 double min15;
98 } sg_load_stats;
99
100 sg_load_stats *sg_get_load_stats();
101
102 typedef struct {
103 char *name_list;
104 int num_entries;
105 } sg_user_stats;
106
107 sg_user_stats *sg_get_user_stats();
108
109 typedef struct {
110 long long total;
111 long long used;
112 long long free;
113 } sg_swap_stats;
114
115 sg_swap_stats *sg_get_swap_stats();
116
117 typedef struct {
118 char *device_name;
119 char *fs_type;
120 char *mnt_point;
121 long long size;
122 long long used;
123 long long avail;
124 long long total_inodes;
125 long long used_inodes;
126 long long free_inodes;
127 } sg_fs_stats;
128
129 sg_fs_stats *sg_get_fs_stats(int *entries);
130
131 typedef struct {
132 char *disk_name;
133 long long read_bytes;
134 long long write_bytes;
135 time_t systime;
136 } sg_disk_io_stats;
137
138 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
141 typedef struct {
142 char *interface_name;
143 long long tx;
144 long long rx;
145 long long ipackets;
146 long long opackets;
147 long long ierrors;
148 long long oerrors;
149 long long collisions;
150 time_t systime;
151 } 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
156 typedef enum {
157 SG_IFACE_DUPLEX_FULL,
158 SG_IFACE_DUPLEX_HALF,
159 SG_IFACE_DUPLEX_UNKNOWN
160 } sg_iface_duplex;
161
162 typedef struct {
163 char *interface_name;
164 int speed; /* In megabits/sec */
165 sg_iface_duplex dup;
166 int up;
167 } sg_network_iface_stats;
168
169 sg_network_iface_stats *sg_get_network_iface_stats(int *entries);
170
171 typedef struct {
172 long long pages_pagein;
173 long long pages_pageout;
174 time_t systime;
175 } sg_page_stats;
176
177 sg_page_stats *sg_get_page_stats();
178 sg_page_stats *sg_get_page_stats_diff();
179
180 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
188 typedef struct {
189 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 time_t time_spent; /* time running in seconds */
204 double cpu_percent;
205 int nice;
206 sg_process_state state;
207 } sg_process_stats;
208
209 sg_process_stats *sg_get_process_stats(int *entries);
210
211 typedef struct {
212 int total;
213 int running;
214 int sleeping;
215 int stopped;
216 int zombie;
217 } sg_process_count;
218
219 sg_process_count *sg_get_process_count();
220
221 #ifdef SG_ENABLE_DEPRECATED
222 #include <statgrab_deprecated.h>
223 #endif
224