2016-10-31 12:46:15 +00:00
|
|
|
class Metricbeat < Formula
|
|
|
|
desc "Collect metrics from your systems and services."
|
|
|
|
homepage "https://www.elastic.co/products/beats/metricbeat"
|
2016-11-15 19:07:02 +00:00
|
|
|
url "https://github.com/elastic/beats/archive/v5.0.1.tar.gz"
|
|
|
|
sha256 "707bea8d8eb8cc358bddfcaffa5e90da2a09fab00f2fc53608cc013c79743117"
|
2016-10-31 12:46:15 +00:00
|
|
|
|
|
|
|
head "https://github.com/elastic/beats.git"
|
|
|
|
|
2016-10-31 18:24:13 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any_skip_relocation
|
2016-11-15 21:57:46 +00:00
|
|
|
sha256 "c6bfea943e2261364534eae6f0b87c8ddfbff19d0e6e968961e17d94137e2490" => :sierra
|
|
|
|
sha256 "c98b135d8baca56ed1120ef3d33e60454074cf69b80d423b4529cdce4745ec25" => :el_capitan
|
|
|
|
sha256 "68e76b095d2bbf69944ae8fc7d7e6468490c1c1d96b06a7304268dfdf9f38510" => :yosemite
|
2016-10-31 18:24:13 +00:00
|
|
|
end
|
|
|
|
|
2016-10-31 12:46:15 +00:00
|
|
|
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.yml"
|
|
|
|
(etc/"metricbeat").install "metricbeat.template.json"
|
|
|
|
(etc/"metricbeat").install "metricbeat.template-es2x.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
|