2008-06-21 13:33:06 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include "common.h"
|
|
|
|
|
2009-01-23 13:56:20 +01:00
|
|
|
#define FS_INODE_NR "/proc/sys/fs/inode-nr"
|
|
|
|
|
2008-06-21 13:33:06 +02:00
|
|
|
int open_inodes(int argc, char **argv) {
|
|
|
|
FILE *f;
|
|
|
|
int nr, freen;
|
|
|
|
if(argc > 1) {
|
|
|
|
if(!strcmp(argv[1], "config")) {
|
|
|
|
puts("graph_title Inode table usage\n"
|
|
|
|
"graph_args --base 1000 -l 0\n"
|
|
|
|
"graph_vlabel number of open inodes\n"
|
|
|
|
"graph_category system\n"
|
|
|
|
"graph_info This graph monitors the Linux open inode table.\n"
|
|
|
|
"used.label open inodes\n"
|
|
|
|
"used.info The number of currently open inodes.\n"
|
|
|
|
"max.label inode table size\n"
|
|
|
|
"max.info The size of the system inode table. This is dynamically adjusted by the kernel.");
|
2013-01-30 12:14:28 +01:00
|
|
|
print_warncrit("used");
|
|
|
|
print_warncrit("max");
|
2008-06-21 13:33:06 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if(!strcmp(argv[1], "autoconf")) {
|
2009-01-23 13:56:20 +01:00
|
|
|
if(0 == access(FS_INODE_NR, R_OK))
|
2008-06-21 13:33:06 +02:00
|
|
|
return writeyes();
|
|
|
|
else
|
2009-01-23 13:56:20 +01:00
|
|
|
return writeno(FS_INODE_NR " not readable");
|
2008-06-21 13:33:06 +02:00
|
|
|
}
|
|
|
|
}
|
2009-01-23 13:56:20 +01:00
|
|
|
if(!(f=fopen(FS_INODE_NR, "r"))) {
|
|
|
|
fputs("cannot open " FS_INODE_NR "\n", stderr);
|
2008-06-21 13:33:06 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if(2 != fscanf(f, "%d %d", &nr, &freen)) {
|
|
|
|
fclose(f);
|
2009-01-23 13:56:20 +01:00
|
|
|
fputs("cannot read from " FS_INODE_NR "\n", stderr);
|
2008-06-21 13:33:06 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
printf("used.value %d\nmax.value %d\n", nr-freen, nr);
|
|
|
|
return 0;
|
|
|
|
}
|