sensu-plugins-network-checks 0.0.1.alpha.3 → 0.0.1.alpha.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c31954aa9beb56d49f07b256b97ecbaa26492ea9
4
- data.tar.gz: 7ec124eb4454ec3e819bd0c6db035a581742c2a9
3
+ metadata.gz: 082a59e8ccfa3a08a9c574b102aa9651923e831c
4
+ data.tar.gz: e5c16cdc6b96bc9b7547b501d0bb2268ad2688b1
5
5
  SHA512:
6
- metadata.gz: ef3375f158d9e621a5c2e6e5c612de524f1f312e6d93d4d8d92fe087a4fed61a252190f9fbd942d80ad0450f87b15321bf8d05687a936324f063eb6475851071
7
- data.tar.gz: 058a106f3dbe594ba1ecce3e7870b54baa06ed6ad1c8e31a09250c143dea901e86d17e8cdaeeb48c9ab1cd6268edb7ad69273f5e93aad9050828e70516fcba9b
6
+ metadata.gz: d039892d53acabcb4240558d605f10b34039b532ac072479a4ab35846a487c0281d319d6731e44afdc32ff1e31746f357723cd14078b6f6dcd6b0aada3f9ba00
7
+ data.tar.gz: dd49bf6cb61b3b1ba37658173e92212dad215c24bc1f33486242119826b915be7759e117fb32de7695dfc72fa460ea9d8296b0a9fefcded0c5b1e7c3ac8b3b2f
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -10,3 +10,11 @@
10
10
  #### 0.0.1.alpha.3
11
11
 
12
12
  * additional functionality to check-banner #6
13
+
14
+ #### 0.0.1.alpha.4
15
+
16
+ * added check-mtu functionality #7
17
+
18
+ #### 0.0.1.alpha.5
19
+
20
+ * updated check-banner to allow checking for no banner
data/bin/check-banner.rb CHANGED
@@ -64,8 +64,7 @@ class CheckBanner < Sensu::Plugin::Check::CLI
64
64
  option :pattern,
65
65
  short: '-q PAT',
66
66
  long: '--pattern PAT',
67
- description: 'Pattern to search for',
68
- default: 'OpenSSH'
67
+ description: 'Pattern to search for'
69
68
 
70
69
  option :timeout,
71
70
  short: '-t SECS',
@@ -106,7 +105,6 @@ class CheckBanner < Sensu::Plugin::Check::CLI
106
105
  else
107
106
  banner = sock.gets(config[:read_till])
108
107
  end
109
- return banner
110
108
  end
111
109
  rescue Errno::ECONNREFUSED
112
110
  critical "Connection refused by #{host}:#{config[:port]}"
@@ -118,19 +116,42 @@ class CheckBanner < Sensu::Plugin::Check::CLI
118
116
  critical 'Connection closed unexpectedly'
119
117
  end
120
118
 
119
+ def acquire_no_banner(host)
120
+ timeout(config[:timeout]) do
121
+ sock = TCPSocket.new(host, config[:port])
122
+ end
123
+ rescue Errno::ECONNREFUSED
124
+ critical "Connection refused by #{host}:#{config[:port]}"
125
+ rescue Timeout::Error
126
+ critical 'Connection or read timed out'
127
+ rescue Errno::EHOSTUNREACH
128
+ critical 'Check failed to run: No route to host'
129
+ rescue EOFError
130
+ critical 'Connection closed unexpectedly'
131
+ end
132
+
121
133
  def run
122
134
  hosts = config[:hosts].split(',')
123
135
  okarray = []
124
136
  hosts.each do |host|
125
- banner = acquire_banner host
126
- okarray << 'ok' if banner =~ /#{config[:pattern]}/
127
- end
128
- if okarray.size == config[:count_match]
129
- ok "pattern #{config[:pattern]} matched" unless config[:ok_message]
130
- ok config[:ok_message]
131
- else
132
- critical "pattern #{config[:pattern]} does not match" unless config[:crit_message]
133
- critical config[:crit_message]
137
+ case config[:pattern]
138
+ when nil
139
+ banner = acquire_no_banner host
140
+ okarray << 'ok' if banner
141
+ else
142
+ banner = acquire_banner host
143
+ okarray << 'ok' if banner =~ /#{config[:pattern]}/
144
+ end
145
+ if okarray.size == config[:count_match] and config[:pattern] != nil
146
+ ok "pattern #{config[:pattern]} matched" unless config[:ok_message]
147
+ ok config[:ok_message]
148
+ elsif okarray.size == config[:count_match] and config[:pattern].nil?
149
+ ok "port #{config[:port]} open" unless config[:ok_message]
150
+ ok config[:ok_message]
151
+ else
152
+ critical "port count or pattern #{config[:pattern]} does not match" unless config[:crit_message]
153
+ critical config[:crit_message]
154
+ end
134
155
  end
135
156
  end
136
157
  end
data/bin/check-mtu.rb ADDED
@@ -0,0 +1,89 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-mtu.rb
4
+ #
5
+ # DESCRIPTION:
6
+ # Check MTU of a network interface
7
+ # In many setups, MTUs are tuned. MTU mismatches cause issues. Having a check for MTU settings helps catch these mistakes.
8
+ # Also, some instances in Amazon EC2 have default MTU size of 9,000 bytes. It is undesirable in some environments. This check can catch undesired setups.
9
+ #
10
+ # OUTPUT:
11
+ # OK, Warning, Critical message
12
+ #
13
+ # PLATFORMS:
14
+ # Linux
15
+ #
16
+ # DEPENDENCIES:
17
+ # gem: sensu-plugin
18
+ #
19
+ # USAGE:
20
+ # This will throw an error if interface eth0 does not have MTU of 1,500 bytes
21
+ # check-mtu.rb --interface eth0 --mtu 1500
22
+ # This will throw a warning if interface eth0 does not have MTU of 1,500 bytes
23
+ # check-mtu.rb --interface eth0 --mtu 1500 --warn
24
+ # This will throw an error if interface eth1 does not have MTU 9,000 bytes
25
+ # check-mtu.rb --interface eth1 --mtu 9000
26
+ # This will throw a waring if interface eth1 does not have MTU 9,000 bytes
27
+ # check-mtu.rb --interface eth1 --mtu 9000 --warn
28
+ #
29
+ # NOTES:
30
+ # No special notes. This should be fairly straight forward.
31
+ #
32
+ # LICENSE:
33
+ # Robin <robin81@gmail.com>
34
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
35
+ # for details.
36
+ #
37
+
38
+ require 'rubygems' if RUBY_VERSION < '1.9.0'
39
+ require 'sensu-plugin/check/cli'
40
+
41
+ #
42
+ # Check MTU
43
+ #
44
+ class CheckMTU < Sensu::Plugin::Check::CLI
45
+ option :interface,
46
+ short: '-i INTERFACE',
47
+ long: '--interface INTERFACE',
48
+ description: 'Specify the interface',
49
+ default: 'eth0'
50
+
51
+ option :mtu,
52
+ short: '-m MTU',
53
+ long: '--mtu MTU',
54
+ description: 'Optionally specify desired MTU size',
55
+ proc: proc(&:to_i),
56
+ default: 1500
57
+
58
+ option :warn,
59
+ short: '-w',
60
+ long: '--warn',
61
+ boolean: true,
62
+ Description: 'Specify the level of criticality to warning (instead of critical) if MTU size does not match',
63
+ default: false
64
+
65
+ def locate_mtu_file
66
+ "/sys/class/net/#{config[:interface]}/mtu"
67
+ end
68
+
69
+ # rubocop:disable Metrics/AbcSize
70
+ def run
71
+ required_mtu = config[:mtu]
72
+
73
+ mtu_file = locate_mtu_file
74
+
75
+ error_handling = 'critical'
76
+ error_handling = 'warning' if config[:warn]
77
+
78
+ file_read_issue_error_message = "#{mtu_file} does not exist or is not readble"
79
+ send(error_handling, file_read_issue_error_message) unless File.file?(mtu_file)
80
+
81
+ mtu = IO.read(mtu_file).to_i
82
+ mtu_mismatch_error_message = "Required MTU is #{required_mtu} and we found #{mtu}"
83
+ send(error_handling, mtu_mismatch_error_message) unless mtu == required_mtu
84
+
85
+ ok_message = "#{mtu} matches #{required_mtu}"
86
+ ok ok_message
87
+ end
88
+ # rubocop:enable Metrics/AbcSize
89
+ end
@@ -3,5 +3,5 @@
3
3
  #
4
4
  module SensuPluginsNetworkChecks
5
5
  # Gem version
6
- VERSION = '0.0.1.alpha.3'
6
+ VERSION = '0.0.1.alpha.5'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-network-checks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha.3
4
+ version: 0.0.1.alpha.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yieldbot, Inc. and contributors
@@ -30,7 +30,7 @@ cert_chain:
30
30
  8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
31
31
  HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
32
32
  -----END CERTIFICATE-----
33
- date: 2015-03-20 00:00:00.000000000 Z
33
+ date: 2015-03-25 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: sensu-plugin
@@ -232,6 +232,7 @@ description: ''
232
232
  email: "<sensu-users@googlegroups.com>"
233
233
  executables:
234
234
  - check-banner.rb
235
+ - check-mtu.rb
235
236
  - check-multicast-groups.rb
236
237
  - check-netstat-tcp.rb
237
238
  - check-ping.rb
@@ -249,6 +250,7 @@ files:
249
250
  - LICENSE
250
251
  - README.md
251
252
  - bin/check-banner.rb
253
+ - bin/check-mtu.rb
252
254
  - bin/check-multicast-groups.rb
253
255
  - bin/check-netstat-tcp.rb
254
256
  - bin/check-ping.rb
@@ -285,3 +287,4 @@ signing_key:
285
287
  specification_version: 4
286
288
  summary: ''
287
289
  test_files: []
290
+ has_rdoc:
metadata.gz.sig CHANGED
Binary file