dsa-check-statusfile: port to python3
[mirror/dsa-nagios.git] / dsa-nagios-checks / checks / dsa-check-entropy
index 42bb5fd..ddf1d92 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 # Copyright 2011 Peter Palfrader
+# Copyright 2014 Hendrik Koehler
 #
 # Permission is hereby granted, free of charge, to any person obtaining
 # a copy of this software and associated documentation files (the
@@ -37,7 +38,7 @@ parser.add_option("-s", "--sleep", dest="sleep", metavar="MSECS",
   help="Amount of time to wait between reads [250msec].")
 parser.add_option("-w", "--watermark", dest="watermark", metavar="BYTES",
   type="int", default=800,
-  help="Minimum number of expected bytes in the entropy pool.")
+  help="Minimum number of expected bytes in the entropy pool [800].")
 (options, args) = parser.parse_args()
 
 if len(args) != 0:
@@ -64,16 +65,16 @@ while tries <= options.retries:
 
     if avail >= options.watermark:
         if tries > 0:
-            print "OK: %d bytes in the pool after %d attempts."%(avail, tries)
+            print "OK: %d bytes in the pool after %d attempts.|entropy=%d bytes"%(avail, tries, avail)
         else:
-            print "OK: %d bytes in the pool."%(avail)
+            print "OK: %d bytes in the pool.|entropy=%d bytes"%(avail, avail)
         sys.exit(0)
 
     values.append(avail)
     time.sleep(1.0 * options.sleep / 1000)
     tries += 1
 
-print "WARNING: Too little entropy in the pool (min: %d, max: %d in %d reads)"%(min(values), max(values), tries)
+print "WARNING: Too little entropy in the pool (min: %d, max: %d in %d reads)|entropy=%d bytes"%(min(values), max(values), tries-1, avail)
 sys.exit(1)
 
 # vim:set et: