From 66b5173003d6c9c4bc205f71c987828ec546d239 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Sat, 10 Oct 2020 20:21:48 -0400 Subject: util: watch-entropy --- src/watch-entropy | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 src/watch-entropy 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 @@ +#!/usr/bin/perl +$SIG{INT} = sub { ++$interrupted; }; +use Time::HiRes qw(sleep); +use constant default_file => "/proc/sys/kernel/random/entropy_avail"; +use constant default_format => 'system entropy: %-5d bits'; +$|++; +my $file = shift || default_file; +my $format = $file eq default_file ? default_format : "$file: %s"; +my $sleep_time = shift || 0.2; +open ENT, "<", $file or die "$0: error opening $file: $!\n"; +my $last; while () { + chomp; + printf " $format", $_ . (" " x (length($last) - length $_)) unless $_ eq $last; + $last = $_; + last if $interrupted; + sleep $sleep_time; + seek ENT, 0, 0; +} +print "\n"; -- cgit v1.2.3