Sha256: 66afd99857be8b2205cc71f6756ab66b8b19ced0ae5693c1bb2c982eef90608b

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'optparse'

$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
require 'zombie_passenger_killer'

unless system("which timeout > /dev/null")
  warn "Please install timeout commandline tool e.g. via apt-get install timeout / apt-get install coreutils"
end

options = {}
OptionParser.new do |opts|
  opts.banner = <<BANNER
Guaranteed zombie passengers death

Usage:
    zombie_passenger_killer [options]

Options:
BANNER
  opts.on("-m", "--max [SIZE]", Integer, "Max high CPU entries in history before killing") {|i| options[:max]=i }
  opts.on("--history [SIZE]", Integer, "History size") {|i| options[:history]=i }
  opts.on("-c", "--cpu [PERCENT]", Integer, "Mark as high CPU when above PERCENT") {|i| options[:cpu]=i }
  opts.on("-g", "--grace [SECONDS]", Integer, "Wait SECONDS before hard-killing (-9) a process") {|i| options[:grace]=i }
  opts.on("-i", "--interval [SECONDS]", Integer, "Check every SECONDS") {|i| options[:interval]=i }
  opts.on("-p", "--pattern [PATTERN]", String, "Find processes with this pattern") {|i| options[:pattern]=i }
  opts.on("-h", "--help","Show this.") { puts opts; exit }
  opts.on('-v', '--version','Show Version'){ puts Smusher::VERSION; exit}
end.parse!

$stdout.sync = true
puts "Started at #{Time.now}"

killer = ZombiePassengerKiller.new(options)

loop do
  killer.hunt_zombies
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zombie_passenger_killer-0.1.0 bin/zombie_passenger_killer