Module: SystemdServiceCheck::SSH

Included in:
Base
Defined in:
lib/systemd_service_check/ssh.rb

Overview

SSH

Instance Method Summary collapse

Instance Method Details

#hostname(ssh) ⇒ String

Parameters:

  • ssh (Net::SSH::Connection::Session)

Returns:

  • (String)


21
22
23
# File 'lib/systemd_service_check/ssh.rb', line 21

def hostname(ssh)
  ssh.exec!('hostname').chomp
end

#ssh(server) ⇒ Utils::Result

Parameters:

Returns:



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/systemd_service_check/ssh.rb', line 7

def ssh(server)
  services = []
  Net::SSH.start(*server.conn_info) do |ssh|
    server[:hostname] = hostname(ssh)
    services =
      server[:services].map { |service_name| systemctl_show(ssh, service_name) }
    # TODO: store in Result object
    # puts ssh.exec!("systemctl list-timers")
  end
  Utils::Result.new(server, services)
end

#systemctl_show(ssh, service_name) ⇒ Utils::Service

Parameters:

  • ssh (Net::SSH::Connection::Session)
  • service_name (String)

Returns:



28
29
30
31
# File 'lib/systemd_service_check/ssh.rb', line 28

def systemctl_show(ssh, service_name)
  prop = ssh.exec!("systemctl show #{service_name} -p #{Utils::PROPERTY.join(",")}")
  Utils::Service.new(service_name, *split_property(prop))
end