homebrew-core/Formula/netdata.rb

113 lines
3.7 KiB
Ruby

class Netdata < Formula
desc "Diagnose infrastructure problems with metrics, visualizations & alarms"
homepage "https://netdata.cloud/"
url "https://github.com/netdata/netdata/releases/download/v1.26.0/netdata-v1.26.0.tar.gz"
sha256 "33af27eb57f954e50059a32bec624815aa742fe03182845b1d9b577f1e20e30a"
license "GPL-3.0-or-later"
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 "bd2e4c457cb565f03c632527ac62eef558bf54ea770a06bd06a4c53a100d043f" => :catalina
sha256 "e2a1165f6dcabb048cc8298213b5ea2b212fb393ab19e24245b6403edb128764" => :mojave
sha256 "0e27a3c39108a37709aaaf549b57bbb1d4726f31e2abfdb5f0ba73432bbcc849" => :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/"cache/netdata/unittest-dbengine/dbengine").mkpath
(var/"lib/netdata/registry").mkpath
(var/"log/netdata").mkpath
(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"
end
end