diff options
author | Helmut Grohne <helmut@subdivi.de> | 2008-06-21 11:33:06 +0000 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2008-06-21 11:33:06 +0000 |
commit | f481beb2dc4e6db37ea79f32960cbfa4a148eb90 (patch) | |
tree | 9c1f37c19b727d34fd8ab23e6e10b8866d46bb43 /entropy.c | |
download | munin-plugins-busybox-f481beb2dc4e6db37ea79f32960cbfa4a148eb90.tar.gz |
initial tree
Diffstat (limited to 'entropy.c')
-rw-r--r-- | entropy.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/entropy.c b/entropy.c new file mode 100644 index 0000000..4a5d846 --- /dev/null +++ b/entropy.c @@ -0,0 +1,35 @@ +#include <string.h> +#include <stdio.h> +#include "common.h" + +int entropy(int argc, char **argv) { + FILE *f; + int entropy; + if(argc > 1) { + if(!strcmp(argv[1], "config")) { + puts("graph_title Available entropy\n" + "graph_args --base 1000 -l 0\n" + "graph_vlabel entropy (bytes)\n" + "graph_scale no\n" + "graph_category system\n" + "graph_info This graph shows the amount of entropy available in the system.\n" + "entropy.label entropy\n" + "entropy.info The number of random bytes available. This is typically used by cryptographic applications."); + return 0; + } + if(!strcmp(argv[1], "autoconf")) + return writeyes(); + } + if(!(f=fopen("/proc/sys/kernel/random/entropy_avail", "r"))) { + fputs("cannot open /proc/sys/kernel/random/entropy_avail\n", stderr); + return 1; + } + if(1 != fscanf(f, "%d", &entropy)) { + fputs("cannot read from /proc/sys/kernel/random/entropy_avail\n", stderr); + fclose(f); + return 1; + } + fclose(f); + printf("entropy.value %d\n", entropy); + return 0; +} |