class Collectd < Formula
desc "Statistics collection and monitoring daemon"
homepage "https://collectd.org/"
url "https://collectd.org/files/collectd-5.9.0.tar.bz2"
sha256 "7b220f8898a061f6e7f29a8c16697d1a198277f813da69474a67911097c0626b"
revision 3
bottle do
rebuild 1
sha256 "bafe26077fc69f75b20fe505bf892277c8195d4e21ddba0a9f4464324d353280" => :mojave
sha256 "f7f4298b9f642212247047431a3ad61f2b2aebb4715ddd4492b8f3893a535936" => :high_sierra
sha256 "94bba540b5b976511a514cf0c55e9c8c0e6eb119a1e1416e42035b1da5710f13" => :sierra
end
head do
url "https://github.com/collectd/collectd.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
end
depends_on "pkg-config" => :build
depends_on "libgcrypt"
depends_on "libtool"
depends_on "net-snmp"
depends_on "riemann-client"
uses_from_macos "perl"
def install
args = %W[
--disable-debug
--disable-dependency-tracking
--prefix=#{prefix}
--localstatedir=#{var}
--disable-java
--enable-write_riemann
]
system "./build.sh" if build.head?
system "./configure", *args
system "make", "install"
end
plist_options :manual => "#{HOMEBREW_PREFIX}/sbin/collectd -f -C #{HOMEBREW_PREFIX}/etc/collectd.conf"
def plist; <<~EOS
KeepAlive
Label
#{plist_name}
ProgramArguments
#{sbin}/collectd
-f
-C
#{etc}/collectd.conf
RunAtLoad
StandardErrorPath
#{var}/log/collectd.log
StandardOutPath
#{var}/log/collectd.log
EOS
end
test do
log = testpath/"collectd.log"
(testpath/"collectd.conf").write <<~EOS
LoadPlugin logfile
File "#{log}"
LoadPlugin memory
EOS
begin
pid = fork { exec sbin/"collectd", "-f", "-C", "collectd.conf" }
sleep 1
assert_predicate log, :exist?, "Failed to create log file"
assert_match "plugin \"memory\" successfully loaded.", log.read
ensure
Process.kill("SIGINT", pid)
Process.wait(pid)
end
end
end