class Telegraf < Formula desc "Server-level metric gathering agent for InfluxDB" homepage "https://influxdata.com" url "https://github.com/influxdata/telegraf/archive/1.3.2.tar.gz" sha256 "21e5ae7f61564c1251931cb731bb6be52445609ebf724ac1ea65d95bf856b9d9" head "https://github.com/influxdata/telegraf.git" bottle do cellar :any_skip_relocation sha256 "551403e7ed860ee12f9687b265dd31f646fd84fbb2c355e1e2778478a85c7135" => :sierra sha256 "d992cb8f5c7c9091df7c5d48b22d13409d031823c76d835d3752cd5cf40cd1fb" => :el_capitan sha256 "0552f518b735c7b99c21a3053d6a3ac59d896274ff351ecabf2323754795691c" => :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