1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-24 18:07:20 +00:00

made more paths be macros

This commit is contained in:
Helmut Grohne 2009-01-23 12:56:20 +00:00 committed by Steve Schnepp
parent 339b8f43a9
commit 611bfb0580
5 changed files with 40 additions and 26 deletions

View file

@ -3,6 +3,8 @@
#include <unistd.h>
#include "common.h"
#define FS_INODE_NR "/proc/sys/fs/inode-nr"
int open_inodes(int argc, char **argv) {
FILE *f;
int nr, freen;
@ -21,19 +23,19 @@ int open_inodes(int argc, char **argv) {
return 0;
}
if(!strcmp(argv[1], "autoconf")) {
if(0 == access("/proc/sys/fs/inode-nr", R_OK))
if(0 == access(FS_INODE_NR, R_OK))
return writeyes();
else
return writeno("/proc/sys/fs/inode-nr not readable");
return writeno(FS_INODE_NR " not readable");
}
}
if(!(f=fopen("/proc/sys/fs/inode-nr", "r"))) {
fputs("cannot open /proc/sys/fs/inode-nr\n", stderr);
if(!(f=fopen(FS_INODE_NR, "r"))) {
fputs("cannot open " FS_INODE_NR "\n", stderr);
return 1;
}
if(2 != fscanf(f, "%d %d", &nr, &freen)) {
fclose(f);
fputs("cannot read from /proc/sys/fs/inode-nr\n", stderr);
fputs("cannot read from " FS_INODE_NR "\n", stderr);
return 1;
}
fclose(f);