From f481beb2dc4e6db37ea79f32960cbfa4a148eb90 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sat, 21 Jun 2008 11:33:06 +0000 Subject: initial tree --- entropy.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 entropy.c (limited to 'entropy.c') 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 +#include +#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; +} -- cgit v1.2.3