diff --git a/tools/munin-plugins-busybox/common.h b/tools/munin-plugins-busybox/common.h index 67a5bebc..8db440a9 100644 --- a/tools/munin-plugins-busybox/common.h +++ b/tools/munin-plugins-busybox/common.h @@ -1,6 +1,8 @@ #ifndef COMMON_H #define COMMON_H +#define PROC_STAT "/proc/stat" + int writeyes(void); int writeno(const char *); diff --git a/tools/munin-plugins-busybox/cpu.c b/tools/munin-plugins-busybox/cpu.c index 171a3d3c..9f3483f8 100644 --- a/tools/munin-plugins-busybox/cpu.c +++ b/tools/munin-plugins-busybox/cpu.c @@ -19,8 +19,8 @@ int cpu(int argc, char **argv) { if(s && !strcmp(s, "yes")) scaleto100=1; - if(!(f=fopen("/proc/stat", "r"))) { - fputs("cannot open /proc/stat\n", stderr); + if(!(f=fopen(PROC_STAT, "r"))) { + fputs("cannot open " PROC_STAT "\n", stderr); return 1; } while(fgets(buff, 256, f)) { @@ -37,7 +37,7 @@ int cpu(int argc, char **argv) { fclose(f); if(ncpu < 1 || extinfo < 4) { - fputs("cannot parse /proc/stat\n", stderr); + fputs("cannot parse " PROC_STAT "\n", stderr); return 1; } @@ -114,14 +114,14 @@ int cpu(int argc, char **argv) { return 0; } if(!strcmp(argv[1], "autoconf")) { - if(0 == access("/proc/stat", R_OK)) + if(0 == access(PROC_STAT, R_OK)) return writeyes(); else - return writeno("/proc/stat not readable"); + return writeno(PROC_STAT " not readable"); } } - if(!(f=fopen("/proc/stat", "r"))) { - fputs("cannot open /proc/stat\n", stderr); + if(!(f=fopen(PROC_STAT, "r"))) { + fputs("cannot open " PROC_STAT "\n", stderr); return 1; } while(fgets(buff, 256, f)) { @@ -152,6 +152,6 @@ int cpu(int argc, char **argv) { } } fclose(f); - fputs("no cpu line found in /proc/stat\n", stderr); + fputs("no cpu line found in " PROC_STAT "\n", stderr); return 1; } diff --git a/tools/munin-plugins-busybox/forks.c b/tools/munin-plugins-busybox/forks.c index fa4dadb4..3d4a198e 100644 --- a/tools/munin-plugins-busybox/forks.c +++ b/tools/munin-plugins-busybox/forks.c @@ -21,14 +21,14 @@ int forks(int argc, char **argv) { return 0; } if(!strcmp(argv[1], "autoconf")) { - if(0 == access("/proc/stat", R_OK)) + if(0 == access(PROC_STAT, R_OK)) return writeyes(); else - return writeno("/proc/stat not readable"); + return writeno(PROC_STAT " not readable"); } } - if(!(f=fopen("/proc/stat", "r"))) { - fputs("cannot open /proc/stat\n", stderr); + if(!(f=fopen(PROC_STAT, "r"))) { + fputs("cannot open " PROC_STAT "\n", stderr); return 1; } while(fgets(buff, 256, f)) { @@ -39,6 +39,6 @@ int forks(int argc, char **argv) { } } fclose(f); - fputs("no processes line found in /proc/stat\n", stderr); + fputs("no processes line found in " PROC_STAT "\n", stderr); return 1; } diff --git a/tools/munin-plugins-busybox/interrupts.c b/tools/munin-plugins-busybox/interrupts.c index 2755ccf6..8c800c61 100644 --- a/tools/munin-plugins-busybox/interrupts.c +++ b/tools/munin-plugins-busybox/interrupts.c @@ -26,14 +26,14 @@ int interrupts(int argc, char **argv) { return 0; } if(!strcmp(argv[1], "autoconf")) { - if(0 == access("/proc/stat", R_OK)) + if(0 == access(PROC_STAT, R_OK)) return writeyes(); else - return writeno("/proc/stat not readable"); + return writeno(PROC_STAT " not readable"); } } - if(!(f=fopen("/proc/stat", "r"))) { - fputs("cannot open /proc/stat\n", stderr); + if(!(f=fopen(PROC_STAT, "r"))) { + fputs("cannot open " PROC_STAT "\n", stderr); return 1; } while(fgets(buff, 256, f)) { diff --git a/tools/munin-plugins-busybox/swap.c b/tools/munin-plugins-busybox/swap.c index 1a270fe8..3decfbb0 100644 --- a/tools/munin-plugins-busybox/swap.c +++ b/tools/munin-plugins-busybox/swap.c @@ -27,10 +27,10 @@ int swap(int argc, char **argv) { return 0; } if(!strcmp(argv[1], "autoconf")) { - if(0 == access("/proc/stat", R_OK)) + if(0 == access(PROC_STAT, R_OK)) return writeyes(); else - return writeno("/proc/stat not readable"); + return writeno(PROC_STAT " not readable"); } } if(!access("/proc/vmstat", F_OK)) { @@ -56,15 +56,16 @@ int swap(int argc, char **argv) { } return 0; } else { - if(!(f=fopen("/proc/stat", "r"))) { - fputs("cannot open /proc/stat\n", stderr); + if(!(f=fopen(PROC_STAT, "r"))) { + fputs("cannot open " PROC_STAT "\n", stderr); return 1; } while(fgets(buff, 256, f)) { if(!strncmp(buff, "swap ", 5)) { fclose(f); if(2 != sscanf(buff+5, "%d %d", &in, &out)) { - fputs("bad data on /proc/stat\n", stderr); + fputs("bad data on " PROC_STAT "\n", + stderr); return 1; } printf("swap_in.value %d\nswap_out.value %d\n", in, out); @@ -72,7 +73,7 @@ int swap(int argc, char **argv) { } } fclose(f); - fputs("no swap line found in /proc/stat\n", stderr); + fputs("no swap line found in " PROC_STAT "\n", stderr); return 1; } }