malsh 0.3.3 → 0.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53560007bf799b565171bcfb12e482e6b197b55114259f6df3795df69f1427cf
4
- data.tar.gz: 71469c9e09c80c1386b31b5a06a0d3fb80bc38850fa225d36ef7ebc02e3d471d
3
+ metadata.gz: 0ba6b10739e65fa9b65e4cd60cd399ccdc4fc688d69bbaca61f0d032e9fd2c3d
4
+ data.tar.gz: 521295added941774b5ba85b0a2c3777747569552f5c94b6926259a050c812c2
5
5
  SHA512:
6
- metadata.gz: a62d25c6b1906f595cc816765cbd38957b03393826e46def774ea348d440978cd6f223e8a9ad98769b3a66561ff3f1d6cbc2efaf13545fc860be522fc683fd77
7
- data.tar.gz: 884c91493164eae6609000338255ccd8dcd78083c25410c437cf1a718a3b8f115a2699aae44d56e15b6f60ffc1d9e98ba12fe1265aad22a74c05adac9388df0a
6
+ metadata.gz: '050824909ff8d3d653b0e7a864b403002560386d217f02de354a6829d38890f439c2950bc6ac443bde5165e1ae0aed03097d91e604368af0acafc8f9158a417a'
7
+ data.tar.gz: 77b19f42a100da11c7e29c79f00a438bbe6488817f478be5b0fa9363cabab365415e810dc0d98ce0b310d033b10f563ad92b22e0d26e8416a5a86b24112711d6
@@ -30,16 +30,16 @@ module Malsh::Notification
30
30
  ''
31
31
  end
32
32
 
33
- title = if alert.type == 'external'
34
- alert.monitor.name
35
- else
33
+ title = if Malsh.alert_has_host?(alert)
36
34
  alert.host.name
35
+ else
36
+ alert.monitor.name
37
37
  end
38
38
 
39
- author_name = if alert.type == 'external'
40
- ''
41
- else
39
+ author_name = if Malsh.alert_has_host?(alert)
42
40
  alert.host.roles.map{|k, v| v.map{|r| "#{k}: #{r}"}}.flatten.join(" ")
41
+ else
42
+ ''
43
43
  end
44
44
 
45
45
  attachments << {
data/lib/malsh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Malsh
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
data/lib/malsh.rb CHANGED
@@ -51,10 +51,10 @@ module Malsh
51
51
 
52
52
  def alerts()
53
53
  @_alerts ||= Mackerel.alerts.map do |alert|
54
- if alert.type == 'external'
55
- alert['monitor'] = Mackerel.monitor(alert.monitorId)
56
- else
54
+ if alert_has_host?(alert)
57
55
  alert['host'] = Malsh.host_by_id(alert.hostId)
56
+ else
57
+ alert['monitor'] = Mackerel.monitor(alert.monitorId)
58
58
  end
59
59
  alert
60
60
  end
@@ -91,5 +91,11 @@ module Malsh
91
91
  puts e
92
92
  end
93
93
  end
94
+
95
+ def alert_has_host?(alert)
96
+ exclude_types = ['external', 'service']
97
+ return false if exclude_types.include?(alert.type)
98
+ true
99
+ end
94
100
  end
95
101
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: malsh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - kazuhiko yamahsita
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-11 00:00:00.000000000 Z
11
+ date: 2021-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
158
  requirements: []
159
- rubygems_version: 3.1.4
159
+ rubygems_version: 3.1.6
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: mackerel tools.