class Telegraf < Formula desc "Server-level metric gathering agent for InfluxDB" homepage "https://influxdata.com" url "https://github.com/influxdata/telegraf/archive/1.6.4.tar.gz" sha256 "0813d5e87a4eb21098306a4839cdb24d263ea07b9e9954eeb4ae956269c085c9" head "https://github.com/influxdata/telegraf.git" bottle do cellar :any_skip_relocation sha256 "b0b6f3071dc8db966d23afc08373af004b4df03ca9054d6e75a27059b6696922" => :high_sierra sha256 "77de161d23723801151fc004c4c9192407aafa096f14cf9ec3f031ce9d8a26e1" => :sierra sha256 "a64c007eac29b32be2aecf077ca2680345b77ae5edb49d5e0c1df31785ec95ae" => :el_capitan 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 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