hipchat_nagios_notifier 0.0.1

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.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,25 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rollout (0.0.1)
5
+ hipchat-api
6
+ thor
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ hipchat-api (1.0.4)
12
+ httparty
13
+ httparty (0.9.0)
14
+ multi_json (~> 1.0)
15
+ multi_xml
16
+ multi_json (1.3.7)
17
+ multi_xml (0.5.1)
18
+ thor (0.16.0)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ bundler (>= 1.0.0)
25
+ rollout!
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "hipchat_nagios_notifier"
4
+ HipchatNagiosNotifier::CLI.start
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "hipchat_nagios_notifier/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "hipchat_nagios_notifier"
7
+ s.version = HipchatNagiosNotifier::VERSION
8
+ s.authors = ["James Golick"]
9
+ s.email = ["jamesgolick@gmail.com"]
10
+ s.description = "HipChat nagios notifier."
11
+ s.summary = "HipChat nagios notifier."
12
+ s.homepage = "https://github.com/jamesgolick/hipchat_nagios_notifier"
13
+
14
+ s.require_paths = ["lib"]
15
+
16
+ s.rubyforge_project = "hipchat_nagios_notifier"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ # specify any dependencies here; for example:
24
+ s.add_development_dependency "bundler", ">= 1.0.0"
25
+
26
+ s.add_runtime_dependency "hipchat-api"
27
+ s.add_runtime_dependency "thor"
28
+ end
@@ -0,0 +1,58 @@
1
+ require "thor"
2
+ require "hipchat-api"
3
+ require "socket"
4
+
5
+ module HipchatNagiosNotifier
6
+ class CLI < Thor
7
+ COLORS = {
8
+ 'PROBLEM' =>'red',
9
+ 'RECOVERY' =>'green',
10
+ 'ACKNOWLEDGEMENT' =>'green',
11
+ 'FLAPPINGSTART' =>'orange',
12
+ 'FLAPPINGSTOP' =>'green',
13
+ 'FLAPPINGDISABLED' =>'gray',
14
+ 'DOWNTIMESTART' =>'red',
15
+ 'DOWNTIMESTOP' =>'green',
16
+ 'DOWNTIMECANCELLED' =>'green'
17
+ }
18
+
19
+ desc "service api_key room from details", "Notify about a service."
20
+ def service(api_key, room, from, details)
21
+ nagioshost = Socket.gethostname.split('.')[0]
22
+ servicedesc, hostalias,timestamp,type,hostaddress,servicestate,serviceoutput = details.split('|')
23
+ color = COLORS[type] || 'gray'
24
+
25
+ notify api_key, room, from, color, %{#{timestamp} - #{servicedesc} is #{servicestate} on #{hostaddress}: #{serviceoutput}}
26
+ end
27
+
28
+ desc "host api_key room from details", "Notify about a host."
29
+ def host(api_key, room, from, details)
30
+ nagioshost = Socket.gethostname.split('.')[0]
31
+ hostname,timestamp,type,hostaddress,hoststate,hostoutput = details.split('|')
32
+ color = COLORS[type] || 'gray'
33
+
34
+ notify api_key, room, from, color, %{#{timestamp} - Host #{hostname} (Origin: nagios@#{nagioshost})
35
+ Details:
36
+ Notification type: #{type}
37
+ Host: #{hostname} (Address #{hostaddress})
38
+ State: #{hoststate}
39
+ Info:
40
+ #{hostoutput}
41
+ ---------}.gsub("\n", "<br/>")
42
+ end
43
+
44
+ private
45
+ def notify(api_key, room, from, color, message)
46
+ connection(api_key).rooms_message(room, from, message.strip, true, color)
47
+ end
48
+
49
+ def connection(api_key)
50
+ begin
51
+ HipChat::API.new(api_key)
52
+ rescue Exception => e
53
+ $stderr.puts "Error connecting to HipChat: "+e.inspect
54
+ exit(1)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,3 @@
1
+ module HipchatNagiosNotifier
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hipchat_nagios_notifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - James Golick
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: &70123162734500 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70123162734500
25
+ - !ruby/object:Gem::Dependency
26
+ name: hipchat-api
27
+ requirement: &70123162734080 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70123162734080
36
+ - !ruby/object:Gem::Dependency
37
+ name: thor
38
+ requirement: &70123162733620 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70123162733620
47
+ description: HipChat nagios notifier.
48
+ email:
49
+ - jamesgolick@gmail.com
50
+ executables:
51
+ - hipchat_nagios_notifier
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - Gemfile
56
+ - Gemfile.lock
57
+ - bin/hipchat_nagios_notifier
58
+ - hipchat_nagios_notifier.gemspec
59
+ - lib/hipchat_nagios_notifier.rb
60
+ - lib/hipchat_nagios_notifier/version.rb
61
+ homepage: https://github.com/jamesgolick/hipchat_nagios_notifier
62
+ licenses: []
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project: hipchat_nagios_notifier
81
+ rubygems_version: 1.8.10
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: HipChat nagios notifier.
85
+ test_files: []
86
+ has_rdoc: