Method: NewRelic::Agent::Hostname.get_fqdn

Defined in:
lib/new_relic/agent/hostname.rb

.get_fqdnObject

Pass ‘-f’ to the external executable ‘hostname’ to request the fully qualified domain name (fqdn). For implementations of ‘hostname’ that do not support ‘-f’ (such as the one OpenBSD ships with), fall back to calling ‘hostname’ without the ‘-f’. If both ways of calling ‘hostname’ fail, or in a context where ‘hostname’ is not even available (within an AWS Lambda function, for example), call the ‘get’ method which uses Socket instead of an external executable.

[View source]

29
30
31
32
33
34
35
36
37
38
# File 'lib/new_relic/agent/hostname.rb', line 29

def self.get_fqdn
  begin
    NewRelic::Helper.run_command('hostname -f')
  rescue NewRelic::CommandRunFailedError
    NewRelic::Helper.run_command('hostname')
  end
rescue NewRelic::CommandExecutableNotFoundError, NewRelic::CommandRunFailedError => e
  NewRelic::Agent.logger.debug("#{e.class} - #{e.message}")
  get
end