added entropy

This commit is contained in:
Aaron Marcher
2016-06-03 13:04:15 +02:00
committed by Aaron Marcher (drkhsh)
parent bf2cdd102e
commit 5a943fa59c
3 changed files with 26 additions and 0 deletions

View File

@ -181,6 +181,29 @@ disk_perc(const char *mountpoint)
return smprintf("%d%%", perc);
}
/* entropy available */
char *
entropy(const char *null)
{
int entropy = 0;
FILE *fp;
/* open entropy file */
if (!(fp = fopen("/proc/sys/kernel/random/entropy_avail", "r"))) {
fprintf(stderr, "Could not open entropy file.\n");
return smprintf("n/a");
}
/* extract entropy */
fscanf(fp, "%d", &entropy);
/* close entropy file */
fclose(fp);
/* return entropy */
return smprintf("%d", entropy);
}
/* ram percentage */
char *
ram_perc(const char *null)