From aacb1862a2bcf120c4907ca40ecc77e0f53e92ef Mon Sep 17 00:00:00 2001 From: Frank Groeneveld Date: Thu, 17 Feb 2022 08:15:33 +0100 Subject: [PATCH] Silence stderr output on *BSD Without this, all my cronjobs, servers etc will always output to stderr: ``` hostname: unknown option -- f usage: hostname [-s] [name-of-host] ``` --- lib/new_relic/agent/hostname.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/new_relic/agent/hostname.rb b/lib/new_relic/agent/hostname.rb index ca8d1ee048..5761c7d8ad 100644 --- a/lib/new_relic/agent/hostname.rb +++ b/lib/new_relic/agent/hostname.rb @@ -22,7 +22,7 @@ def self.get # we get back empty string. So, solution here is to check for non-zero # exit status and retry the command without the -f flag. def self.get_fqdn - fqdn = %x(hostname -f).chomp! + fqdn = %x(hostname -f 2>/dev/null).chomp! fqdn = %x(hostname).chomp! unless $?.exitstatus.zero? fqdn rescue => e