1 |
|
/* |
2 |
< |
* i-scream central monitoring system |
2 |
> |
* i-scream libstatgrab |
3 |
|
* http://www.i-scream.org |
4 |
|
* Copyright (C) 2000-2004 i-scream |
5 |
|
* |
23 |
|
|
24 |
|
#include <sys/types.h> |
25 |
|
|
26 |
< |
typedef struct{ |
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 struct { |
36 |
> |
char *os_name; |
37 |
> |
char *os_release; |
38 |
> |
char *os_version; |
39 |
> |
char *platform; |
40 |
> |
char *hostname; |
41 |
> |
time_t uptime; |
42 |
> |
} sg_host_info; |
43 |
> |
|
44 |
> |
sg_host_info *sg_get_host_info(); |
45 |
> |
|
46 |
> |
typedef struct { |
47 |
|
long long user; |
48 |
|
long long kernel; |
49 |
|
long long idle; |
52 |
|
long long nice; |
53 |
|
long long total; |
54 |
|
time_t systime; |
55 |
< |
}cpu_states_t; |
55 |
> |
} sg_cpu_stats; |
56 |
|
|
57 |
< |
typedef struct{ |
57 |
> |
sg_cpu_stats *sg_get_cpu_stats(); |
58 |
> |
sg_cpu_stats *sg_get_cpu_stats_diff(); |
59 |
> |
|
60 |
> |
typedef struct { |
61 |
|
float user; |
62 |
|
float kernel; |
63 |
|
float idle; |
65 |
|
float swap; |
66 |
|
float nice; |
67 |
|
time_t time_taken; |
68 |
< |
}cpu_percent_t; |
68 |
> |
} sg_cpu_percents; |
69 |
|
|
70 |
< |
typedef struct{ |
70 |
> |
sg_cpu_percents *sg_get_cpu_percents(); |
71 |
> |
|
72 |
> |
typedef struct { |
73 |
|
long long total; |
74 |
|
long long free; |
75 |
|
long long used; |
76 |
|
long long cache; |
77 |
< |
}mem_stat_t; |
77 |
> |
} sg_mem_stats; |
78 |
|
|
79 |
< |
typedef struct{ |
79 |
> |
sg_mem_stats *sg_get_mem_stats(); |
80 |
> |
|
81 |
> |
typedef struct { |
82 |
|
double min1; |
83 |
|
double min5; |
84 |
|
double min15; |
85 |
< |
}load_stat_t; |
85 |
> |
} sg_load_stats; |
86 |
|
|
87 |
< |
typedef struct{ |
87 |
> |
sg_load_stats *sg_get_load_stats(); |
88 |
> |
|
89 |
> |
typedef struct { |
90 |
|
char *name_list; |
91 |
|
int num_entries; |
92 |
< |
}user_stat_t; |
92 |
> |
} sg_user_stats; |
93 |
|
|
94 |
< |
typedef struct{ |
94 |
> |
sg_user_stats *sg_get_user_stats(); |
95 |
> |
|
96 |
> |
typedef struct { |
97 |
|
long long total; |
98 |
|
long long used; |
99 |
|
long long free; |
100 |
< |
}swap_stat_t; |
100 |
> |
} sg_swap_stats; |
101 |
|
|
102 |
< |
typedef struct{ |
72 |
< |
char *os_name; |
73 |
< |
char *os_release; |
74 |
< |
char *os_version; |
75 |
< |
char *platform; |
76 |
< |
char *hostname; |
77 |
< |
time_t uptime; |
78 |
< |
}general_stat_t; |
102 |
> |
sg_swap_stats *sg_get_swap_stats(); |
103 |
|
|
104 |
|
typedef struct { |
105 |
|
char *device_name; |
111 |
|
long long total_inodes; |
112 |
|
long long used_inodes; |
113 |
|
long long free_inodes; |
114 |
< |
}disk_stat_t; |
114 |
> |
} sg_fs_stats; |
115 |
|
|
116 |
< |
typedef struct{ |
116 |
> |
sg_fs_stats *sg_get_fs_stats(int *entries); |
117 |
> |
|
118 |
> |
typedef struct { |
119 |
|
char *disk_name; |
120 |
|
long long read_bytes; |
121 |
|
long long write_bytes; |
122 |
|
time_t systime; |
123 |
< |
}diskio_stat_t; |
123 |
> |
} sg_disk_io_stats; |
124 |
|
|
125 |
< |
typedef struct{ |
126 |
< |
int total; |
101 |
< |
int running; |
102 |
< |
int sleeping; |
103 |
< |
int stopped; |
104 |
< |
int zombie; |
105 |
< |
}process_stat_t; |
125 |
> |
sg_disk_io_stats *sg_get_disk_io_stats(int *entries); |
126 |
> |
sg_disk_io_stats *sg_get_disk_io_stats_diff(int *entries); |
127 |
|
|
128 |
< |
typedef struct{ |
128 |
> |
typedef struct { |
129 |
|
char *interface_name; |
130 |
|
long long tx; |
131 |
|
long long rx; |
135 |
|
long long oerrors; |
136 |
|
long long collisions; |
137 |
|
time_t systime; |
138 |
< |
}network_stat_t; |
138 |
> |
} sg_network_io_stats; |
139 |
|
|
140 |
< |
typedef enum{ |
141 |
< |
FULL_DUPLEX, |
121 |
< |
HALF_DUPLEX, |
122 |
< |
UNKNOWN_DUPLEX |
123 |
< |
}statgrab_duplex; |
140 |
> |
sg_network_io_stats *sg_get_network_io_stats(int *entries); |
141 |
> |
sg_network_io_stats *sg_get_network_io_stats_diff(int *entries); |
142 |
|
|
143 |
< |
typedef struct{ |
143 |
> |
typedef enum { |
144 |
> |
SG_IFACE_DUPLEX_FULL, |
145 |
> |
SG_IFACE_DUPLEX_HALF, |
146 |
> |
SG_IFACE_DUPLEX_UNKNOWN |
147 |
> |
} sg_iface_duplex; |
148 |
> |
|
149 |
> |
typedef struct { |
150 |
|
char *interface_name; |
151 |
|
int speed; /* In megabits/sec */ |
152 |
< |
statgrab_duplex dup; |
152 |
> |
sg_iface_duplex dup; |
153 |
|
int up; |
154 |
< |
}network_iface_stat_t; |
154 |
> |
} sg_network_iface_stats; |
155 |
|
|
156 |
< |
typedef struct{ |
156 |
> |
sg_network_iface_stats *sg_get_network_iface_stats(int *entries); |
157 |
> |
|
158 |
> |
typedef struct { |
159 |
|
long long pages_pagein; |
160 |
|
long long pages_pageout; |
161 |
|
time_t systime; |
162 |
< |
}page_stat_t; |
162 |
> |
} sg_page_stats; |
163 |
|
|
164 |
< |
typedef struct{ |
164 |
> |
sg_page_stats *sg_get_page_stats(); |
165 |
> |
sg_page_stats *sg_get_page_stats_diff(); |
166 |
> |
|
167 |
> |
typedef enum { |
168 |
> |
SG_PROCESS_STATE_RUNNING, |
169 |
> |
SG_PROCESS_STATE_SLEEPING, |
170 |
> |
SG_PROCESS_STATE_STOPPED, |
171 |
> |
SG_PROCESS_STATE_ZOMBIE, |
172 |
> |
SG_PROCESS_STATE_UNKNOWN |
173 |
> |
} sg_process_state; |
174 |
> |
|
175 |
> |
typedef struct { |
176 |
|
char *process_name; |
177 |
|
char *proctitle; |
178 |
|
|
187 |
|
|
188 |
|
unsigned long long proc_size; /* in bytes */ |
189 |
|
unsigned long long proc_resident; /* in bytes */ |
190 |
< |
time_t time_spent; |
190 |
> |
time_t time_spent; /* time running in seconds */ |
191 |
|
double cpu_percent; |
192 |
|
int nice; |
193 |
< |
int state; |
194 |
< |
}proc_state_t; |
193 |
> |
sg_process_state state; |
194 |
> |
} sg_process_stats; |
195 |
|
|
196 |
< |
int get_proc_snapshot(proc_state_t **proc_state); |
196 |
> |
sg_process_stats *sg_get_process_stats(int *entries); |
197 |
|
|
198 |
< |
cpu_states_t *get_cpu_totals(); |
199 |
< |
cpu_states_t *get_cpu_diff(); |
200 |
< |
cpu_percent_t *cpu_percent_usage(); |
198 |
> |
typedef struct { |
199 |
> |
int total; |
200 |
> |
int running; |
201 |
> |
int sleeping; |
202 |
> |
int stopped; |
203 |
> |
int zombie; |
204 |
> |
} sg_process_count; |
205 |
|
|
206 |
< |
mem_stat_t *get_memory_stats(); |
166 |
< |
|
167 |
< |
load_stat_t *get_load_stats(); |
168 |
< |
|
169 |
< |
user_stat_t *get_user_stats(); |
170 |
< |
|
171 |
< |
swap_stat_t *get_swap_stats(); |
172 |
< |
|
173 |
< |
general_stat_t *get_general_stats(); |
174 |
< |
|
175 |
< |
disk_stat_t *get_disk_stats(int *entries); |
176 |
< |
diskio_stat_t *get_diskio_stats(int *entries); |
177 |
< |
diskio_stat_t *get_diskio_stats_diff(int *entries); |
178 |
< |
|
179 |
< |
process_stat_t *get_process_stats(); |
180 |
< |
|
181 |
< |
network_stat_t *get_network_stats(int *entries); |
182 |
< |
network_stat_t *get_network_stats_diff(int *entries); |
183 |
< |
|
184 |
< |
network_iface_stat_t *get_network_iface_stats(int *entries); |
185 |
< |
|
186 |
< |
page_stat_t *get_page_stats(); |
187 |
< |
page_stat_t *get_page_stats_diff(); |
188 |
< |
|
189 |
< |
int statgrab_init(void); |
190 |
< |
int statgrab_drop_privileges(void); |
206 |
> |
sg_process_count *sg_get_process_count(); |
207 |
|
|