mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-28 11:54:52 +00:00
refactor code
Added common functions autoconf_check_readable and fail. Added some TODOs for later completion. Updated messages from upstream plugins.
This commit is contained in:
parent
e71641b88f
commit
bb7bf0bcd7
15 changed files with 97 additions and 166 deletions
|
@ -21,17 +21,11 @@ int forks(int argc, char **argv) {
|
|||
print_warncrit("forks");
|
||||
return 0;
|
||||
}
|
||||
if(!strcmp(argv[1], "autoconf")) {
|
||||
if(0 == access(PROC_STAT, R_OK))
|
||||
return writeyes();
|
||||
else
|
||||
return writeno(PROC_STAT " not readable");
|
||||
}
|
||||
}
|
||||
if(!(f=fopen(PROC_STAT, "r"))) {
|
||||
fputs("cannot open " PROC_STAT "\n", stderr);
|
||||
return 1;
|
||||
if(!strcmp(argv[1], "autoconf"))
|
||||
return autoconf_check_readable(PROC_STAT);
|
||||
}
|
||||
if(!(f=fopen(PROC_STAT, "r")))
|
||||
return fail("cannot open " PROC_STAT);
|
||||
while(fgets(buff, 256, f)) {
|
||||
if(!strncmp(buff, "processes ", 10)) {
|
||||
fclose(f);
|
||||
|
@ -40,6 +34,5 @@ int forks(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
fclose(f);
|
||||
fputs("no processes line found in " PROC_STAT "\n", stderr);
|
||||
return 1;
|
||||
return fail("no processes line found in " PROC_STAT);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue