91 lines
2.5 KiB
Ruby
91 lines
2.5 KiB
Ruby
class Metricbeat < Formula
|
|
desc "Collect metrics from your systems and services"
|
|
homepage "https://www.elastic.co/products/beats/metricbeat"
|
|
url "https://github.com/elastic/beats/archive/v6.1.2.tar.gz"
|
|
sha256 "e673b4f03bc73807d23083b8d6a5f45f5a8b3fa3a6709f89881a2debb10a8d2f"
|
|
|
|
head "https://github.com/elastic/beats.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "7e2b21967fab90120256a96960be3b8635ded5030c03fe7ae2b45f8eec242896" => :high_sierra
|
|
sha256 "03156298d3ed0e2259f39a4d79df5bcf4256e81fe8ed61f41f06e61f15689ff3" => :sierra
|
|
sha256 "484d7d1937f6607ac168de94783e242596c132181c2ebe57b4477e1ef7fdf6cb" => :el_capitan
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ENV["GOPATH"] = buildpath
|
|
(buildpath/"src/github.com/elastic/beats").install buildpath.children
|
|
|
|
cd "src/github.com/elastic/beats/metricbeat" do
|
|
system "make"
|
|
system "make", "kibana"
|
|
(libexec/"bin").install "metricbeat"
|
|
libexec.install "_meta/kibana"
|
|
|
|
(etc/"metricbeat").install Dir["metricbeat*.yml"]
|
|
prefix.install_metafiles
|
|
end
|
|
|
|
(bin/"metricbeat").write <<~EOS
|
|
#!/bin/sh
|
|
exec "#{libexec}/bin/metricbeat" \
|
|
--path.config "#{etc}/metricbeat" \
|
|
--path.home="#{prefix}" \
|
|
--path.logs="#{var}/log/metricbeat" \
|
|
--path.data="#{var}/lib/metricbeat" \
|
|
"$@"
|
|
EOS
|
|
end
|
|
|
|
plist_options :manual => "metricbeat"
|
|
|
|
def plist; <<~EOS
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//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>Program</key>
|
|
<string>#{opt_bin}/metricbeat</string>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
(testpath/"config/metricbeat.yml").write <<~EOS
|
|
metricbeat.modules:
|
|
- module: system
|
|
metricsets: ["load"]
|
|
period: 1s
|
|
output.file:
|
|
enabled: true
|
|
path: #{testpath}/data
|
|
filename: metricbeat
|
|
EOS
|
|
|
|
(testpath/"logs").mkpath
|
|
(testpath/"data").mkpath
|
|
|
|
pid = fork do
|
|
exec bin/"metricbeat", "-path.config", testpath/"config", "-path.data",
|
|
testpath/"data"
|
|
end
|
|
|
|
begin
|
|
sleep 30
|
|
assert_predicate testpath/"data/metricbeat", :exist?
|
|
ensure
|
|
Process.kill "SIGINT", pid
|
|
Process.wait pid
|
|
end
|
|
end
|
|
end
|