100 lines
2.9 KiB
Ruby
100 lines
2.9 KiB
Ruby
class Metricbeat < Formula
|
|
desc "Collect metrics from your systems and services"
|
|
homepage "https://www.elastic.co/beats/metricbeat"
|
|
url "https://github.com/elastic/beats.git",
|
|
tag: "v7.9.1",
|
|
revision: "ad823eca4cc74439d1a44351c596c12ab51054f5"
|
|
license "Apache-2.0"
|
|
head "https://github.com/elastic/beats.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "570c36dcef5dacb42e380566f658f10113828df1db6681a1b794c6148de308a6" => :catalina
|
|
sha256 "407a155d12f0de809832c2bf6e7130cfa974ab61f9bdf4901800584aa4770729" => :mojave
|
|
sha256 "957fa560d91a2518125d445f6eae2b1894454345e28439b3e059321671bb01a4" => :high_sierra
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "python@3.8" => :build
|
|
|
|
def install
|
|
# remove non open source files
|
|
rm_rf "x-pack"
|
|
|
|
ENV["GOPATH"] = buildpath
|
|
(buildpath/"src/github.com/elastic/beats").install buildpath.children
|
|
ENV.prepend_path "PATH", buildpath/"bin" # for mage (build tool)
|
|
|
|
cd "src/github.com/elastic/beats/metricbeat" do
|
|
# don't build docs because it would fail creating the combined OSS/x-pack
|
|
# docs and we aren't installing them anyway
|
|
inreplace "magefile.go", "mg.Deps(CollectDocs, FieldsDocs)", ""
|
|
|
|
system "make", "mage"
|
|
system "mage", "-v", "build"
|
|
ENV.deparallelize
|
|
system "mage", "-v", "update"
|
|
|
|
(etc/"metricbeat").install Dir["metricbeat.*", "fields.yml", "modules.d"]
|
|
(libexec/"bin").install "metricbeat"
|
|
prefix.install "build/kibana"
|
|
end
|
|
|
|
prefix.install_metafiles buildpath/"src/github.com/elastic/beats"
|
|
|
|
(bin/"metricbeat").write <<~EOS
|
|
#!/bin/sh
|
|
exec #{libexec}/bin/metricbeat \
|
|
--path.config #{etc}/metricbeat \
|
|
--path.data #{var}/lib/metricbeat \
|
|
--path.home #{prefix} \
|
|
--path.logs #{var}/log/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
|
|
|
|
fork do
|
|
exec bin/"metricbeat", "-path.config", testpath/"config", "-path.data",
|
|
testpath/"data"
|
|
end
|
|
|
|
sleep 30
|
|
assert_predicate testpath/"data/metricbeat", :exist?
|
|
end
|
|
end
|