Last active
February 8, 2017 16:30
-
-
Save lleirborras/333f64634c820e3824d984ab54179195 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Collectd < Formula | |
desc "Statistics collection and monitoring daemon" | |
homepage "https://collectd.org/" | |
stable do | |
url "https://collectd.org/files/collectd-5.7.1.tar.bz2" | |
sha256 "7edd3643c0842215553b2421d5456f4e9a8a58b07e216b40a7e8e91026d8e501" | |
end | |
bottle do | |
sha256 "f9adc84dbfdd0acfff4292077b58c9c496a38b4d31b83aa011caba556b2c6fd1" => :sierra | |
sha256 "8b089b6fa5bd2f6860b1fa9ec8136ab12e216d9537bf204311123fae0b04da63" => :el_capitan | |
sha256 "cf32fb80a6d26f60862fcf2fbba1eaf1c50d83d45cb6cce37178a48ec2b05e91" => :yosemite | |
end | |
head do | |
url "https://github.com/collectd/collectd.git" | |
depends_on "libtool" => :build | |
depends_on "automake" => :build | |
depends_on "autoconf" => :build | |
end | |
option "with-java", "Enable Java support" | |
option "with-python", "Enable Python support" | |
option "with-protobuf-c", "Enable write_riemann via protobuf-c support" | |
option "with-debug", "Enable debug support" | |
option "with-encryption", "Enable network encryption" | |
deprecated_option "java" => "with-java" | |
deprecated_option "debug" => "with-debug" | |
depends_on "pkg-config" => :build | |
depends_on "protobuf-c" => :optional | |
depends_on :java => :optional | |
depends_on :python => :optional | |
depends_on "libgcrypt" => :optional | |
depends_on "net-snmp" | |
fails_with :clang do | |
build 318 | |
cause <<-EOS.undent | |
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-embedded-perl" if MacOS.version <= :leopard | |
args << "--disable-java" if build.without? "java" | |
args << "--enable-python" if build.with? "python" | |
args << "--enable-write_riemann" if build.with? "protobuf-c" | |
args << "--enable-debug" if build.with? "debug" | |
args << "--with-libgcrypt" if build.with? "encryption" | |
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.undent | |
<?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 | |
begin | |
pid = fork { exec sbin/"collectd", "-f" } | |
assert shell_output("nc -u -w 2 127.0.0.1 25826", 0) | |
ensure | |
Process.kill("SIGINT", pid) | |
Process.wait(pid) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment