notifu 1.6.1 → 1.6.2
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 +4 -4
- data/lib/notifu/actors/slack.rb +36 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b69631e3ea0fbdbb5e28b4b39fd1de5a8d5d491
|
4
|
+
data.tar.gz: 589bb9be936d20b9a6766220bbb8dafd93d38503
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7b97cb854bb4eab2c9a637bcba5de2e2812e106ba0331af16d39ce343a2f8dbd9567319484c20eb3c7bfc49cfc654bfe1123019d6f5b5e79b4bf4d5f8e70943
|
7
|
+
data.tar.gz: 81da4b166bff5f063ac9761d920c1e2d8e78c95dc2cd627b3d91372ac7d644d4e0e87467fe1eef34cff6ee6a0995ebd1613abd67f00a33aedf1fa42a1d85d969
|
data/lib/notifu/actors/slack.rb
CHANGED
@@ -15,7 +15,7 @@ module Notifu
|
|
15
15
|
icon_emoji: ":loudspeaker:",
|
16
16
|
attachments: [
|
17
17
|
{
|
18
|
-
fallback: self.text,
|
18
|
+
fallback: self.text(self.fallback_template),
|
19
19
|
color: self.color,
|
20
20
|
title: "#{self.issue.host} - #{self.issue.service}",
|
21
21
|
title_link: "#{Notifu::CONFIG[:uchiwa_url]}/#/client/#{self.issue.datacenter}/#{self.issue.host}?check=#{self.issue.service}",
|
@@ -38,7 +38,7 @@ module Notifu
|
|
38
38
|
return {
|
39
39
|
username: "notifu",
|
40
40
|
icon_emoji: ":loudspeaker:",
|
41
|
-
text: self.text
|
41
|
+
text: self.text(self.template)
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
@@ -55,24 +55,53 @@ module Notifu
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
def status_icon
|
59
|
+
return @status_icon if defined? @status_icon
|
60
|
+
case self.issue.code.to_i
|
61
|
+
when 0
|
62
|
+
@status_icon = ":white_check_mark:"
|
63
|
+
when 1
|
64
|
+
@status_icon = ":exclamation:"
|
65
|
+
when 2
|
66
|
+
@status_icon = ":bangbang:"
|
67
|
+
else
|
68
|
+
@status_icon = ":question: _#{self.issue.code.to_s}_"
|
69
|
+
end
|
70
|
+
@status_icon
|
71
|
+
end
|
72
|
+
|
73
|
+
def service_icon
|
74
|
+
return @service_icon if defined? @service_icon
|
75
|
+
@service_icon = ":computer:" if self.issue.service == "keepalive"
|
76
|
+
@service_icon ||= ":gear:"
|
77
|
+
end
|
78
|
+
|
58
79
|
# fallback simple message (templated, see below)
|
59
|
-
def text
|
60
|
-
|
80
|
+
def text(tmpl)
|
81
|
+
@tmpl_struct ||= OpenStruct.new({
|
61
82
|
notifu_id: self.issue.notifu_id,
|
62
83
|
datacenter: self.issue.datacenter,
|
63
84
|
host: self.issue.host,
|
85
|
+
address: self.issue.address,
|
64
86
|
service: self.issue.service,
|
65
87
|
message: self.issue.message,
|
66
88
|
status: self.issue.code.to_state,
|
67
89
|
duration: (Time.now.to_i - self.issue.time_created.to_i).duration,
|
68
|
-
uchiwa_url: "#{Notifu::CONFIG[:uchiwa_url]}/#/client/#{self.issue.datacenter}/#{self.issue.host}?check=#{self.issue.service}"
|
90
|
+
uchiwa_url: "#{Notifu::CONFIG[:uchiwa_url]}/#/client/#{self.issue.datacenter}/#{self.issue.host}?check=#{self.issue.service}",
|
91
|
+
service_icon: self.service_icon,
|
92
|
+
status_icon: self.status_icon
|
69
93
|
})
|
70
|
-
ERB.new(
|
94
|
+
ERB.new(tmpl).result(@tmpl_struct.instance_eval {binding})
|
71
95
|
end
|
72
96
|
|
73
97
|
# template for fallback message
|
98
|
+
def fallback_template
|
99
|
+
"*<%= data[:status] %>* <%= data[:datacenter]%> <%= data[:host] %> <%= data[:service] %> - <%= data[:message] %> (<%= data[:duration] %>) <%= data[:uchiwa_url] %>"
|
100
|
+
end
|
101
|
+
|
102
|
+
# template for plain message
|
74
103
|
def template
|
75
|
-
"
|
104
|
+
"<%= data[:status_icon] %> *<<%= data[:uchiwa_url] %>|<%= data[:datacenter] %>/<%= data[:host] %>>* <%= data[:address] %> <%= data[:service_icon] %> *<%= data[:service] %>* - <%= data[:message] %> _<%= data[:duration] %>_"
|
76
105
|
end
|
77
106
|
|
78
107
|
def act
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Radek 'blufor' Slavicinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|