Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- #TH v0.1 10/09/2014
- #check nf_contrack_table usage script
- require 'rubygems'
- require 'snmp'
- class SNMP_check
- attr_reader :responce
- def initialize (host, community, crit, warn)
- @host = host
- @community = community
- @crit = crit.to_f
- @warn = warn.to_f
- end
- def poll
- begin
- SNMP::Manager.open(:host => @host, :Community => @community) do |pollServer|
- (nf_max, nf_count) = \
- pollServer.get_value ["1.3.6.1.4.1.8072.1.3.2.3.1.1.16.110.102.95.99.111.110.110.116.114.97.99.107.95.109.97.120",
- "1.3.6.1.4.1.8072.1.3.2.3.1.1.18.110.102.95.99.111.110.110.116.114.97.99.107.95.99.111.117.110.116"]
- @responce = (nf_count.to_f/nf_max.to_f) * 100
- end
- rescue
- print("SNMP problem. No data received from host.\n")
- exit 3
- end
- end
- def check
- if @responce > @crit
- printf("Contrack Critical - " "%.02f", "#@responce")
- print "%\n"
- exit 2
- elsif @responce < @crit and @responce > @warn
- printf("Contrack Warning - " "%.02f", "#@responce")
- print "%\n"
- exit 1
- else
- printf("Contrack Ok - " "%.02f", "#@responce")
- print "%\n"
- exit 0
- end
- end
- end
- host = ARGV[0]
- community = ARGV[1]
- warn = ARGV[2].to_i
- crit = ARGV[3].to_i
- if ARGV.length < 1
- puts "Usage: host community warn critical"
- elsif crit <= warn
- puts "Warning must be less than critical"
- exit 3
- elsif
- crit > 100
- puts "Critical should be less than 100%"
- else
- server = SNMP_check.new(host, community, crit, warn)
- server.poll
- server.check
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement