class Collectd < Formula desc "Statistics collection and monitoring daemon" homepage "https://collectd.org/" url "https://collectd.org/files/collectd-5.8.0.tar.bz2" sha256 "b06ff476bbf05533cb97ae6749262cc3c76c9969f032bd8496690084ddeb15c9" bottle do sha256 "c228054cab6171395cf7fc0aae7baa020743514a41dd374e668d4d9440675e7f" => :high_sierra sha256 "e49db6c81c43d172e13ced53c61175afb5bcd3f14121e501c4a111267ad014ae" => :sierra sha256 "5bad0992c7a9022f3b083a8d127d6cd7aa9f024b4aec6f5edc21a8dac3115324" => :el_capitan end head do url "https://github.com/collectd/collectd.git" depends_on "automake" => :build depends_on "autoconf" => :build end option "with-java", "Enable Java support" option "with-python", "Enable Python support" option "with-riemann-client", "Enable write_riemann support" option "with-debug", "Enable debug support" deprecated_option "java" => "with-java" deprecated_option "debug" => "with-debug" depends_on "pkg-config" => :build depends_on "libtool" => :run depends_on "riemann-client" => :optional depends_on :java => :optional depends_on :python => :optional depends_on "net-snmp" fails_with :clang do build 318 cause <<~EOS Clang interacts poorly with the collectd-bundled libltdl, causing configure to fail. EOS end def install args = %W[ --disable-debug --disable-dependency-tracking --prefix=#{prefix} --localstatedir=#{var} ] args << "--disable-java" if build.without? "java" args << "--enable-python" if build.with? "python" args << "--enable-write_riemann" if build.with? "riemann-client" args << "--enable-debug" if build.with? "debug" 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