Skip to content

Instantly share code, notes, and snippets.

@mmb
Created May 21, 2009 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmb/115799 to your computer and use it in GitHub Desktop.
Save mmb/115799 to your computer and use it in GitHub Desktop.
get number of active and allowed connections from a DD-WRT router
#!/usr/bin/ruby
# get number of active and allowed connections from a DD-WRT router
require 'rubygems'
require 'net/ssh'
Net::SSH.start('192.168.0.1', 'root') do |ssh|
max = ssh.exec!('cat /proc/sys/net/ipv4/netfilter/ip_conntrack_max').strip
tcp = ssh.exec!('grep -c ^tcp /proc/net/ip_conntrack').strip
udp = ssh.exec!('grep -c ^udp /proc/net/ip_conntrack').strip
puts "#{udp}u+#{tcp}t/#{max}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment