Class: Jah::Netstat
- Inherits:
-
Object
- Object
- Jah::Netstat
- Includes:
- Command
- Defined in:
- lib/jah/commands/netstat.rb
Constant Summary
Constants included from Command
Class Method Summary collapse
Methods included from Command
Class Method Details
.connections ⇒ Object
20 21 22 23 24 25 |
# File 'lib/jah/commands/netstat.rb', line 20 def connections `netstat -ntu | grep ESTAB | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr`.to_a.map do |l| count, ip = l.split [ip, count] end end |
.count ⇒ Object
16 17 18 |
# File 'lib/jah/commands/netstat.rb', line 16 def count `netstat -n | grep -i established | wc -l`.to_i end |
.net ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/jah/commands/netstat.rb', line 8 def net out = "" connections.each do |c| out << "#{c[0]} => #{c[1]} connections\n" end out << "Total: #{Net.count}" end |