root / tools / munin-plugins-busybox / entropy.c @ cbfa6b45
Historique | Voir | Annoter | Télécharger (1 ko)
| 1 |
#include <string.h> |
|---|---|
| 2 |
#include <stdio.h> |
| 3 |
#include "common.h" |
| 4 |
|
| 5 |
#define ENTROPY_AVAIL "/proc/sys/kernel/random/entropy_avail" |
| 6 |
|
| 7 |
int entropy(int argc, char **argv) { |
| 8 |
FILE *f; |
| 9 |
int entropy;
|
| 10 |
if(argc > 1) { |
| 11 |
if(!strcmp(argv[1], "config")) { |
| 12 |
puts("graph_title Available entropy\n"
|
| 13 |
"graph_args --base 1000 -l 0\n"
|
| 14 |
"graph_vlabel entropy (bytes)\n"
|
| 15 |
"graph_scale no\n"
|
| 16 |
"graph_category system\n"
|
| 17 |
"graph_info This graph shows the amount of entropy available in the system.\n"
|
| 18 |
"entropy.label entropy\n"
|
| 19 |
"entropy.info The number of random bytes available. This is typically used by cryptographic applications.");
|
| 20 |
print_warncrit("entropy");
|
| 21 |
return 0; |
| 22 |
} |
| 23 |
if(!strcmp(argv[1], "autoconf")) |
| 24 |
return writeyes();
|
| 25 |
} |
| 26 |
if(!(f=fopen(ENTROPY_AVAIL, "r"))) { |
| 27 |
fputs("cannot open " ENTROPY_AVAIL "\n", stderr); |
| 28 |
return 1; |
| 29 |
} |
| 30 |
if(1 != fscanf(f, "%d", &entropy)) { |
| 31 |
fputs("cannot read from " ENTROPY_AVAIL "\n", stderr); |
| 32 |
fclose(f); |
| 33 |
return 1; |
| 34 |
} |
| 35 |
fclose(f); |
| 36 |
printf("entropy.value %d\n", entropy);
|
| 37 |
return 0; |
| 38 |
} |
