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