class Telegraf < Formula desc "Server-level metric gathering agent for InfluxDB" homepage "https://influxdata.com" url "https://github.com/influxdata/telegraf/archive/1.10.1.tar.gz" sha256 "7d61966b7dc9e6045d97ee58b9fc19316f8fa03e8194134236809899b4695b63" head "https://github.com/influxdata/telegraf.git" bottle do cellar :any_skip_relocation sha256 "8a4c512be54d40f906c8d06a7b2c19b444e42a71c76893d1ceb1eedfbe0c7dfe" => :mojave sha256 "5af357ded6b5be234b9479b9a847b9e90add907610c95aa3d4cae8325bb0b487" => :high_sierra sha256 "161fc7674447490d38f7dc87ce0b63d24c61a057b8378cce3cc1beffd75c202f" => :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