sensu-plugins-network-interface 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/README.md +2 -2
- data/bin/check-network-interface.rb +42 -8
- data/lib/sensu-plugins-network-interface/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9df281e905ea0881d3db6754b1f69db6c56bbcf
|
4
|
+
data.tar.gz: 59f0f9d9f364b74e7406d6e9dddd49af101a9201
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e48cdcc0e40760c5a41859fde1638829dddf41484de2c72d6b18aa70d164c9937459b031a5553ef769e8060aca9e55da4a34c23f8aa24e72400d28a1c5672f2b
|
7
|
+
data.tar.gz: 621f255afd3d7b77ac9c08c6bbcf758d54c89d6d58a945db58e22c2a7ab9f36e1a0c0ccbba58eecf71563b2702d8e0d6522e7ddaef93622630f43ad29f186b6c
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,18 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
5
5
|
|
6
6
|
## Unreleased
|
7
7
|
|
8
|
-
## [0.
|
8
|
+
## [0.1.4] - 2015-12-29
|
9
|
+
### Added
|
10
|
+
- Added ifcfg-<interface> support
|
11
|
+
|
12
|
+
## [0.1.3] - 2015-12-28
|
13
|
+
### Added
|
14
|
+
- Requiring json globally
|
15
|
+
|
16
|
+
## [0.1.2] - 2015-12-28
|
17
|
+
### Added
|
18
|
+
- Defaulting @json_config to empty hash
|
19
|
+
|
20
|
+
## [0.1.1] - 2015-12-28
|
9
21
|
### Added
|
10
22
|
- Initial release
|
data/README.md
CHANGED
@@ -25,8 +25,8 @@ Usage: check-network-interface.rb (options)
|
|
25
25
|
-w, --warn Warn instead of throwing a critical failure
|
26
26
|
```
|
27
27
|
|
28
|
-
By default, command line option parameters are global to all interfaces. However, each interface can override the defaults in
|
29
|
-
in the same location as the plugin.
|
28
|
+
By default, command line option parameters are global to all interfaces. However, each interface can override the defaults either in their ifcfg configuration files (e.g. MTU) or
|
29
|
+
in an optional JSON configuration file which must be placed in the same location as the plugin.
|
30
30
|
|
31
31
|
JSON example:
|
32
32
|
|
@@ -16,7 +16,7 @@ class CheckNetworkInterface < Sensu::Plugin::Check::CLI
|
|
16
16
|
:proc => proc { |a| a.split(',') },
|
17
17
|
:default => []
|
18
18
|
|
19
|
-
option :
|
19
|
+
option :interface_regex,
|
20
20
|
:description => "Comma separated list of interfaces to check (regex)",
|
21
21
|
:short => "-I <INTERFACES>",
|
22
22
|
:proc => proc { |a| a.split(',') },
|
@@ -28,7 +28,7 @@ class CheckNetworkInterface < Sensu::Plugin::Check::CLI
|
|
28
28
|
:proc => proc { |a| a.split(',') },
|
29
29
|
:default => []
|
30
30
|
|
31
|
-
option :
|
31
|
+
option :ignore_interface_regex,
|
32
32
|
:description => "Comma separated list of Interfaces to ignore (regex)",
|
33
33
|
:short => "-X <INTERFACES>",
|
34
34
|
:proc => proc { |a| a.split(',') },
|
@@ -95,9 +95,9 @@ class CheckNetworkInterface < Sensu::Plugin::Check::CLI
|
|
95
95
|
next if config[:ignore_interface].include?(interface)
|
96
96
|
end
|
97
97
|
|
98
|
-
if config[:
|
98
|
+
if config[:ignore_interface_regex].size > 0
|
99
99
|
b = false
|
100
|
-
config[:
|
100
|
+
config[:ignore_interface_regex].each do |ignore_interface|
|
101
101
|
if interface =~ Regexp.new(ignore_interface)
|
102
102
|
b = true
|
103
103
|
break
|
@@ -110,10 +110,10 @@ class CheckNetworkInterface < Sensu::Plugin::Check::CLI
|
|
110
110
|
next unless config[:interface].include?(interface)
|
111
111
|
end
|
112
112
|
|
113
|
-
if config[:
|
113
|
+
if config[:interface_regex].size > 0
|
114
114
|
b = true
|
115
|
-
config[:
|
116
|
-
if interface =~ Regexp.new(
|
115
|
+
config[:interface_regex].each do |interface_regex|
|
116
|
+
if interface =~ Regexp.new(interface_regex)
|
117
117
|
b = false
|
118
118
|
break
|
119
119
|
end
|
@@ -192,11 +192,45 @@ class CheckNetworkInterface < Sensu::Plugin::Check::CLI
|
|
192
192
|
problems = 0
|
193
193
|
|
194
194
|
@interfaces.each do |interface|
|
195
|
+
ifcfg = nil
|
196
|
+
|
197
|
+
# RHEL
|
198
|
+
if File.exists?("/etc/sysconfig/network-scripts/ifcfg-#{interface}")
|
199
|
+
ifcfg = "/etc/sysconfig/network-scripts/ifcfg-#{interface}"
|
200
|
+
# SuSE
|
201
|
+
elsif File.exists?("/etc/sysconfig/network/ifcfg-#{interface}")
|
202
|
+
ifcfg = "/etc/sysconfig/network/ifcfg-#{interface}"
|
203
|
+
end
|
204
|
+
|
205
|
+
interface_config = {}
|
206
|
+
if ifcfg
|
207
|
+
File.read(ifcfg).split("\n").reject { |i| i =~ /^#/ or i =~ /^\s*$/ }.each do |i|
|
208
|
+
k, v = i.split('=')
|
209
|
+
case k
|
210
|
+
when 'mtu', 'txqueuelen'
|
211
|
+
v = v.to_i
|
212
|
+
end
|
213
|
+
interface_config[k] = v
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
195
217
|
get_info(interface).each do |metric, value|
|
196
218
|
check_name = "network-interface-#{interface}-#{metric}"
|
197
219
|
|
198
220
|
if value != nil
|
199
|
-
if
|
221
|
+
if interface_config.has_key(metric)
|
222
|
+
if value != interface_config[metric]
|
223
|
+
msg = "Expected #{metric} #{interface_config[metric]} but found #{value} on #{interface}"
|
224
|
+
if config[:warn]
|
225
|
+
send_warning(check_name, msg)
|
226
|
+
else
|
227
|
+
send_critical(check_name, msg)
|
228
|
+
end
|
229
|
+
problems += 1
|
230
|
+
else
|
231
|
+
send_ok(check_name, "Found expected #{metric} (#{interface_config[metric]}) on #{interface}")
|
232
|
+
end
|
233
|
+
elsif @json_config.has_key?('interfaces') and @json_config['interfaces'].has_key?(interface) and @json_config['interfaces'][interface].has_key?(metric)
|
200
234
|
if value != @json_config['interfaces'][interface][metric]
|
201
235
|
msg = "Expected #{metric} #{@json_config['interfaces'][interface][metric]} but found #{value} on #{interface}"
|
202
236
|
if config[:warn]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-network-interface
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matteo Cerutti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|