76 lines
2.5 KiB
Ruby
76 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.6.2.tar.gz"
|
|
sha256 "93cc548f336a8e0750055e137458c9950e4d5f6e59b2cbf9da492e5c58977240"
|
|
head "https://github.com/influxdata/telegraf.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "6a52e1f1a5c990a3a1dd2438ca433500629c2845334841920e5f0bb3b59e48c0" => :high_sierra
|
|
sha256 "6555f0ecd8529ddb904342cc4f00522b2f5494a2c9e2b874b23c0dbf2d48ba8a" => :sierra
|
|
sha256 "4d48caa19da9c786606c03f32db64041590a093ce08aba8470ef84d950fb6570" => :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
|
|
<?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
|