monit2slack 0.1.4 → 0.1.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcbd60d8801a14b671eca1b11671f072836f602a94b6dfcc8e400bc158be09d1
4
- data.tar.gz: f361dc925f25821d27f1b1fae5464a53f5f0d57e04ee30ede167027eaa9d92c5
3
+ metadata.gz: 96beb167507b4fe652f2c1f50cca4a4e2c76a2216a4e7c2454a81b247d50a65f
4
+ data.tar.gz: e9155dee78533d3a7c41207bea339d686a985db01b9b4c1e3fc0637f52760b21
5
5
  SHA512:
6
- metadata.gz: fda78f07b0d24edc46704cf38b1d702025de22e761e41b15e2c06b43575b012021cbc33b59a6b116ca64529aa6a4a22dd0f520e9c610497cee11a995ed17b4ef
7
- data.tar.gz: e085381932b14d0f96e551cf935cb854181b4a0f7e9b7858df4b32977e4cc8bf0cc1a8a50e5f6137e6878b67ae13bbaa9f3d5906f0b8edf2235a2451c225d66c
6
+ metadata.gz: 6a57dd8f75ce37141d3cafe2595bbe8efd86721d9843fb7f71d027661c25a197d2373c4356d1d296bb68d57e2b972a8801c4399e15f9c5e35a27ba141fd6b679
7
+ data.tar.gz: baacad8cdeec1ceb17656d7ce89e4a5e534d7dc97ef4f572dd1f18b163a977e688d4ff9f32d713a7a2f47fdd54694cd0b735d3dc7faa8055e28703364c0f94b1
data/README.md CHANGED
@@ -26,6 +26,12 @@ This gem provides a binary `monit2slack`.
26
26
  monit2slack --webhook 'https://hooks.slack.com/services/xxx/xxx/xxx' --host MyServer --service NginX --status error --text 'Process NginX is down'
27
27
  ````
28
28
 
29
+ If using `rbenv`
30
+
31
+ ````
32
+ /usr/local/rbenv/shims/monit2slack --webhook 'https://hooks.slack.com/services/xxx/xxx/xxx' --host MyServer --service NginX --status error --text 'Process NginX is down'
33
+ ````
34
+
29
35
  If you prefer you can call if manually from a rb file.
30
36
 
31
37
  ````
@@ -38,13 +44,32 @@ Monit2Slack::Post
38
44
 
39
45
  ## Monit configuration file
40
46
 
47
+ ### Implicit configuration
48
+
49
+ In this case `hostname`, `service` and `description` gets read from the environment variables that monit provides.
50
+
51
+ ````
52
+ check process NginX
53
+ with pidfile /run/nginx.pid
54
+ start program = "/etc/init.d/nginx start" with timeout 30 seconds
55
+ stop program = "/etc/init.d/nginx stop" with timeout 30 seconds
56
+ if does not exist for 1 cycle
57
+ then exec "/usr/local/rbenv/shims/monit2slack --webhook 'https://hooks.slack.com/services/xxx/xxx/xxx' --status error'"
58
+ else if succeeded for 1 cycle then exec "/usr/local/rbenv/shims/monit2slack --webhook 'https://hooks.slack.com/services/xxx/xxx/xxx' --status ok"
59
+ if does not exist then restart
60
+ ````
61
+
62
+ ### Explicit configuration
63
+
64
+ You control settings like `hostname`, `service` and `description`.
65
+
41
66
  ````
42
67
  check process NginX
43
68
  with pidfile /run/nginx.pid
44
69
  start program = "/etc/init.d/nginx start" with timeout 30 seconds
45
70
  stop program = "/etc/init.d/nginx stop" with timeout 30 seconds
46
71
  if does not exist for 1 cycle
47
- then exec "monit2slack --webhook 'https://hooks.slack.com/services/xxx/xxx/xxx' --host MyServer --service NginX --status error --text 'Process NginX is down'"
72
+ then exec "/usr/local/rbenv/shims/monit2slack --webhook 'https://hooks.slack.com/services/xxx/xxx/xxx' --host MyServer --service NginX --status error --text 'Process NginX is down'"
48
73
  else if succeeded for 1 cycle then exec "monit2slack --webhook 'https://hooks.slack.com/services/xxx/xxx/xxx' --host MyServer --service NginX --status ok --text 'Process NginX is up'"
49
74
  if does not exist then restart
50
75
  ````
@@ -57,6 +57,10 @@ module Monit2Slack
57
57
 
58
58
  opt_parser.parse!
59
59
 
60
+ options[:service] ||= ENV['MONIT_SERVICE']
61
+
62
+ options[:host] ||= ENV['MONIT_HOST']
63
+
60
64
  options[:color] ||= case options[:status]
61
65
  when "error"
62
66
  "danger"
@@ -99,7 +103,7 @@ module Monit2Slack
99
103
  defaults channel: options[:channel],
100
104
  username: options[:username]
101
105
  end
102
- notifier.post text: "Message from Monit", icon_emoji: options[:emoji] if options[:text] && options[:emoji]
106
+ notifier.post text: "Message from Monit: #{ENV['MONIT_SERVICE']} #{ENV['MONIT_DESCRIPTION']}", icon_emoji: options[:emoji] if options[:text] && options[:emoji]
103
107
  notifier.post attachments: [attachment] if attachment
104
108
  notifier.ping options[:ping] if options[:ping]
105
109
  end
@@ -1,3 +1,3 @@
1
1
  module Monit2Slack
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monit2slack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nedim Hadzimahmutovic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-19 00:00:00.000000000 Z
11
+ date: 2018-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.7.6
122
+ rubygems_version: 2.7.7
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Post monit status messages to Slack.