mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-09-20 01:23:36 +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
|
@ -1,3 +1,4 @@
|
|||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -10,12 +11,13 @@ int writeyes(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int writeno(const char *s) {
|
||||
if(s)
|
||||
printf("no (%s)\n", s);
|
||||
else
|
||||
puts("no");
|
||||
return 1;
|
||||
int autoconf_check_readable(const char *path) {
|
||||
if(0 == access(path, R_OK))
|
||||
return writeyes();
|
||||
else {
|
||||
printf("no (%s is not readable, errno=%d)\n", path, errno);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int getenvint(const char *name, int defvalue) {
|
||||
|
@ -64,3 +66,9 @@ void print_warncrit(const char *name) {
|
|||
print_warning(name);
|
||||
print_critical(name);
|
||||
}
|
||||
|
||||
int fail(const char *message) {
|
||||
fputs(message, stderr);
|
||||
fputc('\n', stderr);
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue