blob: cc7791fdca5bffd4848fc0d5426034f9134f0562 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <string.h>
#include <stdio.h>
#include "common.h"
#define ENTROPY_AVAIL "/proc/sys/kernel/random/entropy_avail"
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(ENTROPY_AVAIL, "r"))) {
fputs("cannot open " ENTROPY_AVAIL "\n", stderr);
return 1;
}
if(1 != fscanf(f, "%d", &entropy)) {
fputs("cannot read from " ENTROPY_AVAIL "\n", stderr);
fclose(f);
return 1;
}
fclose(f);
printf("entropy.value %d\n", entropy);
return 0;
}
|