require "language/go" class Telegraf < Formula desc "Server-level metric gathering agent for InfluxDB" homepage "https://influxdb.com" url "https://github.com/influxdb/telegraf/archive/v0.2.3.tar.gz" sha256 "b6891b5f310232e47461b780a1151afed942438e323c44b77496a885fa6fea86" bottle do cellar :any_skip_relocation sha256 "c26df3331a29c4104c397f0233055ec64cac03be964e32a68a059bc9a5563e78" => :el_capitan sha256 "67fc5b3b22d843a467a521807a158ada5ff9f90b2cda7e54ce62ebcdd0c1de9e" => :yosemite sha256 "d52224210126cfe21c0f5185d34eb7987f6fdfd713f6a3da98990a4dfd32c7a0" => :mavericks end depends_on "go" => :build depends_on "godep" => :build def install ENV["GOPATH"] = buildpath telegraf_path = buildpath/"src/github.com/influxdb/telegraf" telegraf_path.install Dir["*"] Language::Go.stage_deps resources, buildpath/"src" cd telegraf_path do system "godep", "go", "build", "-o", "telegraf", "-ldflags", "-X main.Version=#{version}", "cmd/telegraf/telegraf.go" end bin.install telegraf_path/"telegraf" etc.install telegraf_path/"etc/telegraf.conf" => "telegraf.conf" 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 #{HOMEBREW_PREFIX}/etc/telegraf.conf RunAtLoad WorkingDirectory #{var} StandardErrorPath #{var}/log/telegraf.log StandardOutPath #{var}/log/telegraf.log EOS end test do (testpath/"config.toml").write shell_output("telegraf -sample-config") system "telegraf", "-config", testpath/"config.toml", "-test", "-filter", "cpu:mem" end end