sensu-plugins-check-lan 0.0.1 → 0.0.2
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 +12 -0
- data/LICENSE +22 -0
- data/README.md +21 -0
- data/bin/check-check-lan.rb +75 -0
- data/lib/sensu-plugins-check-lan.rb +1 -55
- data/lib/sensu-plugins-check-lan/version.rb +28 -0
- metadata +165 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0dbae728d0107ac8130cec86f09df499bcec9fa
|
4
|
+
data.tar.gz: c3f8a88844331f9796a04c4bec2e62764c958947
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6388d9ea0363668862663cee45d8df86f251a6f33e656b07bc82c1e4329f7312ebd61c8196a956f8c5b8dccc2cbf4ef62e9f42addc6b7502a2b118889fe5b27d
|
7
|
+
data.tar.gz: fb80e46354759fe9908bef52446f4e8cd25df707f1fe508023f0ae086efd8ed1606dcef63fe901b083f878eff5602d45f93910407dbab06307501e465dd26d17
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#Change Log
|
2
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
3
|
+
|
4
|
+
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
|
+
|
6
|
+
## Unreleased][unreleased]
|
7
|
+
|
8
|
+
## 0.0.1.alpha.1 - 1970-01-01
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
##
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Sensu Plugins, sensu-plugin@sensu-plugins.io
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
## Sensu-Plugins-
|
2
|
+
|
3
|
+
[](https://travis-ci.org/sensu-plugins/sensu-plugins-)
|
4
|
+
[](http://badge.fury.io/rb/sensu-plugins-)
|
5
|
+
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-)
|
6
|
+
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-)
|
7
|
+
[](https://gemnasium.com/sensu-plugins/sensu-plugins-)
|
8
|
+
|
9
|
+
## Functionality
|
10
|
+
|
11
|
+
## Files
|
12
|
+
*
|
13
|
+
*
|
14
|
+
*
|
15
|
+
*
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
|
20
|
+
|
21
|
+
## Notes
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/opt/sensu/embedded/bin/ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
#
|
4
|
+
# check-lan
|
5
|
+
#
|
6
|
+
# DESCRIPTION:
|
7
|
+
# This plugin uses checks (standalone) if a given ip is reachable and if it is not restarts the given interface.
|
8
|
+
# If this is not successfull this plugin reboots the client machine.
|
9
|
+
#
|
10
|
+
# PLATFORMS:
|
11
|
+
# Linux
|
12
|
+
#
|
13
|
+
# DEPENDENCIES:
|
14
|
+
# gem: sensu-plugin
|
15
|
+
#
|
16
|
+
# USAGE:
|
17
|
+
#
|
18
|
+
# NOTES:
|
19
|
+
#
|
20
|
+
# LICENSE:
|
21
|
+
# Copyright 2017 Max
|
22
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
23
|
+
# for details.
|
24
|
+
|
25
|
+
require 'sensu-plugin/check/cli'
|
26
|
+
|
27
|
+
class CheckLan < Sensu::Plugin::Check::CLI
|
28
|
+
#change the IP whatever IP you want to ping.
|
29
|
+
IP_TO_PING = "172.22.1.100"
|
30
|
+
PING_COUNT = 1
|
31
|
+
#change interface to the interface you want to check
|
32
|
+
INTERFACE="eth0"
|
33
|
+
|
34
|
+
PING = "/bin/ping"
|
35
|
+
IFUP="/sbin/ifup"
|
36
|
+
IFDOWN="/sbin/ifdown --force"
|
37
|
+
|
38
|
+
#Method to ping the IP_TO_PING
|
39
|
+
def ping
|
40
|
+
`#{PING} -c #{PING_COUNT} #{IP_TO_PING} > /dev/null 2> /dev/null`
|
41
|
+
end
|
42
|
+
|
43
|
+
def run
|
44
|
+
|
45
|
+
puts "ping #{IP_TO_PING} for checking conectivity..."
|
46
|
+
ping()
|
47
|
+
if $?.exitstatus >= 1
|
48
|
+
puts "#{INTERFACE} seems to be down, trying to bring it up..."
|
49
|
+
puts "executing ifdown #{INTERFACE}"
|
50
|
+
`sudo #{IFDOWN} #{INTERFACE} `
|
51
|
+
puts "waiting 10 seconds to bring #{INTERFACE} up..."
|
52
|
+
`sleep 10`
|
53
|
+
puts "executing ifup #{INTERFACE}"
|
54
|
+
`sudo #{IFUP} #{INTERFACE}`
|
55
|
+
puts "waiting 10 seconds to ping again..."
|
56
|
+
`sleep 10`
|
57
|
+
puts "ping server again..."
|
58
|
+
ping()
|
59
|
+
if $?.exitstatus >= 1
|
60
|
+
puts "#{INTERFACE} is still down, REBOOT to recover..."
|
61
|
+
`sudo reboot`
|
62
|
+
critical "REBOOT to recover"
|
63
|
+
else
|
64
|
+
#puts "Resetting #{INTERFACE} was successfull"
|
65
|
+
ok "Resetting #{INTERFACE} was successfull"
|
66
|
+
end
|
67
|
+
else
|
68
|
+
#puts "#{INTERFACE} is up"
|
69
|
+
ok "#{INTERFACE} is up"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
|
@@ -1,55 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#sensu plugin for checking wlan conenctivity
|
4
|
-
|
5
|
-
require 'sensu-plugin/check/cli'
|
6
|
-
|
7
|
-
class CheckLan < Sensu::Plugin::Check::CLI
|
8
|
-
#change the IP whatever IP you want to ping.
|
9
|
-
IP_TO_PING = "172.22.1.100"
|
10
|
-
PING_COUNT = 1
|
11
|
-
#change interface to the interface you want to check
|
12
|
-
INTERFACE="eth0"
|
13
|
-
|
14
|
-
PING = "/bin/ping"
|
15
|
-
IFUP="/sbin/ifup"
|
16
|
-
IFDOWN="/sbin/ifdown --force"
|
17
|
-
|
18
|
-
#Method to ping the IP_TO_PING
|
19
|
-
def ping
|
20
|
-
`#{PING} -c #{PING_COUNT} #{IP_TO_PING} > /dev/null 2> /dev/null`
|
21
|
-
end
|
22
|
-
|
23
|
-
def run
|
24
|
-
|
25
|
-
puts "ping #{IP_TO_PING} for checking conectivity..."
|
26
|
-
ping()
|
27
|
-
if $?.exitstatus >= 1
|
28
|
-
puts "#{INTERFACE} seems to be down, trying to bring it up..."
|
29
|
-
puts "executing ifdown #{INTERFACE}"
|
30
|
-
`sudo #{IFDOWN} #{INTERFACE} `
|
31
|
-
puts "waiting 10 seconds to bring #{INTERFACE} up..."
|
32
|
-
`sleep 10`
|
33
|
-
puts "executing ifup #{INTERFACE}"
|
34
|
-
`sudo #{IFUP} #{INTERFACE}`
|
35
|
-
puts "waiting 10 seconds to ping again..."
|
36
|
-
`sleep 10`
|
37
|
-
puts "ping server again..."
|
38
|
-
ping()
|
39
|
-
if $?.exitstatus >= 1
|
40
|
-
puts "#{INTERFACE} is still down, REBOOT to recover..."
|
41
|
-
`sudo reboot`
|
42
|
-
critical "REBOOT to recover"
|
43
|
-
else
|
44
|
-
#puts "Resetting #{INTERFACE} was successfull"
|
45
|
-
ok "Resetting #{INTERFACE} was successfull"
|
46
|
-
end
|
47
|
-
else
|
48
|
-
#puts "#{INTERFACE} is up"
|
49
|
-
ok "#{INTERFACE} is up"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
|
1
|
+
require 'sensu-plugins-check-lan/version'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
module SensuPluginsCheckLan
|
5
|
+
# This defines the version of the gem
|
6
|
+
module Version
|
7
|
+
MAJOR = 0
|
8
|
+
MINOR = 0
|
9
|
+
PATCH = 2
|
10
|
+
|
11
|
+
VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
|
12
|
+
|
13
|
+
NAME = 'sensu-plugins-check-lan'
|
14
|
+
BANNER = "#{NAME} v%s"
|
15
|
+
|
16
|
+
module_function
|
17
|
+
|
18
|
+
def version
|
19
|
+
format(BANNER, VER_STRING)
|
20
|
+
end
|
21
|
+
|
22
|
+
def json_version
|
23
|
+
{
|
24
|
+
'version' => VER_STRING
|
25
|
+
}.to_json
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,181 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-check-lan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Max
|
7
|
+
- Max
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
cert_chain:
|
11
|
+
- certs/sensu-plugins.pem
|
12
|
+
date: 2017-03-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sensu-plugin
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 1.1.0
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 1.1.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: codeclimate-test-reporter
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0.4'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0.4'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rubocop
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0.30'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0.30'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.1'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.1'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: bundler
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.7'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.7'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rake
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '10.0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '10.0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: github-markup
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '1.3'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '1.3'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: redcarpet
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '3.2'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '3.2'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: yard
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0.8'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0.8'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: pry
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0.10'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0.10'
|
154
|
+
description: "Check (standalone) if a certain ip is reachable. If not reset the network
|
155
|
+
interface and if it is still not reachable \n\t\t\t\t\t\t\t reboot the machine."
|
16
156
|
email:
|
17
|
-
executables:
|
157
|
+
executables:
|
158
|
+
- check-check-lan.rb
|
18
159
|
extensions: []
|
19
160
|
extra_rdoc_files: []
|
20
161
|
files:
|
162
|
+
- CHANGELOG.md
|
163
|
+
- LICENSE
|
164
|
+
- README.md
|
165
|
+
- bin/check-check-lan.rb
|
21
166
|
- lib/sensu-plugins-check-lan.rb
|
167
|
+
- lib/sensu-plugins-check-lan/version.rb
|
22
168
|
homepage:
|
23
169
|
licenses:
|
24
170
|
- MIT
|
25
|
-
metadata:
|
26
|
-
|
171
|
+
metadata:
|
172
|
+
maintainer: ''
|
173
|
+
development_status: unmaintained
|
174
|
+
production_status: unstable - testing recommended
|
175
|
+
release_draft: 'false'
|
176
|
+
release_prerelease: 'false'
|
177
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
178
|
+
in /etc/default/sensu
|
27
179
|
rdoc_options: []
|
28
180
|
require_paths:
|
29
181
|
- lib
|
@@ -31,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
31
183
|
requirements:
|
32
184
|
- - ">="
|
33
185
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
186
|
+
version: 1.9.3
|
35
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
188
|
requirements:
|
37
189
|
- - ">="
|
@@ -42,5 +194,5 @@ rubyforge_project:
|
|
42
194
|
rubygems_version: 2.5.2
|
43
195
|
signing_key:
|
44
196
|
specification_version: 4
|
45
|
-
summary:
|
197
|
+
summary: Check for Wlan or Lan conectivity
|
46
198
|
test_files: []
|