homebrew-core/Formula/telegraf.rb
2017-09-19 01:02:30 +02:00

77 lines
2.5 KiB
Ruby

class Telegraf < Formula
desc "Server-level metric gathering agent for InfluxDB"
homepage "https://influxdata.com"
url "https://github.com/influxdata/telegraf/archive/1.4.0.tar.gz"
sha256 "4d6be93ef8881cfbf1cde7b1421e0cf6e998086adde16d1201df8c38b389078b"
head "https://github.com/influxdata/telegraf.git"
bottle do
cellar :any_skip_relocation
sha256 "3cdfc3b27b0cc67091409424d86878be7052dee652a1df951b1c26a2ca564e40" => :high_sierra
sha256 "8ecbd6aa60b109277cf6315fb6be45c9dd816a2d10d098f6be2350969143d843" => :sierra
sha256 "5526fc57f949d035bfda52bb5c85b9dbe67f9cac30af1501f697089d45b9c792" => :el_capitan
sha256 "67439b0e77a146c0b0e94e31265389474927a68a2b662321f6a916c852be6154" => :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
<?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>#{etc}/telegraf.conf</string>
<string>-config-directory</string>
<string>#{etc}/telegraf.d</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("#{bin}/telegraf -sample-config")
system "#{bin}/telegraf", "-config", testpath/"config.toml", "-test",
"-input-filter", "cpu:mem"
end
end