homebrew-core/Formula/telegraf.rb
2015-11-19 01:02:46 +00:00

75 lines
2.3 KiB
Ruby

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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/telegraf</string>
<string>-config</string>
<string>#{HOMEBREW_PREFIX}/etc/telegraf.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{var}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/telegraf.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/telegraf.log</string>
</dict>
</plist>
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