| 170 |
|
|
| 171 |
|
if (cpu_p != NULL) { |
| 172 |
|
add_stat(FLOAT, &cpu_p->user, |
| 173 |
< |
"cpu", "user", NULL); |
| 173 |
> |
"cpu", "user", NULL); |
| 174 |
|
add_stat(FLOAT, &cpu_p->kernel, |
| 175 |
< |
"cpu", "kernel", NULL); |
| 175 |
> |
"cpu", "kernel", NULL); |
| 176 |
|
add_stat(FLOAT, &cpu_p->idle, |
| 177 |
< |
"cpu", "idle", NULL); |
| 177 |
> |
"cpu", "idle", NULL); |
| 178 |
|
add_stat(FLOAT, &cpu_p->iowait, |
| 179 |
< |
"cpu", "iowait", NULL); |
| 179 |
> |
"cpu", "iowait", NULL); |
| 180 |
|
add_stat(FLOAT, &cpu_p->swap, |
| 181 |
< |
"cpu", "swap", NULL); |
| 181 |
> |
"cpu", "swap", NULL); |
| 182 |
|
add_stat(FLOAT, &cpu_p->nice, |
| 183 |
< |
"cpu", "nice", NULL); |
| 183 |
> |
"cpu", "nice", NULL); |
| 184 |
|
add_stat(TIME_T, &cpu_p->time_taken, |
| 185 |
< |
"cpu", "time_taken", NULL); |
| 185 |
> |
"cpu", "time_taken", NULL); |
| 186 |
|
} |
| 187 |
|
} else { |
| 188 |
|
sg_cpu_stats *cpu_s; |
| 189 |
|
|
| 190 |
|
cpu_s = use_diffs ? sg_get_cpu_stats_diff() |
| 191 |
< |
: sg_get_cpu_stats(); |
| 191 |
> |
: sg_get_cpu_stats(); |
| 192 |
|
if (cpu_s != NULL) { |
| 193 |
|
add_stat(LONG_LONG, &cpu_s->user, |
| 194 |
< |
"cpu", "user", NULL); |
| 194 |
> |
"cpu", "user", NULL); |
| 195 |
|
add_stat(LONG_LONG, &cpu_s->kernel, |
| 196 |
< |
"cpu", "kernel", NULL); |
| 196 |
> |
"cpu", "kernel", NULL); |
| 197 |
|
add_stat(LONG_LONG, &cpu_s->idle, |
| 198 |
< |
"cpu", "idle", NULL); |
| 198 |
> |
"cpu", "idle", NULL); |
| 199 |
|
add_stat(LONG_LONG, &cpu_s->iowait, |
| 200 |
< |
"cpu", "iowait", NULL); |
| 200 |
> |
"cpu", "iowait", NULL); |
| 201 |
|
add_stat(LONG_LONG, &cpu_s->swap, |
| 202 |
< |
"cpu", "swap", NULL); |
| 202 |
> |
"cpu", "swap", NULL); |
| 203 |
|
add_stat(LONG_LONG, &cpu_s->nice, |
| 204 |
< |
"cpu", "nice", NULL); |
| 204 |
> |
"cpu", "nice", NULL); |
| 205 |
|
add_stat(LONG_LONG, &cpu_s->total, |
| 206 |
< |
"cpu", "total", NULL); |
| 206 |
> |
"cpu", "total", NULL); |
| 207 |
|
add_stat(TIME_T, &cpu_s->systime, |
| 208 |
< |
"cpu", "systime", NULL); |
| 208 |
> |
"cpu", "systime", NULL); |
| 209 |
|
} |
| 210 |
|
} |
| 211 |
|
} |
| 256 |
|
|
| 257 |
|
if (host != NULL) { |
| 258 |
|
add_stat(STRING, &host->os_name, |
| 259 |
< |
"general", "os_name", NULL); |
| 259 |
> |
"general", "os_name", NULL); |
| 260 |
|
add_stat(STRING, &host->os_release, |
| 261 |
< |
"general", "os_release", NULL); |
| 261 |
> |
"general", "os_release", NULL); |
| 262 |
|
add_stat(STRING, &host->os_version, |
| 263 |
< |
"general", "os_version", NULL); |
| 263 |
> |
"general", "os_version", 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); |
| 293 |
|
*p = '_'; |
| 294 |
|
|
| 295 |
|
add_stat(STRING, &disk[i].device_name, |
| 296 |
< |
"fs", name, "device_name", NULL); |
| 296 |
> |
"fs", name, "device_name", NULL); |
| 297 |
|
add_stat(STRING, &disk[i].fs_type, |
| 298 |
< |
"fs", name, "fs_type", NULL); |
| 298 |
> |
"fs", name, "fs_type", NULL); |
| 299 |
|
add_stat(STRING, &disk[i].mnt_point, |
| 300 |
< |
"fs", name, "mnt_point", NULL); |
| 300 |
> |
"fs", name, "mnt_point", NULL); |
| 301 |
|
add_stat(LONG_LONG, &disk[i].size, |
| 302 |
< |
"fs", name, "size", NULL); |
| 302 |
> |
"fs", name, "size", NULL); |
| 303 |
|
add_stat(LONG_LONG, &disk[i].used, |
| 304 |
< |
"fs", name, "used", NULL); |
| 304 |
> |
"fs", name, "used", NULL); |
| 305 |
|
add_stat(LONG_LONG, &disk[i].avail, |
| 306 |
< |
"fs", name, "avail", NULL); |
| 306 |
> |
"fs", name, "avail", NULL); |
| 307 |
|
add_stat(LONG_LONG, &disk[i].total_inodes, |
| 308 |
< |
"fs", name, "total_inodes", NULL); |
| 308 |
> |
"fs", name, "total_inodes", NULL); |
| 309 |
|
add_stat(LONG_LONG, &disk[i].used_inodes, |
| 310 |
< |
"fs", name, "used_inodes", NULL); |
| 310 |
> |
"fs", name, "used_inodes", NULL); |
| 311 |
|
add_stat(LONG_LONG, &disk[i].free_inodes, |
| 312 |
< |
"fs", name, "free_inodes", NULL); |
| 312 |
> |
"fs", name, "free_inodes", NULL); |
| 313 |
|
|
| 314 |
|
free(buf); |
| 315 |
|
} |
| 321 |
|
sg_disk_io_stats *diskio; |
| 322 |
|
|
| 323 |
|
diskio = use_diffs ? sg_get_disk_io_stats_diff(&n) |
| 324 |
< |
: sg_get_disk_io_stats(&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; |
| 328 |
|
|
| 329 |
|
add_stat(STRING, &diskio[i].disk_name, |
| 330 |
< |
"disk", name, "disk_name", NULL); |
| 330 |
> |
"disk", name, "disk_name", NULL); |
| 331 |
|
add_stat(LONG_LONG, &diskio[i].read_bytes, |
| 332 |
< |
"disk", name, "read_bytes", NULL); |
| 332 |
> |
"disk", name, "read_bytes", NULL); |
| 333 |
|
add_stat(LONG_LONG, &diskio[i].write_bytes, |
| 334 |
< |
"disk", name, "write_bytes", NULL); |
| 334 |
> |
"disk", name, "write_bytes", NULL); |
| 335 |
|
add_stat(TIME_T, &diskio[i].systime, |
| 336 |
< |
"disk", name, "systime", NULL); |
| 336 |
> |
"disk", name, "systime", NULL); |
| 337 |
|
} |
| 338 |
|
} |
| 339 |
|
} |
| 357 |
|
sg_network_iface_stats *iface; |
| 358 |
|
|
| 359 |
|
io = use_diffs ? sg_get_network_io_stats_diff(&n) |
| 360 |
< |
: sg_get_network_io_stats(&n); |
| 360 |
> |
: sg_get_network_io_stats(&n); |
| 361 |
|
if (io != NULL) { |
| 362 |
|
for (i = 0; i < n; i++) { |
| 363 |
|
const char *name = io[i].interface_name; |
| 364 |
|
|
| 365 |
|
add_stat(STRING, &io[i].interface_name, |
| 366 |
< |
"net", name, "interface_name", NULL); |
| 366 |
> |
"net", name, "interface_name", NULL); |
| 367 |
|
add_stat(LONG_LONG, &io[i].tx, |
| 368 |
< |
"net", name, "tx", NULL); |
| 368 |
> |
"net", name, "tx", NULL); |
| 369 |
|
add_stat(LONG_LONG, &io[i].rx, |
| 370 |
< |
"net", name, "rx", NULL); |
| 370 |
> |
"net", name, "rx", NULL); |
| 371 |
|
add_stat(LONG_LONG, &io[i].ipackets, |
| 372 |
< |
"net", name, "ipackets", NULL); |
| 372 |
> |
"net", name, "ipackets", NULL); |
| 373 |
|
add_stat(LONG_LONG, &io[i].opackets, |
| 374 |
< |
"net", name, "opackets", NULL); |
| 374 |
> |
"net", name, "opackets", NULL); |
| 375 |
|
add_stat(LONG_LONG, &io[i].ierrors, |
| 376 |
< |
"net", name, "ierrors", NULL); |
| 376 |
> |
"net", name, "ierrors", NULL); |
| 377 |
|
add_stat(LONG_LONG, &io[i].oerrors, |
| 378 |
< |
"net", name, "oerrors", NULL); |
| 378 |
> |
"net", name, "oerrors", NULL); |
| 379 |
|
add_stat(LONG_LONG, &io[i].collisions, |
| 380 |
< |
"net", name, "collisions", NULL); |
| 380 |
> |
"net", name, "collisions", NULL); |
| 381 |
|
add_stat(TIME_T, &io[i].systime, |
| 382 |
< |
"net", name, "systime", NULL); |
| 382 |
> |
"net", name, "systime", NULL); |
| 383 |
|
} |
| 384 |
|
} |
| 385 |
|
|
| 389 |
|
const char *name = iface[i].interface_name; |
| 390 |
|
|
| 391 |
|
add_stat(INT, &iface[i].speed, |
| 392 |
< |
"net", name, "speed", NULL); |
| 392 |
> |
"net", name, "speed", NULL); |
| 393 |
|
add_stat(BOOL, &iface[i].up, |
| 394 |
< |
"net", name, "up", NULL); |
| 394 |
> |
"net", name, "up", NULL); |
| 395 |
|
add_stat(DUPLEX, &iface[i].dup, |
| 396 |
< |
"net", name, "duplex", NULL); |
| 396 |
> |
"net", name, "duplex", NULL); |
| 397 |
|
} |
| 398 |
|
} |
| 399 |
|
} |
| 444 |
|
for (i = 0; i < argc; i++) { |
| 445 |
|
for (t = &toplevels[0]; t->name != NULL; t++) { |
| 446 |
|
if (strncmp(argv[i], t->name, |
| 447 |
< |
strlen(t->name)) == 0) { |
| 447 |
> |
strlen(t->name)) == 0) { |
| 448 |
|
t->interesting = 1; |
| 449 |
|
break; |
| 450 |
|
} |
| 557 |
|
s = NULL; |
| 558 |
|
} else { |
| 559 |
|
s = (const stat *)bsearch(&key, stats, |
| 560 |
< |
num_stats, |
| 561 |
< |
sizeof *stats, |
| 562 |
< |
compare); |
| 560 |
> |
num_stats, |
| 561 |
> |
sizeof *stats, |
| 562 |
> |
compare); |
| 563 |
|
} |
| 564 |
|
|
| 565 |
|
if (s == NULL) { |
| 593 |
|
"If no STATs are given, all will be displayed. Specify 'STAT.' to display all\n" |
| 594 |
|
"statistics starting with that prefix.\n" |
| 595 |
|
"\n"); |
| 596 |
< |
printf(" -l Linux sysctl-style output (default)\n" |
| 597 |
< |
" -b BSD sysctl-style output\n" |
| 598 |
< |
" -m MRTG-compatible output\n" |
| 599 |
< |
" -u Plain output (only show values)\n" |
| 600 |
< |
" -n Display cumulative stats once (default)\n" |
| 601 |
< |
" -s Display stat differences repeatedly\n" |
| 602 |
< |
" -o Display stat differences once\n" |
| 596 |
> |
printf(" -l Linux sysctl-style output (default)\n" |
| 597 |
> |
" -b BSD sysctl-style output\n" |
| 598 |
> |
" -m MRTG-compatible output\n" |
| 599 |
> |
" -u Plain output (only show values)\n" |
| 600 |
> |
" -n Display cumulative stats once (default)\n" |
| 601 |
> |
" -s Display stat differences repeatedly\n" |
| 602 |
> |
" -o Display stat differences once\n" |
| 603 |
|
" -t DELAY When repeating, wait DELAY seconds between updates (default 1)\n" |
| 604 |
< |
" -p Display CPU usage differences as percentages rather than\n" |
| 605 |
< |
" absolute values\n" |
| 604 |
> |
" -p Display CPU usage differences as percentages rather than\n" |
| 605 |
> |
" absolute values\n" |
| 606 |
|
"\n"); |
| 607 |
|
printf("Version %s - report bugs to <%s>.\n", |
| 608 |
|
PACKAGE_VERSION, PACKAGE_BUGREPORT); |