class Telegraf < Formula desc "Server-level metric gathering agent for InfluxDB" homepage "https://influxdata.com" url "https://github.com/influxdata/telegraf/archive/1.1.0.tar.gz" sha256 "ffd3eb5b74c121ae57a83a8d39fb49371ccd2dec5c9e0746e487a5f41b0d45ac" head "https://github.com/influxdata/telegraf.git" bottle do cellar :any_skip_relocation sha256 "c4c3db9203677cdc62edd390ce19ef674101d66bb1302b5bcb17c88b593c18d9" => :sierra sha256 "d781f728d1bfbdc67466e04eb7cb73fc29da7f22cad323a8a69ae918ebbac098" => :el_capitan sha256 "b01d695a1dc2cabdf972ca81e8e6aa33431b7fc779e2b3ba7cc043886e419383" => :yosemite end depends_on "gdm" => :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 "gdm", "restore" 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.undent 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