class Telegraf < Formula desc "Server-level metric gathering agent for InfluxDB" homepage "https://influxdata.com" url "https://github.com/influxdata/telegraf/archive/1.13.0.tar.gz" sha256 "055fb85be002e1fb50f9077c3513a1fef9dc7cecf5ac583d8e1f5ae5c3ebfee4" head "https://github.com/influxdata/telegraf.git" bottle do cellar :any_skip_relocation sha256 "8b10b64e49627c4fca3ae010e3a8768ce2cc8ac640b2bb5390a4f36f46323238" => :catalina sha256 "bad0bb1fab6d96467aa83084f285ee9a6f9f88be6ad61eca380f9def9ede4f28" => :mojave sha256 "90f29d2908f9dcd0eb741f96c01e5d5d68153c0ef5d17297b4414618f4dbf3ed" => :high_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