diff options
author | Aaron Marcher <info@nulltime.net> | 2016-06-03 13:04:15 +0200 |
---|---|---|
committer | Aaron Marcher (drkhsh) <info@nulltime.net> | 2016-06-03 13:04:15 +0200 |
commit | 5a943fa59cab43f4a2cf6c133c4ef5676d6358b1 (patch) | |
tree | 82a8f19501b8be2a862bfb7b1c5be24b9d976546 /slstatus.c | |
parent | bf2cdd102e33272cbac7e886fdc8e4999002e1e4 (diff) | |
download | slstatus-5a943fa59cab43f4a2cf6c133c4ef5676d6358b1.tar.gz |
added entropy
Diffstat (limited to 'slstatus.c')
-rw-r--r-- | slstatus.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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) |