class Telegraf < Formula desc "Server-level metric gathering agent for InfluxDB" homepage "https://influxdata.com" url "https://github.com/influxdata/telegraf/archive/1.9.0.tar.gz" sha256 "5a71c5fbe1b691bc64e56898d28238d2ad9ef0db7b9d816724b6b8c872cdecd2" head "https://github.com/influxdata/telegraf.git" bottle do cellar :any_skip_relocation sha256 "90670c95687f69fc05d482b60421e306dfe64ec43f7fa5be3131a3720d151d20" => :mojave sha256 "8991fde5b4a36a8a699f1272711ecffea4cceda6daa5c94d001c7b53eb4a2547" => :high_sierra sha256 "dbf732df30b7ffa2616a603166380c81bf515c893133eb2f2bc2e6c92abc41ca" => :sierra end depends_on "dep" => :build depends_on "go" => :build def install ENV["GOPATH"] = buildpath dir = buildpath/"src/github.com/influxdata/telegraf" dir.install buildpath.children cd dir do system "dep", "ensure", "-vendor-only" system "go", "install", "-ldflags", "-X main.version=#{version}", "./..." prefix.install_metafiles end bin.install "bin/telegraf" etc.install dir/"etc/telegraf.conf" => "telegraf.conf" end def post_install # Create directory for additional user configurations (etc/"telegraf.d").mkpath end plist_options :manual => "telegraf -config #{HOMEBREW_PREFIX}/etc/telegraf.conf" def plist; <<~EOS KeepAlive SuccessfulExit Label #{plist_name} ProgramArguments #{opt_bin}/telegraf -config #{etc}/telegraf.conf -config-directory #{etc}/telegraf.d RunAtLoad WorkingDirectory #{var} StandardErrorPath #{var}/log/telegraf.log StandardOutPath #{var}/log/telegraf.log EOS end test do (testpath/"config.toml").write shell_output("#{bin}/telegraf -sample-config") system "#{bin}/telegraf", "-config", testpath/"config.toml", "-test", "-input-filter", "cpu:mem" end end