homebrew-core/Formula/collectd.rb

91 lines
2.9 KiB
Ruby

class Collectd < Formula
desc "Statistics collection and monitoring daemon"
homepage "https://collectd.org/"
license "MIT"
revision 5
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_ventura: "17ef602f303744b198fa038d7b7aea63147e4da61d756614d7765aed9b8c1e16"
sha256 arm64_monterey: "dcc3153be48b21d9ed70ad1f73a4ef3e85f4d0a05df1a66f740837b98812f4f4"
sha256 arm64_big_sur: "9b6ef1f192b583587b38842eeb4487472cc120ab113884af1badd94d7f81d718"
sha256 ventura: "b43512984ffee809d62ae814d028b6eb838675da3f2a9d2c0209bec4d7718c1f"
sha256 monterey: "fa6fb93745bfa378667bf760f47dfbdca543979b51e354921639a3e279cb3139"
sha256 big_sur: "722677e0ee31b375470ec75e6bfe40c67ea6e57549eb918e40a0a5a8861984db"
sha256 catalina: "52ee6f9dceeda3c68fbb3f12c585d5725dfdfd7815a6bfcf866ac72d00d884e8"
sha256 x86_64_linux: "11b0e03c4fbf06b9f467d7bb98427a8e0e0a9efc70c376a7c766afce668f4909"
end
head do
url "https://github.com/collectd/collectd.git", branch: "main"
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" => :build
uses_from_macos "flex" => :build
uses_from_macos "perl"
def install
args = std_configure_args + %W[
--localstatedir=#{var}
--disable-java
--enable-write_riemann
]
args << "--with-perl-bindings=PREFIX=#{prefix} INSTALLSITEMAN3DIR=#{man3}" if OS.linux?
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