summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2020-10-10 20:21:48 -0400
committerAndrew Cady <d@jerkface.net>2020-10-10 20:21:48 -0400
commit66b5173003d6c9c4bc205f71c987828ec546d239 (patch)
tree5d9c007d1b2f3c88fd877a47a71ddd6ff2ea0763
parent7e58194eb06762d7e6a99558dfe90e6485da89aa (diff)
util: watch-entropy
-rwxr-xr-xsrc/watch-entropy19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/watch-entropy b/src/watch-entropy
new file mode 100755
index 0000000..e0f3261
--- /dev/null
+++ b/src/watch-entropy
@@ -0,0 +1,19 @@
1#!/usr/bin/perl
2$SIG{INT} = sub { ++$interrupted; };
3use Time::HiRes qw(sleep);
4use constant default_file => "/proc/sys/kernel/random/entropy_avail";
5use constant default_format => 'system entropy: %-5d bits';
6$|++;
7my $file = shift || default_file;
8my $format = $file eq default_file ? default_format : "$file: %s";
9my $sleep_time = shift || 0.2;
10open ENT, "<", $file or die "$0: error opening $file: $!\n";
11my $last; while (<ENT>) {
12 chomp;
13 printf " $format", $_ . (" " x (length($last) - length $_)) unless $_ eq $last;
14 $last = $_;
15 last if $interrupted;
16 sleep $sleep_time;
17 seek ENT, 0, 0;
18}
19print "\n";