90 lines
2.5 KiB
Ruby
90 lines
2.5 KiB
Ruby
class Collectd < Formula
|
|
desc "Statistics collection and monitoring daemon"
|
|
homepage "https://collectd.org/"
|
|
url "https://collectd.org/files/collectd-5.10.0.tar.bz2"
|
|
sha256 "a03359f563023e744c2dc743008a00a848f4cd506e072621d86b6d8313c0375b"
|
|
|
|
bottle do
|
|
sha256 "e4e99e92982ca679cfdb4c01db692f0961ec1fb1f7cccc0101943df30184cf14" => :catalina
|
|
sha256 "da20e601f3f5249a92d3ac31ae9a7024c37fb55c4b7281ad36b1b86414b320d2" => :mojave
|
|
sha256 "48947ba55bbfb0ef454c00098b60e3410edeae569a44752e409462792d5fd927" => :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
|
|
<?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
|