eye-slack 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.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/README.md +77 -0
- data/Rakefile +3 -0
- data/eye-slack.gemspec +27 -0
- data/lib/eye/notify/slack/version.rb +10 -0
- data/lib/eye/notify/slack.rb +68 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dd6e47778991df25d079105c984b28b488801f11
|
4
|
+
data.tar.gz: 7d650b35ea86be934e710c717ded864df66cf3eb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 189dcdab591ec8fdb2b271d7cdb18aa90012127557dd4737d1f69408db8f5f1f5c943f86153620cb29c6d7bbbd15a36d484a43e4d13a9d0ef7127e3cca922540
|
7
|
+
data.tar.gz: 0259cb39fdafe59a8f75d9c33c60b078e3fc5df5b4c9e659c282f64aab3bdb76b2954973327256d02164fc16a52f5abdb0ac505695c57cc7920cc9b5039135cd
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# Eye::Slack
|
2
|
+
|
3
|
+
Sends info about process crashes to Slack channel.
|
4
|
+
|
5
|
+
**NOTE**: This will **NOT** probably work with eye > 0.7
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'eye'
|
13
|
+
gem 'eye-slack'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install eye-slack
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
this is an example configuration file
|
27
|
+
|
28
|
+
````
|
29
|
+
# Notify example
|
30
|
+
require 'eye/notify/slack'
|
31
|
+
|
32
|
+
Eye.config do
|
33
|
+
slack webhook_url: 'url', username: 'eye', color: 'danger'
|
34
|
+
contact :dev, :slack, '#test'
|
35
|
+
logger '/tmp/eye.log'
|
36
|
+
end
|
37
|
+
|
38
|
+
Eye.application 'test' do
|
39
|
+
notify :dev, :debug
|
40
|
+
stdall '/tmp/eye-example.log'
|
41
|
+
|
42
|
+
process :some_process do
|
43
|
+
notify :dev, :debug
|
44
|
+
start_command 'sleep 120'
|
45
|
+
daemonize true
|
46
|
+
pid_file '/tmp/sleep.pid'
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
````
|
51
|
+
|
52
|
+
# Configuration
|
53
|
+
|
54
|
+
* add `slack` line to `Eye.config` section and check following parameters
|
55
|
+
* `webhook_url` - *required* - webhook URL
|
56
|
+
* `username` - who is reporting to slack, *Eye Bot* as a default
|
57
|
+
* `color` - *#f0f0f0* is default. You can choose from RGB or `good`, `warning` and `danger`
|
58
|
+
* `icon` - either emoji or URL of the icon, emoji *must* start and end with `:`
|
59
|
+
* `title` - title, displayed in bold
|
60
|
+
* `message` - message to be sent, default is `*#name#* on #host# *#message#* at #time#.`
|
61
|
+
|
62
|
+
* `message` has following variables (variable must be enclosed to ##)
|
63
|
+
* `time` - human readable time of the event
|
64
|
+
* `host` - hostname
|
65
|
+
* `message` - full message
|
66
|
+
* `name` - name of process
|
67
|
+
* `full_name` - full process name (like group::process)
|
68
|
+
* `pid` - process ID
|
69
|
+
* `level` - message info level
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
1. Fork it ( https://github.com/[my-github-username]/eye-slack/fork )
|
74
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
75
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
76
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
77
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/eye-slack.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'eye/notify/slack/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "eye-slack"
|
8
|
+
spec.version = Eye::Notify::Slack::VERSION
|
9
|
+
spec.authors = ["Tom Meinlschmidt"]
|
10
|
+
spec.email = ["tomas@meinlschmidt.org"]
|
11
|
+
spec.summary = %q{Eye to hipchat notification}
|
12
|
+
spec.description = %q{Eye to hipchat notification}
|
13
|
+
spec.homepage = "https://github.com/tmeinlschmidt/eye-hipchat"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
|
24
|
+
spec.add_runtime_dependency "slack-notifier", "~> 1.2.1"
|
25
|
+
spec.add_runtime_dependency "eye", "~> 0.5"
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'eye'
|
2
|
+
require 'eye/notify/slack/version'
|
3
|
+
|
4
|
+
require 'slack-notifier'
|
5
|
+
|
6
|
+
module Eye
|
7
|
+
class Notify
|
8
|
+
|
9
|
+
class Slack < Eye::Notify::Custom
|
10
|
+
|
11
|
+
# Eye.config do
|
12
|
+
# slack webhook_url: '1312312', icon: '', username: 'eye bot', color: '#f0f0f0', channel
|
13
|
+
# contact :info, :slack, '#channel name'
|
14
|
+
# end
|
15
|
+
|
16
|
+
param :webhook_url, String, true
|
17
|
+
# icon, either emoji or URL
|
18
|
+
param :icon, String, false, nil
|
19
|
+
# not required, if not specified, we're using 'Eye Bot'
|
20
|
+
param :username, String, false, 'Eye Bot'
|
21
|
+
# not required, 'gray' as default color, you can use RGB or danger, good, warning
|
22
|
+
param :color, String, false, '#f0f0f0'
|
23
|
+
# available messages:
|
24
|
+
# time host message name full_name pid level
|
25
|
+
param :message, String, false, '*#name#* on #host# *#message#* at #time#.'
|
26
|
+
# whether to notify room or not
|
27
|
+
param :title, String, false, ''
|
28
|
+
|
29
|
+
def execute
|
30
|
+
say(parse_message)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def parse_message
|
36
|
+
%w{time host message name full_name pid level}.each do |variable|
|
37
|
+
message.gsub!("##{variable}#", send("msg_#{variable}").to_s) if message =~ /##{variable}#/
|
38
|
+
end
|
39
|
+
message
|
40
|
+
end
|
41
|
+
|
42
|
+
def msg_time
|
43
|
+
Eye::Utils.human_time2(msg_at)
|
44
|
+
end
|
45
|
+
|
46
|
+
def client
|
47
|
+
opts = {
|
48
|
+
username: username
|
49
|
+
}
|
50
|
+
|
51
|
+
::Slack::Notifier.new webhook_url, opts
|
52
|
+
end
|
53
|
+
|
54
|
+
def say(what)
|
55
|
+
client.channel = contact
|
56
|
+
data = { attachments: [ { title: title, text: what, color: color, mrkdwn_in: [:text, :title] } ] }
|
57
|
+
|
58
|
+
if icon
|
59
|
+
data[:icon_emoji] = icon if icon =~ /\A:[^:]*:\Z/
|
60
|
+
data[:icon_url] = icon if icon =~ /\Ahttp[s]?:\/\/.*/i
|
61
|
+
end
|
62
|
+
|
63
|
+
client.ping '', data
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eye-slack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom Meinlschmidt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: slack-notifier
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.2.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.2.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: eye
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.5'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.5'
|
69
|
+
description: Eye to hipchat notification
|
70
|
+
email:
|
71
|
+
- tomas@meinlschmidt.org
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- eye-slack.gemspec
|
81
|
+
- lib/eye/notify/slack.rb
|
82
|
+
- lib/eye/notify/slack/version.rb
|
83
|
+
homepage: https://github.com/tmeinlschmidt/eye-hipchat
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.4.5
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Eye to hipchat notification
|
107
|
+
test_files: []
|