|
|
@ -164,19 +164,37 @@ class String
|
|
|
|
#!!(self =~ /\A[-+]?[0-9]+\z/)
|
|
|
|
#!!(self =~ /\A[-+]?[0-9]+\z/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def process_tdata(host)
|
|
|
|
def process_tdata(host, simple=false)
|
|
|
|
print "Processing #{host}: "
|
|
|
|
print "Processing #{host}: "
|
|
|
|
|
|
|
|
STDOUT.flush
|
|
|
|
if system("nmap #{host} -p 22 2>&1 | grep 22 | grep open >/dev/null")
|
|
|
|
if system("nmap #{host} -p 22 2>&1 | grep 22 | grep open >/dev/null")
|
|
|
|
tdata = `ssh -oBatchMode=yes #{host} heatbot_gettemp`
|
|
|
|
tdata = `ssh -oBatchMode=yes #{host} heatbot_gettemp`
|
|
|
|
if tdata.is_integer?
|
|
|
|
if tdata.is_integer?
|
|
|
|
print tdata + "°#{@tunit}\n"
|
|
|
|
print tdata + "°#{@tunit}"
|
|
|
|
return tdata + "°#{@tunit}"
|
|
|
|
if simple #This is mostly just an Easter egg
|
|
|
|
|
|
|
|
if tdata.to_i > 75
|
|
|
|
|
|
|
|
sdata = "Hot"
|
|
|
|
|
|
|
|
elsif tdata.to_i < 50
|
|
|
|
|
|
|
|
sdata = "Cold"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
sdata = "Fair"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
print " [#{sdata}]\n"
|
|
|
|
|
|
|
|
STDOUT.flush
|
|
|
|
|
|
|
|
return sdata
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
print "\n"
|
|
|
|
|
|
|
|
STDOUT.flush
|
|
|
|
|
|
|
|
return tdata + "°#{@tunit}"
|
|
|
|
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
puts "Unexpected output from [".red.bold + host.bold + "]: ".red.bold + tdata
|
|
|
|
puts "Unexpected output from [".red.bold + host.bold + "]: ".red.bold + tdata
|
|
|
|
|
|
|
|
STDOUT.flush
|
|
|
|
return "CHECK PROBE"
|
|
|
|
return "CHECK PROBE"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
print "OFFLINE\n"
|
|
|
|
print "OFFLINE\n"
|
|
|
|
|
|
|
|
STDOUT.flush
|
|
|
|
return "OFFLINE"
|
|
|
|
return "OFFLINE"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -304,6 +322,11 @@ def handle_message(message)
|
|
|
|
process_command_check(message, command, adm)
|
|
|
|
process_command_check(message, command, adm)
|
|
|
|
when '/report', '/r'
|
|
|
|
when '/report', '/r'
|
|
|
|
process_command_report(message, command, adm)
|
|
|
|
process_command_report(message, command, adm)
|
|
|
|
|
|
|
|
#when '/simple', '/s', '/sc'
|
|
|
|
|
|
|
|
# process_command_check(message, command, adm, true)
|
|
|
|
|
|
|
|
#when '/sreport', '/simpler', '/simplereport', '/sr'
|
|
|
|
|
|
|
|
when '/simple', '/s', '/sreport', '/simpler', '/simplereport', '/sr'
|
|
|
|
|
|
|
|
process_command_report(message, command, adm, true)
|
|
|
|
when '/test'
|
|
|
|
when '/test'
|
|
|
|
process_command_test(message, command, adm)
|
|
|
|
process_command_test(message, command, adm)
|
|
|
|
when '/pp', '/debug'
|
|
|
|
when '/pp', '/debug'
|
|
|
|