mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-23 06:35:42 +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,5 +1,6 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "common.h"
|
||||
|
||||
#define ENTROPY_AVAIL "/proc/sys/kernel/random/entropy_avail"
|
||||
|
@ -21,16 +22,13 @@ int entropy(int argc, char **argv) {
|
|||
return 0;
|
||||
}
|
||||
if(!strcmp(argv[1], "autoconf"))
|
||||
return writeyes();
|
||||
}
|
||||
if(!(f=fopen(ENTROPY_AVAIL, "r"))) {
|
||||
fputs("cannot open " ENTROPY_AVAIL "\n", stderr);
|
||||
return 1;
|
||||
return autoconf_check_readable(ENTROPY_AVAIL);
|
||||
}
|
||||
if(!(f=fopen(ENTROPY_AVAIL, "r")))
|
||||
return fail("cannot open " ENTROPY_AVAIL);
|
||||
if(1 != fscanf(f, "%d", &entropy)) {
|
||||
fputs("cannot read from " ENTROPY_AVAIL "\n", stderr);
|
||||
fclose(f);
|
||||
return 1;
|
||||
return fail("cannot read from " ENTROPY_AVAIL);
|
||||
}
|
||||
fclose(f);
|
||||
printf("entropy.value %d\n", entropy);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue