Closed rguaitanele closed 5 years ago
Sorry, here it is :
=begin Script: as.name Version: 1.0 Author: Jean-Jacques Martrès (jjmartres |at| gmail |dot| com) Description: Query whois.cymru.com server to get AS Name associated to the IP address License: GPL2
This script is intended for use with Zabbix > 2.0
USAGE: as a script: as.name [options] as an item: as.name["-p","BGP_PEER_IP_ADDRESS"]
OPTIONS -h, --help Display this help message -p, --peer BGP_PEER_IP_ADDRESS BGP peer IP address discovered by Zabbix =end require 'rubygems' require 'optparse'
version="0.0.1"
OPTIONS = {} mandatory_options=[:peer] optparse = OptionParser.new do |opts| opts.banner = "Usage: #{$0} [options]" opts.separator "" opts.separator "Options" opts.on("-h", "--help", "Display this help message") do puts opts exit(-1) end opts.on('-p', '--peer BGP_PEER_IP_ADDRESS', String, 'BGP peer IP address discovered by Zabbix') { |v| OPTIONS[:peer] = v } opts.separator "" end
if ARGV.empty? puts optparse exit(-1) end
begin optparse.parse!(ARGV) missing = mandatory_options.select{|p| OPTIONS[p].nil? } if not missing.empty? puts "Missing options: #{missing.join(', ')}" puts optparse exit(-1) end rescue OptionParser::ParseError,OptionParser::InvalidArgument,OptionParser::InvalidOption puts $!.to_s exit(-1) end
t = Thread.new { whois -h whois.cymru.com " -f #{OPTIONS[:peer]}"
}
whois = t.value.chomp.gsub(/\s+|\s+/,"|").split("|")
if whois[2].match("NA") puts "N/A" else puts whois[2] end
exit(-1)
Em 11 de mai de 2018, à(s) 11:52, rguaitanele notifications@github.com escreveu:
externalscripts/as.name not found.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/phanthom2o4o/Huawei_Zabbix_Templates/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5jh3AP_TQuLmw6aDG10y-X3W7ldvThks5txaXFgaJpZM4T7lpH.
externalscripts/as.name not found.