class Collectd < Formula desc "Statistics collection and monitoring daemon" homepage "https://collectd.org/" url "https://collectd.org/files/collectd-5.7.2.tar.bz2" sha256 "9d20a0221569a8d6b80bbc52b86e5e84965f5bafdbf5dfc3790e0fed0763e592" bottle do rebuild 1 sha256 "4d84af67aa0759b1b6d17addfe1fc818fc80a8290f396ddafbd0c299631cc9c0" => :sierra sha256 "d89fee7fc65332048b4a7ea872c73818e75e38861af8913b94c2e636dd3ab775" => :el_capitan sha256 "668edf52a197a19b8df6141b7077ff67b279dff65b803c82aaf2ff9d17619ef7" => :yosemite 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.undent 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.undent 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.undent 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