network-monitor 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/README.md +64 -0
- data/Rakefile +1 -0
- data/bin/network-monitor +67 -0
- data/lib/network/monitor.rb +10 -0
- data/lib/network/monitor/interface.rb +140 -0
- data/lib/network/monitor/network_statistics.rb +200 -0
- data/lib/network/monitor/schema.rb +27 -0
- data/lib/network/monitor/version.rb +5 -0
- data/network-monitor.gemspec +27 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e9b8eec6e627acd02076903b075f725f921cfa02
|
4
|
+
data.tar.gz: 354895adda561dec4b12ae759ab823f84fc644ae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aa723ac94362ea32fe7ad661ddb6b0d72885a27661a3ab921a520dc22222b0cf2f3c86a1a4215d4291a2789d26385d8897b854e84a3160fa1c4370e53a857fd7
|
7
|
+
data.tar.gz: a912d1f63af9d9b3bbf28bec2c7d6746a7bad5145ddcebd7a38ba14bf0675d5f6cf483e0e93f688470e0453136dc3f16c44745d6c18039443e6a156755159038
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Network::Monitor
|
2
|
+
|
3
|
+
`Network::Monitor` is a simple script to measure network utilisation and error rates on SNMP capable network hardware.
|
4
|
+
|
5
|
+
**This is an old project which I've migrated to a gem. It probably needs a lot more work**
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install it yourself as:
|
10
|
+
|
11
|
+
$ gem install network-monitor
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
Create a `hosts.conf` file which includes all the IP addresses of your networking hardware, e.g. switches, wireless routers, etc:
|
16
|
+
|
17
|
+
- '10.0.0.1'
|
18
|
+
- '10.0.0.10'
|
19
|
+
- '10.0.0.30'
|
20
|
+
- '10.0.0.31'
|
21
|
+
- '10.0.0.32'
|
22
|
+
|
23
|
+
Then run `network-monitor`:
|
24
|
+
|
25
|
+
$ network-monitor --hosts path/to/hosts.conf
|
26
|
+
Utilization Report @ 2014-05-14 20:28:38 +1200
|
27
|
+
Errors Detected
|
28
|
+
10.0.0.10: 2 IN# 57 OUT# 0
|
29
|
+
10.0.0.10: 3 IN# 32 OUT# 0
|
30
|
+
10.0.0.30: 2 IN# 847 OUT# 0
|
31
|
+
10.0.0.32: 2 IN# 120 OUT# 0
|
32
|
+
17 ports not displayed.
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create new Pull Request
|
41
|
+
|
42
|
+
## License
|
43
|
+
|
44
|
+
Released under the MIT license.
|
45
|
+
|
46
|
+
Copyright, 2014, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
|
47
|
+
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
49
|
+
of this software and associated documentation files (the "Software"), to deal
|
50
|
+
in the Software without restriction, including without limitation the rights
|
51
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
52
|
+
copies of the Software, and to permit persons to whom the Software is
|
53
|
+
furnished to do so, subject to the following conditions:
|
54
|
+
|
55
|
+
The above copyright notice and this permission notice shall be included in
|
56
|
+
all copies or substantial portions of the Software.
|
57
|
+
|
58
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
59
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
60
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
61
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
62
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
63
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
64
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/network-monitor
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# monitor.rb - a simple script to monitor SNMP port status and utilization
|
3
|
+
# Copyright (c) 2008 Samuel Williams. Released under the GNU GPLv3.
|
4
|
+
|
5
|
+
require 'trollop'
|
6
|
+
|
7
|
+
require_relative '../lib/network/monitor'
|
8
|
+
|
9
|
+
opts = Trollop::options do
|
10
|
+
opt :database, "Path to sqlite3 database", :type => String, :default => "ports.sqlite3"
|
11
|
+
opt :delay, "The delay between subsequent checks", :type => Float, :default => 10.0
|
12
|
+
opt :hosts, "The hosts configuration file", :type => String, :default => "hosts.conf"
|
13
|
+
end
|
14
|
+
|
15
|
+
$hosts = YAML::load_file(opts[:hosts])
|
16
|
+
|
17
|
+
ActiveRecord::Base.establish_connection(
|
18
|
+
:adapter => 'sqlite3',
|
19
|
+
:database => opts[:database]
|
20
|
+
)
|
21
|
+
|
22
|
+
unless File.exist? opts[:database]
|
23
|
+
Network::Monitor.migrate_database!
|
24
|
+
end
|
25
|
+
|
26
|
+
# Currently unused, but gets names from hardware if possible:
|
27
|
+
def fetch_names(hosts)
|
28
|
+
puts "Fetching names..."
|
29
|
+
hosts.each do |h|
|
30
|
+
SNMP::Manager.open(:Host => h, :Version => :SNMPv1) do |manager|
|
31
|
+
response = manager.get(["sysDescr.0", "sysName.0"])
|
32
|
+
|
33
|
+
name = response.varbind_list[1].value.to_s + ' (' + response.varbind_list[0].value.to_s + ')'
|
34
|
+
|
35
|
+
$names[h] = name
|
36
|
+
end
|
37
|
+
end
|
38
|
+
puts "Done."
|
39
|
+
end
|
40
|
+
|
41
|
+
begin
|
42
|
+
while true
|
43
|
+
start_time = Time.now
|
44
|
+
|
45
|
+
$hosts.each do |host|
|
46
|
+
begin
|
47
|
+
Network::Monitor::Interface.query(host)
|
48
|
+
rescue SNMP::RequestTimeout
|
49
|
+
$stderr.puts "#{host}: Timed out when requesting SNMP data..."
|
50
|
+
rescue Errno::EHOSTUNREACH
|
51
|
+
$stderr.puts "#{host}: Error - host unreachable!"
|
52
|
+
rescue Errno::EHOSTDOWN
|
53
|
+
$stderr.puts "#{host}: Error - host unreachable!"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
puts
|
58
|
+
Network::Monitor::Interface.print_statistics($stdout)
|
59
|
+
|
60
|
+
end_time = Time.now
|
61
|
+
|
62
|
+
duration = end_time - start_time
|
63
|
+
sleep(opts[:delay] - duration) if duration < opts[:delay]
|
64
|
+
end
|
65
|
+
rescue Interrupt
|
66
|
+
puts "Exiting..."
|
67
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
|
2
|
+
require 'snmp'
|
3
|
+
require 'active_record'
|
4
|
+
|
5
|
+
require 'rainbow'
|
6
|
+
|
7
|
+
module Network
|
8
|
+
module Monitor
|
9
|
+
class Interface < ActiveRecord::Base
|
10
|
+
QueryColumns = ["ifIndex", "ifSpeed", "ifInOctets", "ifInErrors", "ifOutOctets", "ifOutErrors"]
|
11
|
+
|
12
|
+
def self.hosts
|
13
|
+
Interface.all.group("host").collect { |r| r.host }
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.query(host)
|
17
|
+
SNMP::Manager.open(:Host => host, :Version => :SNMPv1) do |manager|
|
18
|
+
manager.walk(QueryColumns) do |row|
|
19
|
+
next if row[1].value.to_i == 0 # Speed of interface is reported as 0 by some faulty equipment, ignore these ports.
|
20
|
+
|
21
|
+
record = Interface.new(:host => host)
|
22
|
+
|
23
|
+
QueryColumns.each_with_index do |c,i|
|
24
|
+
record.send("#{c}=", row[i].value.to_i)
|
25
|
+
end
|
26
|
+
|
27
|
+
record.save!
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def statistics(prev)
|
33
|
+
dt = (created_at - prev.created_at).to_f
|
34
|
+
s = {
|
35
|
+
:startTime => prev.created_at,
|
36
|
+
:endTime => created_at,
|
37
|
+
:timePeriod => created_at - prev.created_at,
|
38
|
+
:ifInOctets => ifInOctets - prev.ifInOctets,
|
39
|
+
:ifOutOctets => ifOutOctets - prev.ifOutOctets,
|
40
|
+
:ifInErrors => ifInErrors - prev.ifInErrors,
|
41
|
+
:ifOutErrors => ifOutErrors - prev.ifOutErrors
|
42
|
+
}
|
43
|
+
|
44
|
+
# Counter32 may wrap and produce strange results unless we deal with it..
|
45
|
+
[:ifInOctets, :ifOutOctets, :ifInErrors, :ifOutErrors].each do |c|
|
46
|
+
if s[c] < 0
|
47
|
+
s[c] = Counter32Max + s[c]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
s[:ifInUsage] = (s[:ifInOctets].to_f * 8.0) / (ifSpeed.to_f * dt)
|
52
|
+
s[:ifOutUsage] = (s[:ifOutOctets].to_f * 8.0) / (ifSpeed.to_f * dt)
|
53
|
+
|
54
|
+
return s
|
55
|
+
end
|
56
|
+
|
57
|
+
def speed_string
|
58
|
+
bits_to_string(ifSpeed.to_i)
|
59
|
+
end
|
60
|
+
|
61
|
+
def previous
|
62
|
+
Interface.where("host = ? and ifIndex = ? and id < ?", host, ifIndex, id).limit(1).order("created_at desc").first
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.print_statistics(out, min = 0.01)
|
66
|
+
unused_count = 0
|
67
|
+
|
68
|
+
error_interfaces = []
|
69
|
+
|
70
|
+
out.puts "Utilization Report @ #{Time.now.to_s}".center(84)
|
71
|
+
Interface.all.group("host, ifIndex").each do |iface|
|
72
|
+
r2, r1 = Interface.where("host = ? and ifIndex = ?", iface.host, iface.ifIndex).limit(2).order("created_at desc").to_a
|
73
|
+
|
74
|
+
next if r1 == nil or r2 == nil
|
75
|
+
|
76
|
+
unused = true
|
77
|
+
name = iface.host
|
78
|
+
|
79
|
+
s = r2.statistics(r1)
|
80
|
+
|
81
|
+
if s[:ifInErrors] > 0 or s[:ifOutErrors] > 0
|
82
|
+
error_interfaces << [iface, name, s]
|
83
|
+
unused = false
|
84
|
+
end
|
85
|
+
|
86
|
+
if s[:ifInUsage] > min or s[:ifOutUsage] > min
|
87
|
+
out.print "#{name.rjust(20)}: #{iface.ifIndex.to_s.rjust(4)} "
|
88
|
+
|
89
|
+
[[:ifInUsage, "IN%"], [:ifOutUsage, "OUT%"]].each do |v|
|
90
|
+
key, name = *v
|
91
|
+
|
92
|
+
out.print name.rjust(8)
|
93
|
+
out.print s[key].to_prs.rjust(8)
|
94
|
+
end
|
95
|
+
out.puts r1.speed_string.rjust(10)
|
96
|
+
|
97
|
+
unused = false
|
98
|
+
end
|
99
|
+
|
100
|
+
unused_count += 1 if unused
|
101
|
+
end
|
102
|
+
|
103
|
+
if error_interfaces.size > 0
|
104
|
+
out.puts "Errors Detected".center(84)
|
105
|
+
error_interfaces.each do |r|
|
106
|
+
iface, name, s = r
|
107
|
+
|
108
|
+
out.print "#{name.rjust(20)}: #{iface.ifIndex.to_s.rjust(4)} "
|
109
|
+
|
110
|
+
[[:ifInErrors, "IN\#"], [:ifOutErrors, "OUT\#"]].each do |v|
|
111
|
+
key, name = v
|
112
|
+
|
113
|
+
out.print name.rjust(5)
|
114
|
+
out.print s[key].to_s.rjust(8)
|
115
|
+
end
|
116
|
+
|
117
|
+
out.puts
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
out.puts "#{unused_count} ports not displayed.".center(84)
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
def bits_to_string(size)
|
127
|
+
human_size = size
|
128
|
+
levels = 0
|
129
|
+
|
130
|
+
while human_size >= 1000
|
131
|
+
human_size /= 1000.0
|
132
|
+
levels += 1
|
133
|
+
end
|
134
|
+
|
135
|
+
#maybe localize this?
|
136
|
+
sprintf("%0.1f%s", human_size, ['', 'K', 'M', 'G', 'T', 'X'].fetch(levels)) + 'b'
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,200 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
gem 'snmp'
|
4
|
+
|
5
|
+
require 'snmp'
|
6
|
+
require 'active_record'
|
7
|
+
|
8
|
+
Counter32Max = 4294967295
|
9
|
+
|
10
|
+
OPTIONS = {
|
11
|
+
:PostLog => true,
|
12
|
+
:Duration => 10,
|
13
|
+
:DatabaseFile => "ports.db",
|
14
|
+
:HostsFile => "hosts.conf"
|
15
|
+
}
|
16
|
+
|
17
|
+
class Float
|
18
|
+
def to_prs
|
19
|
+
return sprintf("%0.2f\%", self * 100.0)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def bits_to_string(size)
|
24
|
+
human_size = size
|
25
|
+
levels = 0
|
26
|
+
|
27
|
+
while human_size >= 1000
|
28
|
+
human_size /= 1000.0
|
29
|
+
levels += 1
|
30
|
+
end
|
31
|
+
|
32
|
+
#maybe localize this?
|
33
|
+
sprintf("%0.1f%s", human_size, ['', 'K', 'M', 'G', 'T', 'X'].fetch(levels)) + 'b'
|
34
|
+
end
|
35
|
+
|
36
|
+
ActiveRecord::Base.establish_connection(
|
37
|
+
:adapter => 'sqlite3',
|
38
|
+
:database => OPTIONS[:DatabaseFile]
|
39
|
+
)
|
40
|
+
|
41
|
+
unless File.exists? OPTIONS[:DatabaseFile]
|
42
|
+
puts "Building new database..."
|
43
|
+
|
44
|
+
ActiveRecord::Schema.define(:version => 1) do
|
45
|
+
create_table :interfaces do |t|
|
46
|
+
t.string :host, :null => false
|
47
|
+
t.integer :ifIndex, :null => false
|
48
|
+
|
49
|
+
t.integer :ifSpeed, :null => false
|
50
|
+
|
51
|
+
t.integer :ifInOctets, :null => false
|
52
|
+
t.integer :ifOutOctets, :null => false
|
53
|
+
|
54
|
+
t.integer :ifInErrors, :null => false
|
55
|
+
t.integer :ifOutErrors, :null => false
|
56
|
+
|
57
|
+
t.datetime :created_at
|
58
|
+
end
|
59
|
+
|
60
|
+
change_table :interfaces do |t|
|
61
|
+
t.index :host
|
62
|
+
t.index :ifIndex
|
63
|
+
# t.index :created_at
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
Counters = ["ifInOctets", "ifInErrors", :ifInUtilization, "ifOutOctets", "ifOutErrors", :ifOutUtilization]
|
69
|
+
|
70
|
+
$names = {}
|
71
|
+
|
72
|
+
def fetch_names(hosts)
|
73
|
+
puts "Fetching names..."
|
74
|
+
hosts.each do |h|
|
75
|
+
SNMP::Manager.open(:Host => h, :Version => :SNMPv1) do |manager|
|
76
|
+
response = manager.get(["sysDescr.0", "sysName.0"])
|
77
|
+
|
78
|
+
name = response.varbind_list[1].value.to_s + ' (' + response.varbind_list[0].value.to_s + ')'
|
79
|
+
|
80
|
+
$names[h] = name
|
81
|
+
end
|
82
|
+
end
|
83
|
+
puts "Done."
|
84
|
+
end
|
85
|
+
|
86
|
+
class Interface < ActiveRecord::Base
|
87
|
+
QueryColumns = ["ifIndex", "ifSpeed", "ifInOctets", "ifInErrors", "ifOutOctets", "ifOutErrors"]
|
88
|
+
|
89
|
+
def self.hosts
|
90
|
+
Interface.all.group("host").collect { |r| r.host }
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.query(host)
|
94
|
+
SNMP::Manager.open(:Host => host, :Version => :SNMPv1) do |manager|
|
95
|
+
manager.walk(QueryColumns) do |row|
|
96
|
+
next if row[1].value.to_i == 0 # Speed of interface is reported as 0 by some faulty equipment, ignore these ports.
|
97
|
+
|
98
|
+
record = Interface.new(:host => host)
|
99
|
+
|
100
|
+
QueryColumns.each_with_index do |c,i|
|
101
|
+
record.send("#{c}=", row[i].value.to_i)
|
102
|
+
end
|
103
|
+
|
104
|
+
record.save!
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def statistics(prev)
|
110
|
+
dt = (created_at - prev.created_at).to_f
|
111
|
+
s = {
|
112
|
+
:startTime => prev.created_at,
|
113
|
+
:endTime => created_at,
|
114
|
+
:timePeriod => created_at - prev.created_at,
|
115
|
+
:ifInOctets => ifInOctets - prev.ifInOctets,
|
116
|
+
:ifOutOctets => ifOutOctets - prev.ifOutOctets,
|
117
|
+
:ifInErrors => ifInErrors - prev.ifInErrors,
|
118
|
+
:ifOutErrors => ifOutErrors - prev.ifOutErrors
|
119
|
+
}
|
120
|
+
|
121
|
+
# Counter32 may wrap and produce strange results unless we deal with it..
|
122
|
+
[:ifInOctets, :ifOutOctets, :ifInErrors, :ifOutErrors].each do |c|
|
123
|
+
if s[c] < 0
|
124
|
+
s[c] = Counter32Max + s[c]
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
s[:ifInUsage] = (s[:ifInOctets].to_f * 8.0) / (ifSpeed.to_f * dt)
|
129
|
+
s[:ifOutUsage] = (s[:ifOutOctets].to_f * 8.0) / (ifSpeed.to_f * dt)
|
130
|
+
|
131
|
+
return s
|
132
|
+
end
|
133
|
+
|
134
|
+
def speed_string
|
135
|
+
bits_to_string(ifSpeed.to_i)
|
136
|
+
end
|
137
|
+
|
138
|
+
def previous
|
139
|
+
Interface.where("host = ? and ifIndex = ? and id < ?", host, ifIndex, id).limit(1).order("created_at desc").first
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.print_statistics(out, min = 0.01)
|
143
|
+
unused_count = 0
|
144
|
+
|
145
|
+
error_interfaces = []
|
146
|
+
|
147
|
+
out.puts "Utilization Report @ #{Time.now.to_s}".center(84)
|
148
|
+
Interface.all.group("host, ifIndex").each do |iface|
|
149
|
+
r2, r1 = Interface.where("host = ? and ifIndex = ?", iface.host, iface.ifIndex).limit(2).order("created_at desc").to_a
|
150
|
+
|
151
|
+
next if r1 == nil or r2 == nil
|
152
|
+
|
153
|
+
unused = true
|
154
|
+
name = $names[iface.host] || iface.host
|
155
|
+
|
156
|
+
s = r2.statistics(r1)
|
157
|
+
|
158
|
+
if s[:ifInErrors] > 0 or s[:ifOutErrors] > 0
|
159
|
+
error_interfaces << [iface, name, s]
|
160
|
+
unused = false
|
161
|
+
end
|
162
|
+
|
163
|
+
if s[:ifInUsage] > min or s[:ifOutUsage] > min
|
164
|
+
out.print "#{name.rjust(20)}: #{iface.ifIndex.to_s.rjust(4)} "
|
165
|
+
|
166
|
+
[[:ifInUsage, "IN%"], [:ifOutUsage, "OUT%"]].each do |v|
|
167
|
+
key, name = *v
|
168
|
+
|
169
|
+
out.print name.rjust(8)
|
170
|
+
out.print s[key].to_prs.rjust(8)
|
171
|
+
end
|
172
|
+
out.puts r1.speed_string.rjust(10)
|
173
|
+
|
174
|
+
unused = false
|
175
|
+
end
|
176
|
+
|
177
|
+
unused_count += 1 if unused
|
178
|
+
end
|
179
|
+
|
180
|
+
if error_interfaces.size > 0
|
181
|
+
out.puts "Errors Detected".center(84)
|
182
|
+
error_interfaces.each do |r|
|
183
|
+
iface, name, s = r
|
184
|
+
|
185
|
+
out.print "#{name.rjust(20)}: #{iface.ifIndex.to_s.rjust(4)} "
|
186
|
+
|
187
|
+
[[:ifInErrors, "IN\#"], [:ifOutErrors, "OUT\#"]].each do |v|
|
188
|
+
key, name = v
|
189
|
+
|
190
|
+
out.print name.rjust(5)
|
191
|
+
out.print s[key].to_s.rjust(8)
|
192
|
+
end
|
193
|
+
|
194
|
+
out.puts
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
out.puts "#{unused_count} ports not displayed.".center(84)
|
199
|
+
end
|
200
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
module Network
|
3
|
+
module Monitor
|
4
|
+
def self.migrate_database!
|
5
|
+
ActiveRecord::Schema.define(:version => 1) do
|
6
|
+
create_table :interfaces do |t|
|
7
|
+
t.string :host, :null => false
|
8
|
+
t.integer :ifIndex, :null => false
|
9
|
+
|
10
|
+
t.integer :ifSpeed, :null => false
|
11
|
+
|
12
|
+
t.integer :ifInOctets, :null => false
|
13
|
+
t.integer :ifOutOctets, :null => false
|
14
|
+
|
15
|
+
t.integer :ifInErrors, :null => false
|
16
|
+
t.integer :ifOutErrors, :null => false
|
17
|
+
|
18
|
+
t.datetime :created_at
|
19
|
+
|
20
|
+
t.index :host
|
21
|
+
t.index :ifIndex
|
22
|
+
t.index :created_at
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'network/monitor/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "network-monitor"
|
8
|
+
spec.version = Network::Monitor::VERSION
|
9
|
+
spec.authors = ["Samuel Williams"]
|
10
|
+
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
11
|
+
spec.summary = %q{A tool for monitoring network ports for both throughput and errors.}
|
12
|
+
spec.homepage = ""
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "snmp", "~> 1.1.1"
|
21
|
+
spec.add_dependency "trollop", "~> 2.0.0"
|
22
|
+
|
23
|
+
spec.add_dependency "rainbow", '~> 2.0.0'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: network-monitor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Samuel Williams
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: snmp
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: trollop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.0.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rainbow
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- samuel.williams@oriontransfer.co.nz
|
86
|
+
executables:
|
87
|
+
- network-monitor
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- .gitignore
|
92
|
+
- Gemfile
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- bin/network-monitor
|
96
|
+
- lib/network/monitor.rb
|
97
|
+
- lib/network/monitor/interface.rb
|
98
|
+
- lib/network/monitor/network_statistics.rb
|
99
|
+
- lib/network/monitor/schema.rb
|
100
|
+
- lib/network/monitor/version.rb
|
101
|
+
- network-monitor.gemspec
|
102
|
+
homepage: ''
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.0.3
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: A tool for monitoring network ports for both throughput and errors.
|
126
|
+
test_files: []
|