111 lines
3.3 KiB
Ruby
111 lines
3.3 KiB
Ruby
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 "cb0615484d4cc2ecf3fd47679a94b9b0ab35e6075206e6887253d328d2749840" => :high_sierra
|
|
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
|
|
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
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>KeepAlive</key>
|
|
<true/>
|
|
<key>Label</key>
|
|
<string>#{plist_name}</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>#{sbin}/collectd</string>
|
|
<string>-f</string>
|
|
<string>-C</string>
|
|
<string>#{etc}/collectd.conf</string>
|
|
</array>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>StandardErrorPath</key>
|
|
<string>#{var}/log/collectd.log</string>
|
|
<key>StandardOutPath</key>
|
|
<string>#{var}/log/collectd.log</string>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
log = testpath/"collectd.log"
|
|
(testpath/"collectd.conf").write <<~EOS
|
|
LoadPlugin logfile
|
|
<Plugin logfile>
|
|
File "#{log}"
|
|
</Plugin>
|
|
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
|