lita-nagios 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +23 -0
- data/Rakefile +6 -0
- data/contrib/nagios_config.txt +34 -0
- data/lib/lita/handlers/nagios.rb +76 -0
- data/lib/lita-nagios.rb +1 -0
- data/lita-nagios.gemspec +21 -0
- data/spec/lita/handlers/nagios_spec.rb +4 -0
- data/spec/spec_helper.rb +2 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ede4f56d168a547caf8b99d56291d290d0cbe62e
|
4
|
+
data.tar.gz: 9d0cb06ea65d68ed1717cd9ca49e2314ad5ffec1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: efd57d34c435a25b6309d10d1330e7b6e4fd3f2f34a84ff044550f18df0d110a1f03c1736bc2543a90a015ea973b6c8012fcf5bff3d478758d178105ab7a81eb
|
7
|
+
data.tar.gz: bc329db209e663fb2cd243e1b5740aeb8c0f10df94a3abc0505c118d61c73c1d6ced4ca61496334746967dc4481fb9a4b61f81b06231641fc26f4bf9900546b9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2013 Jonathan Amiez
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# lita-nagios
|
2
|
+
|
3
|
+
TODO: Add a description of the plugin.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add lita-nagios to your Lita instance's Gemfile:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
gem "lita-nagios"
|
11
|
+
```
|
12
|
+
|
13
|
+
## Configuration
|
14
|
+
|
15
|
+
TODO: Describe any configuration attributes the plugin exposes.
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
TODO: Describe the plugin's features and how to use them.
|
20
|
+
|
21
|
+
## License
|
22
|
+
|
23
|
+
[MIT](http://opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
define command {
|
2
|
+
command_name notify-host-by-bot
|
3
|
+
command_line /usr/bin/curl --request POST --connect-timeout 1 --max-time 2 $CONTACTADDRESS1$ \
|
4
|
+
--data-urlencode "room=#chan" \
|
5
|
+
--data-urlencode "type=host" \
|
6
|
+
--data-urlencode "host="$HOSTNAME$" \
|
7
|
+
--data-urlencode "output="$HOSTOUTPUT$" \
|
8
|
+
--data-urlencode "state="$HOSTSTATE$" \
|
9
|
+
--data-urlencode "notificationtype=$NOTIFICATIONTYPE$"
|
10
|
+
}
|
11
|
+
|
12
|
+
define command {
|
13
|
+
command_name notify-service-by-bot
|
14
|
+
command_line /usr/bin/curl --request POST --connect-timeout 1 --max-time 2 $CONTACTADDRESS1$ \
|
15
|
+
--data-urlencode "room=#chan" \
|
16
|
+
--data-urlencode "type=service" \
|
17
|
+
--data-urlencode "host=$HOSTALIAS$" \
|
18
|
+
--data-urlencode "output=$SERVICEOUTPUT$" \
|
19
|
+
--data-urlencode "description=$SERVICEDESC$" \
|
20
|
+
--data-urlencode "state=$SERVICESTATE$" \
|
21
|
+
--data-urlencode "notificationtype=$NOTIFICATIONTYPE$"
|
22
|
+
}
|
23
|
+
|
24
|
+
define contact{
|
25
|
+
contact_name bot
|
26
|
+
alias Lita IRC
|
27
|
+
service_notification_period 24x7
|
28
|
+
host_notification_period 24x7
|
29
|
+
service_notification_options w,u,c,r
|
30
|
+
host_notification_options d,r
|
31
|
+
service_notification_commands notify-service-by-bot
|
32
|
+
host_notification_commands notify-host-by-bot
|
33
|
+
address1 http://lita.example.com:8080/nagios
|
34
|
+
}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require "lita"
|
2
|
+
|
3
|
+
module Lita
|
4
|
+
module Handlers
|
5
|
+
class Nagios < Handler
|
6
|
+
|
7
|
+
def self.default_config(config)
|
8
|
+
config.default_room = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
http.post "/nagios", :receive
|
12
|
+
|
13
|
+
def receive(request, response)
|
14
|
+
if request.params.has_key?("type")
|
15
|
+
notif_type = request.params["type"].to_sym
|
16
|
+
unless respond_to?(notif_type, true)
|
17
|
+
raise "'#{notif_type}' is not supported by Nagios handler"
|
18
|
+
end
|
19
|
+
else
|
20
|
+
raise "Notification type must be defined in Nagios command"
|
21
|
+
end
|
22
|
+
|
23
|
+
if request.params.has_key?("room")
|
24
|
+
room = request.params["room"]
|
25
|
+
elsif Lita.config.handlers.nagios.default_room
|
26
|
+
room = Lita.config.handlers.nagios.default_room
|
27
|
+
else
|
28
|
+
raise "Room must be defined. Either fix your command or specify a default room ('config.handlers.nagios.default_room')"
|
29
|
+
end
|
30
|
+
|
31
|
+
message = send(notif_type, request.params)
|
32
|
+
|
33
|
+
ack = request.params["notificationtype"] == "ACKNOWLEDGEMENT" ? "[ACK] " : ""
|
34
|
+
|
35
|
+
target = Source.new(room: room)
|
36
|
+
robot.send_message(target, "nagios: #{ack}#{message}")
|
37
|
+
rescue Exception => e
|
38
|
+
Lita.logger.error(e)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def host(params)
|
44
|
+
case params["state"]
|
45
|
+
when "UP"
|
46
|
+
color = :light_green
|
47
|
+
when "DOWN"
|
48
|
+
color = :light_red
|
49
|
+
when "UNREACHABLE"
|
50
|
+
color = :orange
|
51
|
+
end
|
52
|
+
status = params["state"]
|
53
|
+
|
54
|
+
message = "#{params["host"]} is #{status}: #{params["output"]}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def service(params)
|
58
|
+
case params["state"]
|
59
|
+
when "OK"
|
60
|
+
color = :light_green
|
61
|
+
when "WARNING"
|
62
|
+
color = :yellow
|
63
|
+
when "CRITICAL"
|
64
|
+
color = :light_red
|
65
|
+
when "UNKNOWN"
|
66
|
+
color = :orange
|
67
|
+
end
|
68
|
+
status = params["state"]
|
69
|
+
|
70
|
+
message = "#{params["host"]}:#{params["description"]} is #{status}: #{params["output"]}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
Lita.register_handler(Nagios)
|
75
|
+
end
|
76
|
+
end
|
data/lib/lita-nagios.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "lita/handlers/nagios"
|
data/lita-nagios.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-nagios"
|
3
|
+
spec.version = "0.0.1"
|
4
|
+
spec.authors = ["Jonathan Amiez"]
|
5
|
+
spec.email = ["jonathan.amiez@gmail.com"]
|
6
|
+
spec.description = "Nagios interaction with Lita"
|
7
|
+
spec.summary = "Receive notification and send ACK/recheck, etc. to Nagios"
|
8
|
+
spec.homepage = "https://github.com/josqu4red/lita-nagios"
|
9
|
+
spec.license = "MIT"
|
10
|
+
|
11
|
+
spec.files = `git ls-files`.split($/)
|
12
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
spec.add_runtime_dependency "lita", "~> 3.0"
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
19
|
+
spec.add_development_dependency "rake", "~> 0"
|
20
|
+
spec.add_development_dependency "rspec", "~> 2.14"
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-nagios
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan Amiez
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lita
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.14'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.14'
|
69
|
+
description: Nagios interaction with Lita
|
70
|
+
email:
|
71
|
+
- jonathan.amiez@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- contrib/nagios_config.txt
|
82
|
+
- lib/lita-nagios.rb
|
83
|
+
- lib/lita/handlers/nagios.rb
|
84
|
+
- lita-nagios.gemspec
|
85
|
+
- spec/lita/handlers/nagios_spec.rb
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
homepage: https://github.com/josqu4red/lita-nagios
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.2.0
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Receive notification and send ACK/recheck, etc. to Nagios
|
111
|
+
test_files:
|
112
|
+
- spec/lita/handlers/nagios_spec.rb
|
113
|
+
- spec/spec_helper.rb
|