class Collectd < Formula desc "Statistics collection and monitoring daemon" homepage "https://collectd.org/" url "https://collectd.org/files/collectd-5.9.2.tar.bz2" sha256 "dfcb2a2fa7de0ab02c9e6c1457bee2069957d4ffc9b428851661e9c5e5fc35b7" bottle do sha256 "4c4b4c34332287378e9b7f5fb4bd4a64b95716371c4aa90de9af3c31b992aeff" => :catalina sha256 "ca86a75db509fffc8f70ce9e3b4bfe56dab5c7458955dcab91fbea615310cb50" => :mojave sha256 "359ed8272530b34be21aee41b17b9ac93c65ccab30a6f8a11df19cda33089cd7" => :high_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