Class: Malsh::CLI
- Inherits:
-
Thor
- Object
- Thor
- Malsh::CLI
- Defined in:
- lib/malsh/cli.rb
Instance Method Summary collapse
Instance Method Details
#__print_version ⇒ Object
67 68 69 |
# File 'lib/malsh/cli.rb', line 67 def __print_version puts Malsh::VERSION end |
#alert ⇒ Object
59 60 61 62 63 |
# File 'lib/malsh/cli.rb', line 59 def alert Malsh.init alerts = Malsh.alerts Malsh.notify_alert('アラート一覧', alerts) end |
#maverick ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/malsh/cli.rb', line 33 def maverick Malsh.init hosts = Parallel.map(Malsh.hosts) do |h| h if h.roles.keys.size < 1 end.flatten.compact Malsh.notify_host("ロール無所属ホスト一覧", hosts) end |
#retire ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/malsh/cli.rb', line 17 def retire Malsh.init hosts = Parallel.map(Malsh.hosts) do |h| m = Malsh.host_metrics( h.id, Malsh.host_metric_names(h.id).first, Time.now.to_i - 86400, Time.now.to_i ) h if (!m || (m["metrics"] && m["metrics"].size == 0)) && !(h["meta"].has_key?("cloud") && %w(elb rds cloudfront).include?(h["meta"]["cloud"]["provider"])) end.flatten.compact Malsh.notify_host("退役未了ホスト一覧", hosts) end |
#search ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/malsh/cli.rb', line 48 def search Malsh.init o = [:status] ? { status: [:status] } : {} hosts = Malsh.hosts(o) Object.const_get("Malsh::HostMetrics").constants.each do |c| hosts = Object.const_get("Malsh::HostMetrics::#{c}").check(hosts) end Malsh.notify_host("ホスト一覧", hosts.compact) end |