homebrew-core/Formula/netdata.rb

104 lines
3.5 KiB
Ruby

class Netdata < Formula
desc "Distributed real-time performance and health monitoring"
homepage "https://my-netdata.io/"
url "https://github.com/netdata/netdata/releases/download/v1.19.0/netdata-v1.19.0.tar.gz"
sha256 "36c46bd95c0d8138e2f1a886c9b9fb6a9fd22fbf9d3097420c10b868ed23e355"
bottle do
sha256 "29e1693f268bc6ecac4cf3c0deb76fbce0d5d5933d820867f29e5c77b80046a8" => :catalina
sha256 "71485353950345da2cf50e59ae04d4da2204edfb2d7017be8858a3e3f89748c8" => :mojave
sha256 "f480bf04c2425a0cab26219fab8ea21c5d02ddfaf06e737e1e72d13bc47bfee9" => :high_sierra
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "pkg-config" => :build
depends_on "json-c"
depends_on "libuv"
depends_on "lz4"
depends_on "openssl@1.1"
resource "judy" do
url "https://downloads.sourceforge.net/project/judy/judy/Judy-1.0.5/Judy-1.0.5.tar.gz"
sha256 "d2704089f85fdb6f2cd7e77be21170ced4b4375c03ef1ad4cf1075bd414a63eb"
end
def install
# We build judy as static library, so we don't need to install it
# into the real prefix
judyprefix = "#{buildpath}/resources/judy"
resource("judy").stage do
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--disable-shared", "--prefix=#{judyprefix}"
# Parallel build is broken
ENV.deparallelize do
system "make", "-j1", "install"
end
end
ENV["PREFIX"] = prefix
ENV.append "CFLAGS", "-I#{judyprefix}/include"
ENV.append "LDFLAGS", "-L#{judyprefix}/lib"
system "autoreconf", "-ivf"
system "./configure", "--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=#{prefix}",
"--sysconfdir=#{etc}",
"--localstatedir=#{var}",
"--libexecdir=#{libexec}",
"--with-math",
"--with-zlib",
"--enable-dbengine",
"--with-user=netdata",
"UUID_CFLAGS=-I/usr/include",
"UUID_LIBS=-lc"
system "make", "clean"
system "make", "install"
(etc/"netdata").install "system/netdata.conf"
end
def post_install
config = etc/"netdata/netdata.conf"
inreplace config do |s|
s.gsub!(/web files owner = .*/, "web files owner = #{ENV["USER"]}")
s.gsub!(/web files group = .*/, "web files group = #{Etc.getgrgid(prefix.stat.gid).name}")
end
(var/"netdata").mkpath
end
plist_options :manual => "#{HOMEBREW_PREFIX}/sbin/netdata -D"
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>Label</key>
<string>#{plist_name}</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>#{opt_sbin}/netdata</string>
<string>-D</string>
</array>
<key>WorkingDirectory</key>
<string>#{var}</string>
</dict>
</plist>
EOS
end
test do
system "#{sbin}/netdata", "-W", "set", "registry", "netdata unique id file",
"#{testpath}/netdata.unittest.unique.id",
"-W", "set", "registry", "netdata management api key file",
"#{testpath}/netdata.api.key",
"-W", "unittest"
end
end