166 |
|
|
167 |
|
void populate_cpu() { |
168 |
|
if (use_cpu_percent) { |
169 |
< |
cpu_percent_t *cpu_p = cpu_percent_usage(); |
169 |
> |
sg_cpu_percents *cpu_p = sg_get_cpu_percents(); |
170 |
|
|
171 |
|
if (cpu_p != NULL) { |
172 |
|
add_stat(FLOAT, &cpu_p->user, |
185 |
|
"cpu", "time_taken", NULL); |
186 |
|
} |
187 |
|
} else { |
188 |
< |
cpu_states_t *cpu_s; |
188 |
> |
sg_cpu_stats *cpu_s; |
189 |
|
|
190 |
< |
cpu_s = use_diffs ? get_cpu_diff() : get_cpu_totals(); |
190 |
> |
cpu_s = use_diffs ? sg_get_cpu_stats_diff() |
191 |
> |
: sg_get_cpu_stats(); |
192 |
|
if (cpu_s != NULL) { |
193 |
|
add_stat(LONG_LONG, &cpu_s->user, |
194 |
|
"cpu", "user", NULL); |
211 |
|
} |
212 |
|
|
213 |
|
void populate_mem() { |
214 |
< |
mem_stat_t *mem = get_memory_stats(); |
214 |
> |
sg_mem_stats *mem = sg_get_mem_stats(); |
215 |
|
|
216 |
|
if (mem != NULL) { |
217 |
|
add_stat(LONG_LONG, &mem->total, "mem", "total", NULL); |
222 |
|
} |
223 |
|
|
224 |
|
void populate_load() { |
225 |
< |
load_stat_t *load = get_load_stats(); |
225 |
> |
sg_load_stats *load = sg_get_load_stats(); |
226 |
|
|
227 |
|
if (load != NULL) { |
228 |
|
add_stat(DOUBLE, &load->min1, "load", "min1", NULL); |
232 |
|
} |
233 |
|
|
234 |
|
void populate_user() { |
235 |
< |
user_stat_t *user = get_user_stats(); |
235 |
> |
sg_user_stats *user = sg_get_user_stats(); |
236 |
|
|
237 |
|
if (user != NULL) { |
238 |
|
add_stat(INT, &user->num_entries, "user", "num", NULL); |
241 |
|
} |
242 |
|
|
243 |
|
void populate_swap() { |
244 |
< |
swap_stat_t *swap = get_swap_stats(); |
244 |
> |
sg_swap_stats *swap = sg_get_swap_stats(); |
245 |
|
|
246 |
|
if (swap != NULL) { |
247 |
|
add_stat(LONG_LONG, &swap->total, "swap", "total", NULL); |
251 |
|
} |
252 |
|
|
253 |
|
void populate_general() { |
254 |
< |
general_stat_t *gen = get_general_stats(); |
254 |
> |
/* FIXME this should be renamed to host. */ |
255 |
> |
sg_host_info *host = sg_get_host_info(); |
256 |
|
|
257 |
< |
if (gen != NULL) { |
258 |
< |
add_stat(STRING, &gen->os_name, |
257 |
> |
if (host != NULL) { |
258 |
> |
add_stat(STRING, &host->os_name, |
259 |
|
"general", "os_name", NULL); |
260 |
< |
add_stat(STRING, &gen->os_release, |
260 |
> |
add_stat(STRING, &host->os_release, |
261 |
|
"general", "os_release", NULL); |
262 |
< |
add_stat(STRING, &gen->os_version, |
262 |
> |
add_stat(STRING, &host->os_version, |
263 |
|
"general", "os_version", NULL); |
264 |
< |
add_stat(STRING, &gen->platform, "general", "platform", NULL); |
265 |
< |
add_stat(STRING, &gen->hostname, "general", "hostname", NULL); |
266 |
< |
add_stat(TIME_T, &gen->uptime, "general", "uptime", NULL); |
264 |
> |
add_stat(STRING, &host->platform, "general", "platform", NULL); |
265 |
> |
add_stat(STRING, &host->hostname, "general", "hostname", NULL); |
266 |
> |
add_stat(TIME_T, &host->uptime, "general", "uptime", NULL); |
267 |
|
} |
268 |
|
} |
269 |
|
|
270 |
|
void populate_fs() { |
271 |
|
int n, i; |
272 |
< |
disk_stat_t *disk = get_disk_stats(&n); |
272 |
> |
sg_fs_stats *disk = sg_get_fs_stats(&n); |
273 |
|
|
274 |
|
if (disk != NULL) { |
275 |
|
for (i = 0; i < n; i++) { |
318 |
|
|
319 |
|
void populate_disk() { |
320 |
|
int n, i; |
321 |
< |
diskio_stat_t *diskio; |
321 |
> |
sg_disk_io_stats *diskio; |
322 |
|
|
323 |
< |
diskio = use_diffs ? get_diskio_stats_diff(&n) : get_diskio_stats(&n); |
323 |
> |
diskio = use_diffs ? sg_get_disk_io_stats_diff(&n) |
324 |
> |
: sg_get_disk_io_stats(&n); |
325 |
|
if (diskio != NULL) { |
326 |
|
for (i = 0; i < n; i++) { |
327 |
|
const char *name = diskio[i].disk_name; |
339 |
|
} |
340 |
|
|
341 |
|
void populate_proc() { |
342 |
< |
process_stat_t *proc = get_process_stats(); |
342 |
> |
/* FIXME expose individual process info too */ |
343 |
> |
sg_process_count *proc = sg_get_process_count(); |
344 |
|
|
345 |
|
if (proc != NULL) { |
346 |
|
add_stat(INT, &proc->total, "proc", "total", NULL); |
353 |
|
|
354 |
|
void populate_net() { |
355 |
|
int n, i; |
356 |
< |
network_stat_t *net; |
357 |
< |
network_iface_stat_t *iface; |
356 |
> |
sg_network_io_stats *io; |
357 |
> |
sg_network_iface_stats *iface; |
358 |
|
|
359 |
< |
net = use_diffs ? get_network_stats_diff(&n) : get_network_stats(&n); |
360 |
< |
if (net != NULL) { |
359 |
> |
io = use_diffs ? sg_get_network_io_stats_diff(&n) |
360 |
> |
: sg_get_network_io_stats(&n); |
361 |
> |
if (io != NULL) { |
362 |
|
for (i = 0; i < n; i++) { |
363 |
< |
const char *name = net[i].interface_name; |
363 |
> |
const char *name = io[i].interface_name; |
364 |
|
|
365 |
< |
add_stat(STRING, &net[i].interface_name, |
365 |
> |
add_stat(STRING, &io[i].interface_name, |
366 |
|
"net", name, "interface_name", NULL); |
367 |
< |
add_stat(LONG_LONG, &net[i].tx, |
367 |
> |
add_stat(LONG_LONG, &io[i].tx, |
368 |
|
"net", name, "tx", NULL); |
369 |
< |
add_stat(LONG_LONG, &net[i].rx, |
369 |
> |
add_stat(LONG_LONG, &io[i].rx, |
370 |
|
"net", name, "rx", NULL); |
371 |
< |
add_stat(LONG_LONG, &net[i].ipackets, |
371 |
> |
add_stat(LONG_LONG, &io[i].ipackets, |
372 |
|
"net", name, "ipackets", NULL); |
373 |
< |
add_stat(LONG_LONG, &net[i].opackets, |
373 |
> |
add_stat(LONG_LONG, &io[i].opackets, |
374 |
|
"net", name, "opackets", NULL); |
375 |
< |
add_stat(LONG_LONG, &net[i].ierrors, |
375 |
> |
add_stat(LONG_LONG, &io[i].ierrors, |
376 |
|
"net", name, "ierrors", NULL); |
377 |
< |
add_stat(LONG_LONG, &net[i].oerrors, |
377 |
> |
add_stat(LONG_LONG, &io[i].oerrors, |
378 |
|
"net", name, "oerrors", NULL); |
379 |
< |
add_stat(LONG_LONG, &net[i].collisions, |
379 |
> |
add_stat(LONG_LONG, &io[i].collisions, |
380 |
|
"net", name, "collisions", NULL); |
381 |
< |
add_stat(TIME_T, &net[i].systime, |
381 |
> |
add_stat(TIME_T, &io[i].systime, |
382 |
|
"net", name, "systime", NULL); |
383 |
|
} |
384 |
|
} |
385 |
|
|
386 |
< |
iface = get_network_iface_stats(&n); |
386 |
> |
iface = sg_get_network_iface_stats(&n); |
387 |
|
if (iface != NULL) { |
388 |
|
for (i = 0; i < n; i++) { |
389 |
|
const char *name = iface[i].interface_name; |
399 |
|
} |
400 |
|
|
401 |
|
void populate_page() { |
402 |
< |
page_stat_t *page; |
402 |
> |
sg_page_stats *page; |
403 |
|
|
404 |
< |
page = use_diffs ? get_page_stats_diff() : get_page_stats(); |
404 |
> |
page = use_diffs ? sg_get_page_stats_diff() : sg_get_page_stats(); |
405 |
|
if (page != NULL) { |
406 |
|
add_stat(LONG_LONG, &page->pages_pagein, "page", "in", NULL); |
407 |
|
add_stat(LONG_LONG, &page->pages_pageout, "page", "out", NULL); |
499 |
|
printf("%s", *(int *)v ? "true" : "false"); |
500 |
|
break; |
501 |
|
case DUPLEX: |
502 |
< |
switch (*(statgrab_duplex *) v) { |
503 |
< |
case FULL_DUPLEX: |
502 |
> |
switch (*(sg_iface_duplex *) v) { |
503 |
> |
case SG_IFACE_DUPLEX_FULL: |
504 |
|
printf("full"); |
505 |
|
break; |
506 |
< |
case HALF_DUPLEX: |
506 |
> |
case SG_IFACE_DUPLEX_HALF: |
507 |
|
printf("half"); |
508 |
|
break; |
509 |
|
default: |
667 |
|
|
668 |
|
/* We don't care if statgrab_init fails, because we can just display |
669 |
|
the statistics that can be read as non-root. */ |
670 |
< |
statgrab_init(); |
671 |
< |
if (statgrab_drop_privileges() != 0) |
670 |
> |
sg_init(); |
671 |
> |
if (sg_drop_privileges() != 0) |
672 |
|
die("Failed to drop setuid/setgid privileges"); |
673 |
|
|
674 |
|
switch (repeat_mode) { |