ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/statgrab.h
Revision: 1.38
Committed: Wed Apr 7 09:44:08 2004 UTC (20 years, 2 months ago) by tdb
Content type: text/plain
Branch: MAIN
Changes since 1.37: +3 -2 lines
Log Message:
Add sg_realloc, and a macro fo sg_malloc.

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