78 lines
2.6 KiB
Ruby
78 lines
2.6 KiB
Ruby
class NodeExporter < Formula
|
|
desc "Prometheus exporter for machine metrics"
|
|
homepage "https://prometheus.io/"
|
|
url "https://github.com/prometheus/node_exporter/archive/v0.16.0.tar.gz"
|
|
sha256 "2ed1c1c199e047b1524b49a6662d5969936e81520d6613b8b68cc3effda450cf"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "18aec98484b6171e130b362cb4fdf061ae556889b5a4d0f5e54590bed772d40f" => :mojave
|
|
sha256 "73a63fee885b246f401e3bb5f2ba2ef151a0d445d2c5be3480eb5ad7e34c5150" => :high_sierra
|
|
sha256 "a2f81f31c72150cff3ce0442ae63e783b4c8d9ea6b04cce353caed36f373c464" => :sierra
|
|
sha256 "43917856258a8a777b2632921070b002853b266438495320ca20d5eda6a95809" => :el_capitan
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ENV["GOPATH"] = buildpath
|
|
(buildpath/"src/github.com/prometheus").mkpath
|
|
ln_s buildpath, "src/github.com/prometheus/node_exporter"
|
|
system "go", "build", "-o", bin/"node_exporter", "-ldflags",
|
|
"-X github.com/prometheus/node_exporter/vendor/github.com/prometheus/common/version.Version=#{version}",
|
|
"github.com/prometheus/node_exporter"
|
|
end
|
|
|
|
def caveats; <<~EOS
|
|
When used with `brew services`, node_exporter's configuration is stored as command line flags in
|
|
#{etc}/node_exporter.args
|
|
|
|
Example configuration:
|
|
echo --web.listen-address :9101 > #{etc}/node_exporter.args
|
|
|
|
For the full list of options, execute
|
|
node_exporter -h
|
|
EOS
|
|
end
|
|
|
|
plist_options :manual => "node_exporter"
|
|
|
|
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>Label</key>
|
|
<string>#{plist_name}</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>sh</string>
|
|
<string>-c</string>
|
|
<string>#{opt_bin}/node_exporter $(< #{etc}/node_exporter.args)</string>
|
|
</array>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>KeepAlive</key>
|
|
<false/>
|
|
<key>StandardErrorPath</key>
|
|
<string>#{var}/log/node_exporter.err.log</string>
|
|
<key>StandardOutPath</key>
|
|
<string>#{var}/log/node_exporter.log</string>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
output = shell_output("#{bin}/node_exporter --version 2>&1")
|
|
assert_match version.to_s, output
|
|
begin
|
|
pid = fork { exec bin/"node_exporter" }
|
|
sleep 2
|
|
assert_match "# HELP", shell_output("curl -s localhost:9100/metrics")
|
|
ensure
|
|
Process.kill("SIGINT", pid)
|
|
Process.wait(pid)
|
|
end
|
|
end
|
|
end
|