homebrew-core/Formula/collectd.rb

91 lines
2.6 KiB
Ruby

class Collectd < Formula
desc "Statistics collection and monitoring daemon"
homepage "https://collectd.org/"
license "MIT"
revision 2
stable do
url "https://collectd.org/files/collectd-5.12.0.tar.bz2"
sha256 "5bae043042c19c31f77eb8464e56a01a5454e0b39fa07cf7ad0f1bfc9c3a09d6"
# Fix -flat_namespace being used on Big Sur and later.
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/03cf8088210822aa2c1ab544ed58ea04c897d9c4/libtool/configure-big_sur.diff"
sha256 "35acd6aebc19843f1a2b3a63e880baceb0f5278ab1ace661e57a502d9d78c93c"
end
end
livecheck do
url "https://collectd.org/download.shtml"
regex(/href=.*?collectd[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 arm64_monterey: "a56843d8635cca54f7b67c584147d82a3a1d1f9a2ac3306e4ff9f6c1b112f160"
sha256 arm64_big_sur: "ad251013d5579a17ec0682b23dd902d7fadd6f0f35736dd98d89c4f625f55d1e"
sha256 monterey: "d34d4f4ed54c19669a9cfbd11e8d27ace8c41c0628c2852636c5bead857e8089"
sha256 big_sur: "a81231d246349376c3e6bab9e1c7b1199645c9a8941e7339aed9fd239e4847ed"
sha256 catalina: "1f16bc2e65d7475fd67c6e286027a543e506272901f7fdac98522d3d4a664b7b"
sha256 x86_64_linux: "a2b240c5b10bb4f9b1593d9ff8b1803cbe314cc4b72c108aa845c2e686a8c0d9"
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 "bison"
uses_from_macos "flex"
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
service do
run [opt_sbin/"collectd", "-f", "-C", etc/"collectd.conf"]
keep_alive true
error_log_path var/"log/collectd.log"
log_path var/"log/collectd.log"
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