root / tools / munin-plugins-busybox / open_inodes.c @ cbfa6b45
Historique | Voir | Annoter | Télécharger (1,19 ko)
| 1 |
#include <string.h> |
|---|---|
| 2 |
#include <stdio.h> |
| 3 |
#include <unistd.h> |
| 4 |
#include "common.h" |
| 5 |
|
| 6 |
#define FS_INODE_NR "/proc/sys/fs/inode-nr" |
| 7 |
|
| 8 |
int open_inodes(int argc, char **argv) { |
| 9 |
FILE *f; |
| 10 |
int nr, freen;
|
| 11 |
if(argc > 1) { |
| 12 |
if(!strcmp(argv[1], "config")) { |
| 13 |
puts("graph_title Inode table usage\n"
|
| 14 |
"graph_args --base 1000 -l 0\n"
|
| 15 |
"graph_vlabel number of open inodes\n"
|
| 16 |
"graph_category system\n"
|
| 17 |
"graph_info This graph monitors the Linux open inode table.\n"
|
| 18 |
"used.label open inodes\n"
|
| 19 |
"used.info The number of currently open inodes.\n"
|
| 20 |
"max.label inode table size\n"
|
| 21 |
"max.info The size of the system inode table. This is dynamically adjusted by the kernel.");
|
| 22 |
print_warncrit("used");
|
| 23 |
print_warncrit("max");
|
| 24 |
return 0; |
| 25 |
} |
| 26 |
if(!strcmp(argv[1], "autoconf")) { |
| 27 |
if(0 == access(FS_INODE_NR, R_OK)) |
| 28 |
return writeyes();
|
| 29 |
else
|
| 30 |
return writeno(FS_INODE_NR " not readable"); |
| 31 |
} |
| 32 |
} |
| 33 |
if(!(f=fopen(FS_INODE_NR, "r"))) { |
| 34 |
fputs("cannot open " FS_INODE_NR "\n", stderr); |
| 35 |
return 1; |
| 36 |
} |
| 37 |
if(2 != fscanf(f, "%d %d", &nr, &freen)) { |
| 38 |
fclose(f); |
| 39 |
fputs("cannot read from " FS_INODE_NR "\n", stderr); |
| 40 |
return 1; |
| 41 |
} |
| 42 |
fclose(f); |
| 43 |
printf("used.value %d\nmax.value %d\n", nr-freen, nr);
|
| 44 |
return 0; |
| 45 |
} |
