sensu-plugins-network-interface 0.1.8 → 0.1.9
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +8 -4
- data/bin/check-network-interface.rb +42 -38
- 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: 6d9e84f5b75b04e750ead82a8a08c0c3cdfe0ab8
|
4
|
+
data.tar.gz: af09ac9b9ca0d549dbb3268c108bda97e9a2921d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe09233e33eee94126c28325a62c48826d9b646a8a837a48ded12a0bd60209563dff0168c2b068b17bb7ac4223a87fe0c082d502dac8b7ed56c14fdb98a3df68
|
7
|
+
data.tar.gz: 16e9b95bfcda64244c7b83784214c92bb90c4200188c049b4cbea295af59cf9c316a04dbde045609f9b935dd8d79e362e8df8fdc407bf325682cfe76dc46b9cc
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,10 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
5
5
|
|
6
6
|
## Unreleased
|
7
7
|
|
8
|
+
## [0.1.9] - 2016-01-07
|
9
|
+
### Added
|
10
|
+
- Also monitor interfaces that are configured via the ifcfg config files.
|
11
|
+
|
8
12
|
## [0.1.8] - 2015-12-29
|
9
13
|
### Added
|
10
14
|
- Adding long options
|
data/README.md
CHANGED
@@ -13,18 +13,22 @@ The plugin accepts command line options to specify things like expected mtu, spe
|
|
13
13
|
Usage: check-network-interface.rb (options)
|
14
14
|
--carrier <STATE> Indicates the current physical link state of the interface (default: up)
|
15
15
|
-c, --config <PATH> Optional configuration file (default: ./network-interface.json)
|
16
|
+
--dryrun Do not send events to sensu client socket
|
16
17
|
-d, --duplex <STATE> Check interface duplex settings (default: full)
|
17
|
-
-x <INTERFACES
|
18
|
-
|
18
|
+
-x <INTERFACES>, Comma separated list of interfaces to ignore
|
19
|
+
--ignore-interface
|
20
|
+
-i, --interface <INTERFACES> Comma separated list of interfaces to check (default: ALL)
|
19
21
|
-m, --mtu <MTU> Message Transfer Unit
|
20
22
|
--operstate <STATE> Indicates the interface RFC2863 operational state (default: up)
|
21
|
-
-X <INTERFACES> Comma separated list of Interfaces to ignore (regex)
|
22
|
-
-I <INTERFACES> Comma separated list of interfaces to check (regex)
|
23
23
|
-s, --speed <SPEED> Expected speed in Mb/s
|
24
24
|
-t, --txqueuelen <TXQUEUELEN> Transmit Queue Length
|
25
25
|
-w, --warn Warn instead of throwing a critical failure
|
26
26
|
```
|
27
27
|
|
28
|
+
The --interface and --ignore-interface parameters can also accept regular expressions.
|
29
|
+
|
30
|
+
When no interface is specified, the plugin will monitor all interfaces that are found under /sys/class/net as well as those set up under /etc/sysconfig/network-scripts/ifcfg-\*.
|
31
|
+
|
28
32
|
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
33
|
in an optional JSON configuration file which must be placed in the same location as the plugin.
|
30
34
|
|
@@ -17,13 +17,6 @@ class CheckNetworkInterface < Sensu::Plugin::Check::CLI
|
|
17
17
|
:proc => proc { |a| a.split(',') },
|
18
18
|
:default => []
|
19
19
|
|
20
|
-
option :interface_regex,
|
21
|
-
:description => "Comma separated list of interfaces to check (regex)",
|
22
|
-
:short => "-I <INTERFACES>",
|
23
|
-
:long => "--interface-regex <INTERFACES>",
|
24
|
-
:proc => proc { |a| a.split(',') },
|
25
|
-
:default => []
|
26
|
-
|
27
20
|
option :ignore_interface,
|
28
21
|
:description => "Comma separated list of interfaces to ignore",
|
29
22
|
:short => "-x <INTERFACES>",
|
@@ -31,13 +24,6 @@ class CheckNetworkInterface < Sensu::Plugin::Check::CLI
|
|
31
24
|
:proc => proc { |a| a.split(',') },
|
32
25
|
:default => []
|
33
26
|
|
34
|
-
option :ignore_interface_regex,
|
35
|
-
:description => "Comma separated list of Interfaces to ignore (regex)",
|
36
|
-
:short => "-X <INTERFACES>",
|
37
|
-
:long => "--ignore-interface-regex <INTERFACES>",
|
38
|
-
:proc => proc { |a| a.split(',') },
|
39
|
-
:default => []
|
40
|
-
|
41
27
|
option :config_file,
|
42
28
|
:description => "Optional configuration file (default: #{File.dirname(__FILE__)}/network-interface.json)",
|
43
29
|
:short => "-c <PATH>",
|
@@ -88,21 +74,24 @@ class CheckNetworkInterface < Sensu::Plugin::Check::CLI
|
|
88
74
|
:description => "Warn instead of throwing a critical failure",
|
89
75
|
:short => "-w",
|
90
76
|
:long => "--warn",
|
91
|
-
:boolean =>
|
77
|
+
:boolean => true,
|
78
|
+
:default => false
|
79
|
+
|
80
|
+
option :dryrun,
|
81
|
+
:description => "Do not send events to sensu client socket",
|
82
|
+
:long => "--dryrun",
|
83
|
+
:boolean => true,
|
84
|
+
:default => false
|
92
85
|
|
93
86
|
def initialize()
|
94
87
|
super
|
95
88
|
|
96
89
|
@interfaces = []
|
97
|
-
find_interfaces().each do |
|
90
|
+
find_interfaces().each do |intf|
|
98
91
|
if config[:ignore_interface].size > 0
|
99
|
-
next if config[:ignore_interface].include?(interface)
|
100
|
-
end
|
101
|
-
|
102
|
-
if config[:ignore_interface_regex].size > 0
|
103
92
|
b = false
|
104
|
-
config[:
|
105
|
-
if
|
93
|
+
config[:ignore_interface].each do |ignore_interface|
|
94
|
+
if intf.match(ignore_interface)
|
106
95
|
b = true
|
107
96
|
break
|
108
97
|
end
|
@@ -111,13 +100,9 @@ class CheckNetworkInterface < Sensu::Plugin::Check::CLI
|
|
111
100
|
end
|
112
101
|
|
113
102
|
if config[:interface].size > 0
|
114
|
-
next unless config[:interface].include?(interface)
|
115
|
-
end
|
116
|
-
|
117
|
-
if config[:interface_regex].size > 0
|
118
103
|
b = true
|
119
|
-
config[:
|
120
|
-
if
|
104
|
+
config[:interface].each do |interface|
|
105
|
+
if intf.match(interface)
|
121
106
|
b = false
|
122
107
|
break
|
123
108
|
end
|
@@ -125,18 +110,31 @@ class CheckNetworkInterface < Sensu::Plugin::Check::CLI
|
|
125
110
|
next if b
|
126
111
|
end
|
127
112
|
|
128
|
-
@interfaces <<
|
113
|
+
@interfaces << intf
|
129
114
|
end
|
130
115
|
|
131
116
|
@json_config = {}
|
132
117
|
if File.exists?(config[:config_file])
|
133
118
|
@json_config = JSON.parse(File.read(config[:config_file]))
|
134
119
|
end
|
120
|
+
|
121
|
+
@ifcfg_dir = nil
|
122
|
+
# RHEL
|
123
|
+
if File.directory?("/etc/sysconfig/network-scripts")
|
124
|
+
@ifcfg_dir = "/etc/sysconfig/network-scripts"
|
125
|
+
# SuSE
|
126
|
+
elsif File.directory?("/etc/sysconfig/network")
|
127
|
+
@ifcfg_dir = "/etc/sysconfig/network"
|
128
|
+
end
|
135
129
|
end
|
136
130
|
|
137
131
|
def send_client_socket(data)
|
138
|
-
|
139
|
-
|
132
|
+
if config[:dryrun]
|
133
|
+
puts data.inspect
|
134
|
+
else
|
135
|
+
sock = UDPSocket.new
|
136
|
+
sock.send(data + "\n", 0, "127.0.0.1", 3030)
|
137
|
+
end
|
140
138
|
end
|
141
139
|
|
142
140
|
def send_ok(check_name, msg)
|
@@ -160,7 +158,15 @@ class CheckNetworkInterface < Sensu::Plugin::Check::CLI
|
|
160
158
|
end
|
161
159
|
|
162
160
|
def find_interfaces()
|
163
|
-
Dir["/sys/class/net/*"].select { |i| File.symlink?(i) }.map { |i| File.basename(i) }.reject { |i| i =~ /^lo/ or i =~ /^dummy/ }
|
161
|
+
interfaces = Dir["/sys/class/net/*"].select { |i| File.symlink?(i) }.map { |i| File.basename(i) }.reject { |i| i =~ /^lo/ or i =~ /^dummy/ }
|
162
|
+
|
163
|
+
if @ifcfg_dir
|
164
|
+
Dir[@ifcfg_dir + "/ifcfg-*"].map { |i| File.basename(i) }.reject { |i| i =~ /-lo.*$/ or i =~ /^-range.*$/ }.each do |cfg|
|
165
|
+
content = File.read(@ifcfg_dir + "/" + cfg)
|
166
|
+
device = content[/^DEVICE=(.*)/, 1]
|
167
|
+
interfaces << device unless interfaces.include?(device)
|
168
|
+
end
|
169
|
+
end
|
164
170
|
end
|
165
171
|
|
166
172
|
def get_info(interface)
|
@@ -202,12 +208,10 @@ class CheckNetworkInterface < Sensu::Plugin::Check::CLI
|
|
202
208
|
@interfaces.each do |interface|
|
203
209
|
ifcfg = nil
|
204
210
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
elsif File.exists?("/etc/sysconfig/network/ifcfg-#{interface}")
|
210
|
-
ifcfg = "/etc/sysconfig/network/ifcfg-#{interface}"
|
211
|
+
if @ifcfg_dir
|
212
|
+
if File.exists?("#{@ifcfg_dir}/ifcfg-#{interface}")
|
213
|
+
ifcfg = "#{@ifcfg_dir}/ifcfg-#{interface}"
|
214
|
+
end
|
211
215
|
end
|
212
216
|
|
213
217
|
interface_config = {}
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matteo Cerutti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|