75 lines
2.5 KiB
Ruby
75 lines
2.5 KiB
Ruby
class Telegraf < Formula
|
|
desc "Server-level metric gathering agent for InfluxDB"
|
|
homepage "https://www.influxdata.com/"
|
|
url "https://github.com/influxdata/telegraf/archive/v1.17.3.tar.gz"
|
|
sha256 "fea0a44a0dbbe9a506e695b41ffbbc065cf78acfa5b10d9da0678ce43340b238"
|
|
license "MIT"
|
|
head "https://github.com/influxdata/telegraf.git"
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^v?(\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "2e274b39110c9cec062d724e00531043bc2ed2f1a9990c9722ef3e2653a7e352"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "0895ff4a3277b65b34d9da6ffacf3363d0c5ca5f60fae84ba60b07d867d651d2"
|
|
sha256 cellar: :any_skip_relocation, catalina: "8217c64da0084d8a4e741e157f33f576e40c3c9e26c738f54bd6ba0cf00a56ad"
|
|
sha256 cellar: :any_skip_relocation, mojave: "387c98576c1b705e296057eb555d489feaa6865042c85e22eb682a577891be1a"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
system "go", "build", *std_go_args, "-ldflags", "-X main.version=#{version}", "./cmd/telegraf"
|
|
etc.install "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
|