sensu-plugins-network-checks 0.0.1.alpha.2 → 0.0.1.alpha.3
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +6 -2
- data/bin/check-banner.rb +63 -15
- data/lib/sensu-plugins-network-checks.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c31954aa9beb56d49f07b256b97ecbaa26492ea9
|
4
|
+
data.tar.gz: 7ec124eb4454ec3e819bd0c6db035a581742c2a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef3375f158d9e621a5c2e6e5c612de524f1f312e6d93d4d8d92fe087a4fed61a252190f9fbd942d80ad0450f87b15321bf8d05687a936324f063eb6475851071
|
7
|
+
data.tar.gz: 058a106f3dbe594ba1ecce3e7870b54baa06ed6ad1c8e31a09250c143dea901e86d17e8cdaeeb48c9ab1cd6268edb7ad69273f5e93aad9050828e70516fcba9b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
data/bin/check-banner.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
#
|
3
|
+
# encoding: UTF-8
|
3
4
|
# check-banner
|
4
5
|
#
|
5
6
|
# DESCRIPTION:
|
6
|
-
#
|
7
|
-
#
|
8
|
-
|
7
|
+
# Connect to a TCP port on one or more hosts, read till a char (EOF, EOL, etc)
|
8
|
+
# and test output against a pattern.
|
9
|
+
#
|
10
|
+
# Useful for SSH, ZooKeeper, etc.
|
11
|
+
#
|
9
12
|
# OUTPUT:
|
10
13
|
# plain text
|
11
14
|
#
|
@@ -18,14 +21,21 @@
|
|
18
21
|
#
|
19
22
|
# USAGE:
|
20
23
|
#
|
24
|
+
# To check there is only one zk leader
|
25
|
+
# ./check-banner.rb -h 'zk01,z02,zk03' -p 2181 -q leader -c 1 -w mntr -r EOF -O "ZK has one leader"
|
26
|
+
# -C "ZK has zero or more than one leader"
|
27
|
+
#
|
21
28
|
# NOTES:
|
29
|
+
# By default, checks for openssh on localhost port 22 and reads till EOL
|
30
|
+
#
|
22
31
|
#
|
23
32
|
# LICENSE:
|
24
33
|
# Copyright 2012 Sonian, Inc <chefs@sonian.net>
|
34
|
+
# Modified by Raghu Udiyar <raghu@helpshift.com>
|
25
35
|
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
26
36
|
# for details.
|
27
|
-
#
|
28
37
|
|
38
|
+
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
29
39
|
require 'sensu-plugin/check/cli'
|
30
40
|
require 'socket'
|
31
41
|
require 'timeout'
|
@@ -34,10 +44,10 @@ require 'timeout'
|
|
34
44
|
# Check Banner
|
35
45
|
#
|
36
46
|
class CheckBanner < Sensu::Plugin::Check::CLI
|
37
|
-
option :
|
38
|
-
short: '-H HOSTNAME',
|
39
|
-
long: '--
|
40
|
-
description: 'Host to connect to',
|
47
|
+
option :hosts,
|
48
|
+
short: '-H HOSTNAME(S)',
|
49
|
+
long: '--hostnames HOSTNAME(S)',
|
50
|
+
description: 'Host(s) to connect to, comma seperated',
|
41
51
|
default: 'localhost'
|
42
52
|
|
43
53
|
option :port,
|
@@ -64,14 +74,42 @@ class CheckBanner < Sensu::Plugin::Check::CLI
|
|
64
74
|
proc: proc(&:to_i),
|
65
75
|
default: 30
|
66
76
|
|
67
|
-
|
77
|
+
option :count_match,
|
78
|
+
short: '-c NUMBER',
|
79
|
+
long: '--count NUMBER',
|
80
|
+
description: 'Number of successful matches, default(1)',
|
81
|
+
proc: proc(&:to_i),
|
82
|
+
default: 1
|
83
|
+
|
84
|
+
option :read_till,
|
85
|
+
short: '-r CHAR',
|
86
|
+
long: '--readtill CHAR',
|
87
|
+
description: 'Read till CHAR is reached',
|
88
|
+
default: "\n"
|
89
|
+
|
90
|
+
option :ok_message,
|
91
|
+
short: '-O MESSAGE',
|
92
|
+
long: '--okmessage MESSAGE',
|
93
|
+
description: 'Custom ok message to send'
|
94
|
+
|
95
|
+
option :crit_message,
|
96
|
+
short: '-C MESSAGE',
|
97
|
+
long: '--critmessage MESSAGE',
|
98
|
+
description: 'Custom critical message to send'
|
99
|
+
|
100
|
+
def acquire_banner(host) # rubocop:disable all
|
68
101
|
timeout(config[:timeout]) do
|
69
|
-
sock = TCPSocket.new(
|
102
|
+
sock = TCPSocket.new(host, config[:port])
|
70
103
|
sock.puts config[:write] if config[:write]
|
71
|
-
|
104
|
+
if config[:read_till] == 'EOF'
|
105
|
+
banner = sock.gets(nil)
|
106
|
+
else
|
107
|
+
banner = sock.gets(config[:read_till])
|
108
|
+
end
|
109
|
+
return banner
|
72
110
|
end
|
73
111
|
rescue Errno::ECONNREFUSED
|
74
|
-
critical "Connection refused by #{
|
112
|
+
critical "Connection refused by #{host}:#{config[:port]}"
|
75
113
|
rescue Timeout::Error
|
76
114
|
critical 'Connection or read timed out'
|
77
115
|
rescue Errno::EHOSTUNREACH
|
@@ -81,8 +119,18 @@ class CheckBanner < Sensu::Plugin::Check::CLI
|
|
81
119
|
end
|
82
120
|
|
83
121
|
def run
|
84
|
-
|
85
|
-
|
86
|
-
|
122
|
+
hosts = config[:hosts].split(',')
|
123
|
+
okarray = []
|
124
|
+
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]
|
134
|
+
end
|
87
135
|
end
|
88
136
|
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.
|
4
|
+
version: 0.0.1.alpha.3
|
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-
|
33
|
+
date: 2015-03-20 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: sensu-plugin
|
metadata.gz.sig
CHANGED
Binary file
|