117 lines
3.7 KiB
Ruby
117 lines
3.7 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.git",
|
|
:tag => "v6.8.4",
|
|
:revision => "fa5b03454e25d60fbcd857a5839d16db59507b82"
|
|
head "https://github.com/elastic/beats.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "05cdf380a57e9b976c66cd8f629f378eb934b8813a7b65b3394a7fa8056e9d06" => :catalina
|
|
sha256 "41396f8f2996398b9dcae3fa1020f6ccbe1eef750b88b5bdb3d449acd6414b79" => :mojave
|
|
sha256 "80580cc7b97af0844e783d0466f92d42f3612ee0af2e8562e6e22728d802d4a3" => :high_sierra
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "python@2" => :build # does not support Python 3
|
|
|
|
resource "virtualenv" do
|
|
url "https://files.pythonhosted.org/packages/8b/f4/360aa656ddb0f4168aeaa1057d8784b95d1ce12f34332c1cf52420b6db4e/virtualenv-16.3.0.tar.gz"
|
|
sha256 "729f0bcab430e4ef137646805b5b1d8efbb43fe53d4a0f33328624a84a5121f7"
|
|
end
|
|
|
|
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_create_path "PYTHONPATH", buildpath/"vendor/lib/python2.7/site-packages"
|
|
|
|
resource("virtualenv").stage do
|
|
system "python", *Language::Python.setup_install_args(buildpath/"vendor")
|
|
end
|
|
|
|
ENV.prepend_path "PATH", buildpath/"vendor/bin" # for virtualenv
|
|
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 "Makefile", "collect: assets collect-docs configs kibana imports",
|
|
"collect: assets configs kibana imports"
|
|
|
|
system "make", "mage"
|
|
# prevent downloading binary wheels during python setup
|
|
system "make", "PIP_INSTALL_COMMANDS=--no-binary :all", "python-env"
|
|
system "mage", "-v", "build"
|
|
system "mage", "-v", "update"
|
|
|
|
(etc/"metricbeat").install Dir["metricbeat.*", "fields.yml", "modules.d"]
|
|
(libexec/"bin").install "metricbeat"
|
|
prefix.install "_meta/kibana.generated"
|
|
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
|
|
|
|
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
|