sensu-plugins-check-lan 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/sensu-plugins-check-lan.rb +55 -0
  3. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 78a834c7ac00efb71e167c3928c0b4257a361e96
4
+ data.tar.gz: f32abc878024abcb8b0c13f285f3b1c14270cbe1
5
+ SHA512:
6
+ metadata.gz: b28ce39f6b8de9ce2a70af5fd952edbc9e73c646d6f84959d7d8360da81e0ade943506df5ec896febb74e7ef344f259d3d23c42702cf575fd415d22fe123fdb5
7
+ data.tar.gz: 9794c1babf5900e623d3a64499a07c8604a0bd259faf26680e42478466358772f10fecb7bafff5c598774c4ec5cd73a3fc5050f66b41273dcb8e00297b9a132b
@@ -0,0 +1,55 @@
1
+ #!/opt/sensu/embedded/bin/ruby
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
+
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-check-lan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Max Karthan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: "A sensu plugin which checks if a certain ip is reachable and \n\t\t\t\t\t
14
+ \ if not it is restarting the set interface. If the machine is still not able \n\t\t\t\t\t
15
+ \ to reach the ip this check will reboot the machine."
16
+ email:
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/sensu-plugins-check-lan.rb
22
+ homepage:
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.5.2
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Sensu Networkcheck Plugin
46
+ test_files: []