summaryrefslogtreecommitdiff
path: root/slstatus.c
diff options
context:
space:
mode:
Diffstat (limited to 'slstatus.c')
-rw-r--r--slstatus.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/slstatus.c b/slstatus.c
index ee6b160..3574468 100644
--- a/slstatus.c
+++ b/slstatus.c
@@ -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)