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.2.tar.gz" sha256 "e0bff0c9d2ae548a9c21ee7fe2a0052c4dc630adb5a55327fa14db1a735ad1c9" bottle do cellar :any_skip_relocation sha256 "76d1f91241546592cc8dc830f52bcc950fe63cde3b6b259cef09369de08441aa" => :el_capitan sha256 "985dd1eab5fb8d0bb70cf3e025b51b245eb3271f12234761b8745e440c34e7b4" => :yosemite sha256 "55b75da3affe7a3b3aff64eb49313ff7ab68ae9c8c4ff00cda4f3f17441a628e" => :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/config.sample.toml" => "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