jackett 0.22.1382
[Homebrew/homebrew-core.git] / Formula / c / collectd.rb
blobcbc12614d1ec66dacdce4cfa82cca81e04c11908
1 class Collectd < Formula
2   desc "Statistics collection and monitoring daemon"
3   homepage "https://collectd.org/"
4   license "MIT"
5   revision 8
7   stable do
8     url "https://storage.googleapis.com/collectd-tarballs/collectd-5.12.0.tar.bz2"
9     sha256 "5bae043042c19c31f77eb8464e56a01a5454e0b39fa07cf7ad0f1bfc9c3a09d6"
11     # Fix -flat_namespace being used on Big Sur and later.
12     patch do
13       url "https://raw.githubusercontent.com/Homebrew/formula-patches/03cf8088210822aa2c1ab544ed58ea04c897d9c4/libtool/configure-big_sur.diff"
14       sha256 "35acd6aebc19843f1a2b3a63e880baceb0f5278ab1ace661e57a502d9d78c93c"
15     end
16   end
18   livecheck do
19     url "https://www.collectd.org/download.html"
20     regex(/href=.*?collectd[._-]v?(\d+(?:\.\d+)+)\.t/i)
21   end
23   bottle do
24     sha256 arm64_sequoia: "58f7a44814b1a467e4f68fcf719069fe352920ce6e800fc5d60e8ad2e6af1332"
25     sha256 arm64_sonoma:  "ceb6cf730de48b1f6eadfc3784060f0b6ed437c3a4fcb7f991e75853eb0d8295"
26     sha256 arm64_ventura: "756fa1c1b080652bc6654718c11f5955b1a674b319eb848609e0416415a0cde1"
27     sha256 sonoma:        "74e6ebaf66605da54399207a4f083833b39a90f6ff9edb92c82673f874af5e09"
28     sha256 ventura:       "cea97da9e5ba92d5d02fb688cc72bf698f245e5d849f44f2d3419f64f1ed5000"
29     sha256 x86_64_linux:  "5e73f288cbe0d9d1bd8e35b1782593ab8ef268d41bd05e34913bc63678d926d1"
30   end
32   head do
33     url "https://github.com/collectd/collectd.git", branch: "main"
35     depends_on "autoconf" => :build
36     depends_on "automake" => :build
37   end
39   depends_on "pkgconf" => :build
40   depends_on "libgcrypt"
41   depends_on "libtool"
42   depends_on "net-snmp"
43   depends_on "protobuf-c"
44   depends_on "riemann-client"
46   uses_from_macos "bison" => :build
47   uses_from_macos "flex" => :build
48   uses_from_macos "perl"
50   on_macos do
51     depends_on "libgpg-error"
52   end
54   def install
55     # Workaround for: Built-in generator --c_out specifies a maximum edition
56     # PROTO3 which is not the protoc maximum 2023.
57     # Remove when fixed in `protobuf-c`:
58     # https://github.com/protobuf-c/protobuf-c/pull/711
59     ENV["PROTOC_C"] = Formula["protobuf"].opt_bin/"protoc"
61     args = %W[
62       --localstatedir=#{var}
63       --disable-java
64       --enable-write_riemann
65     ]
66     args << "--with-perl-bindings=PREFIX=#{prefix} INSTALLSITEMAN3DIR=#{man3}" if OS.linux?
68     system "./build.sh" if build.head?
69     system "./configure", *args, *std_configure_args
70     system "make", "install"
71   end
73   service do
74     run [opt_sbin/"collectd", "-f", "-C", etc/"collectd.conf"]
75     keep_alive true
76     error_log_path var/"log/collectd.log"
77     log_path var/"log/collectd.log"
78   end
80   test do
81     log = testpath/"collectd.log"
82     (testpath/"collectd.conf").write <<~EOS
83       LoadPlugin logfile
84       <Plugin logfile>
85         File "#{log}"
86       </Plugin>
87       LoadPlugin memory
88     EOS
89     begin
90       pid = fork { exec sbin/"collectd", "-f", "-C", "collectd.conf" }
91       sleep 3
92       assert_predicate log, :exist?, "Failed to create log file"
93       assert_match "plugin \"memory\" successfully loaded.", log.read
94     ensure
95       Process.kill("SIGINT", pid)
96       Process.wait(pid)
97     end
98   end
99 end