malsh 0.2.0 → 0.2.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 +4 -4
- data/lib/malsh/cli.rb +8 -8
- data/lib/malsh/notification/base.rb +2 -1
- data/lib/malsh/notification/slack.rb +8 -1
- data/lib/malsh/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 858533993fc700f1d6b4fc20d5d5c441ae037f0f
|
4
|
+
data.tar.gz: 15bdd45140ce7f0fb3faadbd94da1cf051886f45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5bbf854b5e324f132626028a63d1d0487f361463d8c7045be77b6e95cb7c7eb7cf7f5f29b45eee34df931e59996dfdeef48bc3533d69b7de93a4b488e5974e7
|
7
|
+
data.tar.gz: 2acfb0ef1aa9e8558f18b62b05cb4717300fb32c50e72158e7c2b7fa9658aa40aa753b34127cc5bbef8dca695654feb8dda3df76c1ddcb89410b02ec508cbffc
|
data/lib/malsh/cli.rb
CHANGED
@@ -8,6 +8,7 @@ module Malsh
|
|
8
8
|
class_option :slack_user, :type => :string, :aliases => :su
|
9
9
|
class_option :api_key, :type => :string, :aliases => :k
|
10
10
|
class_option :subject, :type => :string, :aliases => :s
|
11
|
+
class_option :org, :type => :string, :aliases => :o
|
11
12
|
class_option :invert_match, :type => :array, :aliases => :v
|
12
13
|
class_option :invert_role, :type => :array, :aliases => :r
|
13
14
|
class_option :regexp,:type => :array, :aliases => :e
|
@@ -16,23 +17,23 @@ module Malsh
|
|
16
17
|
def retire
|
17
18
|
Malsh.init options
|
18
19
|
|
19
|
-
|
20
|
+
hosts = Parallel.map(Malsh.metrics('memory.used')) do|memory|
|
20
21
|
host = Malsh.host_by_id memory.first
|
21
|
-
host
|
22
|
+
host if (!memory.last["memory.used"].respond_to?(:value) || !memory.last["memory.used"].value)
|
22
23
|
end.flatten.compact
|
23
24
|
|
24
|
-
Malsh.notify("退役未了ホスト一覧",
|
25
|
+
Malsh.notify("退役未了ホスト一覧", hosts)
|
25
26
|
end
|
26
27
|
|
27
28
|
desc 'maverick', 'check no role'
|
28
29
|
def maverick
|
29
30
|
Malsh.init options
|
30
31
|
|
31
|
-
|
32
|
-
h
|
32
|
+
hosts = Parallel.map(Malsh.hosts) do |h|
|
33
|
+
h if h.roles.keys.size < 1
|
33
34
|
end.flatten.compact
|
34
35
|
|
35
|
-
Malsh.notify("ロール無所属ホスト一覧",
|
36
|
+
Malsh.notify("ロール無所属ホスト一覧", hosts)
|
36
37
|
end
|
37
38
|
|
38
39
|
desc 'search', 'search hosts'
|
@@ -41,14 +42,13 @@ module Malsh
|
|
41
42
|
option :memory_threshold, :type => :numeric, :aliases => :m
|
42
43
|
option :status, :type => :string, :aliases => :st
|
43
44
|
def search
|
44
|
-
_host_names = {}
|
45
45
|
Malsh.init options
|
46
46
|
o = options[:status] ? { status: options[:status] } : {}
|
47
47
|
hosts = Malsh.hosts(o)
|
48
48
|
Object.const_get("Malsh::HostMetrics").constants.each do |c|
|
49
49
|
hosts = Object.const_get("Malsh::HostMetrics::#{c}").check(hosts)
|
50
50
|
end
|
51
|
-
Malsh.notify("ホスト一覧", hosts.compact
|
51
|
+
Malsh.notify("ホスト一覧", hosts.compact)
|
52
52
|
end
|
53
53
|
|
54
54
|
map %w[--version -v] => :__print_version
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Malsh::Notification
|
2
2
|
class Base
|
3
3
|
def self.notify(subject, hosts)
|
4
|
-
|
4
|
+
names = hosts.map(&:name)
|
5
|
+
puts "#{subject}: \n#{names.join("\n")}" if names.size > 0 && doit?
|
5
6
|
end
|
6
7
|
|
7
8
|
def self.doit?
|
@@ -3,8 +3,15 @@ module Malsh::Notification
|
|
3
3
|
class Slack < Base
|
4
4
|
def self.notify(subject, hosts)
|
5
5
|
return unless doit?
|
6
|
+
lists = if Malsh.options[:org]
|
7
|
+
hosts.map do |h|
|
8
|
+
"<https://mackerel.io/orgs/#{Malsh.options[:org]}/hosts/#{h.id}/-/setting|#{h.name}>"
|
9
|
+
end
|
10
|
+
else
|
11
|
+
hosts.map(&:name)
|
12
|
+
end
|
6
13
|
note = {
|
7
|
-
text:
|
14
|
+
text: lists.join("\n"),
|
8
15
|
color: "warning"
|
9
16
|
}
|
10
17
|
notifier.ping "*#{subject}*", attachments: [note]
|
data/lib/malsh/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kazuhiko yamahsita
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
159
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.
|
160
|
+
rubygems_version: 2.5.2
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: mackerel tools.
|