homebrew-core/Formula/zabbix.rb
2018-08-30 19:07:25 +01:00

85 lines
2.7 KiB
Ruby

class Zabbix < Formula
desc "Availability and monitoring solution"
homepage "https://www.zabbix.com/"
url "https://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.12/zabbix-3.4.12.tar.gz"
sha256 "d7e55b2be8ea69921f18bc7f08bdd7d1b87c268513286f46286744bf4da729fe"
bottle do
sha256 "cfee73942d590186fff78401a1f7646e9bf8263e93f6b6afe10ec68fe01963d2" => :mojave
sha256 "ee2661a288dcdc2e7e10358bae69760e20f03edf2d315727817b3f5e5a4c3d76" => :high_sierra
sha256 "c1307762bec0de133d507c7f2d41a2b7b0eb86a78afa4f3e1c46356ef4b43179" => :sierra
sha256 "20ed369a862c1a69acd6d429cc5f1a027ddf69aa6f19ffd531de0bf6e8c5c904" => :el_capitan
end
option "with-mysql", "Use Zabbix Server with MySQL library instead PostgreSQL."
option "with-sqlite", "Use Zabbix Server with SQLite library instead PostgreSQL."
option "without-server-proxy", "Install only the Zabbix Agent without Server and Proxy."
deprecated_option "agent-only" => "without-server-proxy"
depends_on "openssl"
depends_on "pcre"
if build.with? "server-proxy"
depends_on "mysql" => :optional
depends_on "postgresql" if build.without? "mysql"
depends_on "fping"
depends_on "libevent"
depends_on "libssh2"
end
def brewed_or_shipped(db_config)
brewed_db_config = "#{HOMEBREW_PREFIX}/bin/#{db_config}"
(File.exist?(brewed_db_config) && brewed_db_config) || which(db_config)
end
def install
sdk = MacOS::CLT.installed? ? "" : MacOS.sdk_path
args = %W[
--disable-dependency-tracking
--prefix=#{prefix}
--sysconfdir=#{etc}/zabbix
--enable-agent
--with-iconv=#{sdk}/usr
--with-libpcre=#{Formula["pcre"].opt_prefix}
--with-openssl=#{Formula["openssl"].opt_prefix}
]
if build.with? "server-proxy"
args += %w[
--enable-server
--enable-proxy
--enable-ipv6
--with-net-snmp
--with-libcurl
--with-ssh2
]
if build.with? "mysql"
args << "--with-mysql=#{brewed_or_shipped("mysql_config")}"
elsif build.with? "sqlite"
args << "--with-sqlite3"
else
args << "--with-postgresql=#{brewed_or_shipped("pg_config")}"
end
end
if MacOS.version == :el_capitan && MacOS::Xcode.installed? && MacOS::Xcode.version >= "8.0"
inreplace "configure", "clock_gettime(CLOCK_REALTIME, &tp);",
"undefinedgibberish(CLOCK_REALTIME, &tp);"
end
system "./configure", *args
system "make", "install"
if build.with? "server-proxy"
db = build.with?("mysql") ? "mysql" : "postgresql"
pkgshare.install "frontends/php", "database/#{db}"
end
end
test do
system sbin/"zabbix_agentd", "--print"
end
end