2011-07-19 10:07:15 +00:00
|
|
|
require 'formula'
|
|
|
|
|
|
|
|
class Nagios < Formula
|
|
|
|
homepage 'http://www.nagios.org/'
|
2013-03-30 16:26:59 +00:00
|
|
|
url 'http://downloads.sourceforge.net/project/nagios/nagios-3.x/nagios-3.5.0/nagios-3.5.0.tar.gz'
|
|
|
|
sha1 '972e76c638b7d3f15d994eaa8fce0e4907d5d6e1'
|
2011-07-19 10:07:15 +00:00
|
|
|
|
|
|
|
depends_on 'gd'
|
|
|
|
depends_on 'nagios-plugins'
|
2012-09-02 08:08:18 +00:00
|
|
|
depends_on :libpng
|
2011-07-19 10:07:15 +00:00
|
|
|
|
|
|
|
def nagios_sbin; prefix+'cgi-bin'; end
|
|
|
|
def nagios_etc; etc+'nagios'; end
|
|
|
|
def nagios_var; var+'lib/nagios'; end
|
|
|
|
def htdocs; share+'nagios/htdocs'; end
|
|
|
|
def user; `id -un`.chomp; end
|
|
|
|
def group; `id -gn`.chomp; end
|
|
|
|
|
|
|
|
def install
|
|
|
|
system "./configure", "--disable-debug",
|
|
|
|
"--disable-dependency-tracking",
|
|
|
|
"--prefix=#{prefix}",
|
|
|
|
"--sbindir=#{nagios_sbin}",
|
|
|
|
"--sysconfdir=#{nagios_etc}",
|
|
|
|
"--localstatedir=#{nagios_var}",
|
|
|
|
"--datadir=#{htdocs}",
|
2012-05-10 10:50:53 +00:00
|
|
|
"--libexecdir=#{HOMEBREW_PREFIX}/sbin", # Plugin dir
|
2011-07-19 10:07:15 +00:00
|
|
|
"--with-cgiurl=/nagios/cgi-bin",
|
|
|
|
"--with-htmurl=/nagios",
|
|
|
|
"--with-nagios-user=#{user}",
|
|
|
|
"--with-nagios-group=#{group}",
|
|
|
|
"--with-command-user=#{user}",
|
|
|
|
"--with-command-group=_www",
|
|
|
|
"--with-httpd-conf=#{share}"
|
|
|
|
system "make all"
|
|
|
|
system "make install"
|
|
|
|
|
|
|
|
# Install config
|
|
|
|
system "make install-config"
|
|
|
|
system "make install-webconf"
|
2012-09-02 08:08:18 +00:00
|
|
|
mkdir HOMEBREW_PREFIX+'var/lib/nagios/rw' unless File.exists? HOMEBREW_PREFIX+'var/lib/nagios/rw'
|
2011-07-19 10:07:15 +00:00
|
|
|
end
|
|
|
|
|
2012-12-18 05:59:01 +00:00
|
|
|
plist_options :startup => true, :manual => "nagios #{HOMEBREW_PREFIX}/etc/nagios/nagios.cfg"
|
2012-11-25 15:06:41 +00:00
|
|
|
|
|
|
|
def plist; <<-EOS.undent
|
2011-07-19 10:07:15 +00:00
|
|
|
<?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>
|
2011-12-31 05:56:52 +00:00
|
|
|
<string>#{plist_name}</string>
|
2011-07-19 10:07:15 +00:00
|
|
|
<key>ProgramArguments</key>
|
|
|
|
<array>
|
2012-11-25 15:06:41 +00:00
|
|
|
<string>#{opt_prefix}/bin/nagios</string>
|
2011-07-19 10:07:15 +00:00
|
|
|
<string>#{nagios_etc}/nagios.cfg</string>
|
|
|
|
</array>
|
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
<key>StandardErrorPath</key>
|
|
|
|
<string>/dev/null</string>
|
|
|
|
<key>StandardOutPath</key>
|
|
|
|
<string>/dev/null</string>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2012-11-25 15:06:41 +00:00
|
|
|
def caveats; <<-EOS.undent
|
2011-07-19 10:07:15 +00:00
|
|
|
First we need to create a command dir using superhuman powers:
|
|
|
|
|
|
|
|
mkdir -p #{nagios_var}/rw
|
|
|
|
sudo chgrp _www #{nagios_var}/rw
|
|
|
|
sudo chmod 2775 #{nagios_var}/rw
|
|
|
|
|
|
|
|
Then install the Nagios web frontend into Apple's build-in Apache:
|
|
|
|
|
|
|
|
1) Turn on Personal Web Sharing.
|
|
|
|
|
|
|
|
2) Load the php module by patching /etc/apache2/httpd.conf:
|
|
|
|
|
|
|
|
-#LoadModule php5_module libexec/apache2/libphp5.so
|
|
|
|
+LoadModule php5_module libexec/apache2/libphp5.so
|
|
|
|
|
|
|
|
3) Symlink the sample config and create your web account:
|
|
|
|
|
|
|
|
sudo ln -sf #{share}/nagios.conf /etc/apache2/other/
|
|
|
|
htpasswd -cs #{nagios_etc}/htpasswd.users nagiosadmin
|
|
|
|
sudo apachectl restart
|
|
|
|
|
2012-11-25 15:06:41 +00:00
|
|
|
Log in with your web account (and don't forget to RTFM :-)
|
2011-07-19 10:07:15 +00:00
|
|
|
|
|
|
|
open http://localhost/nagios
|
|
|
|
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|