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.6.3.tar.gz" sha256 "52a4c9094287f725a089e161dc71d9cdf0caf73595e8835a5d0636d3ad333bbe" head "https://github.com/elastic/beats.git" bottle do cellar :any_skip_relocation sha256 "8b0e10adad19b779a0eaca9b54f27156e306850d1ebb00f5ee7596b22743365f" => :high_sierra sha256 "2783b43ecf5955adb13c988a01881db073d8b2c9ff3ca0dcc5aa0a72072a88a8" => :sierra sha256 "f20449c667532200439d04552e47fe389863abdc03308cc398836539fb0a1d99" => :el_capitan 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 Label #{plist_name} Program #{opt_bin}/metricbeat RunAtLoad 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_predicate testpath/"data/metricbeat", :exist? ensure Process.kill("TERM", metricbeat_pid) end end end