class Telegraf < Formula desc "Server-level metric gathering agent for InfluxDB" homepage "https://influxdata.com" url "https://github.com/influxdata/telegraf/archive/1.3.0.tar.gz" sha256 "f0d27903bac178026bcdeabf1bfc2df5f441842c9368cd7792ffa2015077e46e" head "https://github.com/influxdata/telegraf.git" bottle do cellar :any_skip_relocation sha256 "bd8e1aa9a22d3d652cf8a12cec5d9082b6360df07440262988dc4147a38e4aaf" => :sierra sha256 "cd87d7b5c2edfcd0b95e600a232831de3709cfa52227d78a8f4d85f83cf42ec5" => :el_capitan sha256 "4c6d62b198934604cb00324e51b35cf7192e7b897baae6a40a2573d2ff909719" => :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