homebrew-core/Formula/metricbeat.rb
2017-06-21 07:21:21 -07:00

88 lines
2.6 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/v5.4.2.tar.gz"
sha256 "6a02dffae1b09bc7e2ea673268124bab43c012e8a3b400f53e26c156448f2a99"
revision 1
head "https://github.com/elastic/beats.git"
bottle do
cellar :any_skip_relocation
sha256 "4c5ba2c82ea7359a39889acfd3c4b1451da04a0199d261744d4be0d4de6cb528" => :sierra
sha256 "d0ed35ec5a30a4918148b1837dd2c27543ad3949889d727cd6a913a5f0e77c0c" => :el_capitan
sha256 "855c37f530231b145d671e7599c316b0ae1a1351b61f6fcd3ddb4566a99851a1" => :yosemite
end
depends_on "go" => :build
def install
gopath = buildpath/"gopath"
(gopath/"src/github.com/elastic/beats").install Dir["{*,.git,.gitignore}"]
ENV["GOPATH"] = gopath
cd gopath/"src/github.com/elastic/beats/metricbeat" do
system "make"
libexec.install "metricbeat"
(etc/"metricbeat").install "metricbeat.full.yml"
(etc/"metricbeat").install "metricbeat.yml"
(etc/"metricbeat").install "metricbeat.template.json"
(etc/"metricbeat").install "metricbeat.template-es2x.json"
(etc/"metricbeat").install "metricbeat.template-es6x.json"
end
(bin/"metricbeat").write <<-EOS.undent
#!/bin/sh
exec "#{libexec}/metricbeat" --path.config "#{etc}/metricbeat" --path.home="#{prefix}" --path.logs="#{var}/log/metricbeat" --path.data="#{opt_prefix}" "$@"
EOS
end
plist_options :manual => "metricbeat"
def plist; <<-EOS.undent
<?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/"metricbeat.yml").write <<-EOS.undent
metricbeat.modules:
- module: system
metricsets: ["load"]
period: 1s
output.file:
enabled: true
path: #{testpath}/data
filename: metricbeat
EOS
(testpath/"logs").mkpath
(testpath/"data").mkpath
metricbeat_pid = fork do
exec bin/"metricbeat", "-c", testpath/"metricbeat.yml",
"--path.data=#{testpath}/data", "--path.logs=#{testpath}/logs"
end
begin
sleep 2
assert File.exist? testpath/"data/metricbeat"
ensure
Process.kill("TERM", metricbeat_pid)
end
end
end