From f38dd5f691218e7eb0bee85c1d6491117cba03b9 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Thu, 6 Dec 2012 10:15:19 +0000 Subject: The --monitor flag now allows a threshold to be specified, and no longer invokes mauvealert directly. Instead the exit code of the script will be used to report success/failure. --- bin/custodian-queue | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'bin') diff --git a/bin/custodian-queue b/bin/custodian-queue index 6298f88..2144b09 100755 --- a/bin/custodian-queue +++ b/bin/custodian-queue @@ -61,7 +61,7 @@ if __FILE__ == $0 then $STATS = false $help = false $manual = false - $MONITOR = false + $MONITOR = nil # # The beanstalkd server address. @@ -74,14 +74,18 @@ if __FILE__ == $0 then [ "--flush", "-f", GetoptLong::NO_ARGUMENT ], [ "--help", "-h", GetoptLong::NO_ARGUMENT ], [ "--manual", "-m", GetoptLong::NO_ARGUMENT ], - [ "--monitor", "-M", GetoptLong::NO_ARGUMENT ], + [ "--monitor", "-M", GetoptLong::OPTIONAL_ARGUMENT ], [ "--server", "-S", GetoptLong::REQUIRED_ARGUMENT ], [ "--stats", "-s", GetoptLong::NO_ARGUMENT ] ) opts.each do |opt, arg| case opt when "--monitor" then - $MONITOR = true + if ( arg ) + $MONITOR = arg.to_i + else + $MONITOR = 5000 + end when "--stats" then $STATS = true when "--flush" then @@ -136,7 +140,7 @@ if __FILE__ == $0 then # # Alerting on a queue that is too-full? # - if ( $MONITOR ) + if ( !$MONITOR.nil? ) # # Find the number of jobs @@ -144,14 +148,11 @@ if __FILE__ == $0 then stats = queue.stats() jobs = stats['current-jobs-ready'] || 0 - max = 5000 - - if ( jobs > max ) - system( "mauvesend alert.bytemark.co.uk -i custodian -r now -s \"Our queue has #{jobs} [alert-threshold is: #{max}] in it\" --detail=\"

The custodian queue doesn't seem to be emptying. Is there a bug, or do we need to add more workers? See https://wiki.bytemark.co.uk/Main/CustodianMonitoring

\" " ) + if ( jobs > $MONITOR ) + exit 1 else - system( "mauvesend alert.bytemark.co.uk -i custodian -c now -s \"Our queue has #{jobs} [alert-threshold is: #{max} in it\" --detail=\"

The custodian queue doesn't seem to be emptying. Is there a bug, or do we need to add more workers? See https://wiki.bytemark.co.uk/Main/CustodianMonitoring

\" " ) + exit 0 end - exit( 0 ) end -- cgit v1.2.1