homebrew-core/Formula/telegraf.rb
2018-09-22 15:15:28 +02:00

77 lines
2.6 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.8.0.tar.gz"
sha256 "ae838f9d4c2db4f0b87e2735b5749972830564ccc8d33aec45d290dec706b40b"
head "https://github.com/influxdata/telegraf.git"
bottle do
cellar :any_skip_relocation
sha256 "2a187834856795b5fe7980b8bac6642a801440aae6b5b06d0cad9d554fef279d" => :mojave
sha256 "06ec5f3fa2fed274952fa5badad02a380cf95104a8a53acbe495c770a3b96ec6" => :high_sierra
sha256 "0a8cef694f2fa48e2f00436b96e63782a4e4e74e9a2ee07d376e8b5dcbfd0d39" => :sierra
sha256 "4462ad076343f7389c189598581cb4a36fba36f42d1132e56c5307a30697a315" => :el_capitan
end
depends_on "dep" => :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 "dep", "ensure", "-vendor-only"
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
<?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