source: trunk/dports/net/nagios/Portfile

Last change on this file was 152600, checked in by mps@…, 12 months ago

nagios: update to version 4.2.1.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.6 KB
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
2# $Id: Portfile 152600 2016-09-12 21:34:12Z ryandesign@macports.org $
3
4PortSystem  1.0
5
6name            nagios
7version         4.2.1
8categories      net
9license         GPL-2
10maintainers     nomaintainer
11platforms       darwin
12
13description     Nagios is a host and service monitoring program
14
15long_description    A network service and host monitor that can notify you \
16            when servers go down by monitoring for external services \
17            such as HTTP, FTP, SMTP, SNMP, as well as internal host \
18            checks for things such as CPU and disk usage and many \
19            other things.
20
21homepage        http://nagios.org
22
23livecheck.regex     nagios-(\[0-9.\]+)${extract.suffix}
24
25master_sites        sourceforge:project/nagios/nagios-4.x/nagios-${version}
26checksums       rmd160 ae6eed1681bfff139dc3197d37c4aa5b46ef09b5 \
27                sha256 cb62c5c16964cfc143b126a576a7f8130e634cb9dda4dd3bd3632598d7855a87
28
29depends_build       port:gd2
30depends_lib         path:lib/libssl.dylib:openssl \
31                    port:nagios-plugins
32
33set sysconfdir      ${prefix}/etc/${name}
34destroot.destdir    prefix=${prefix} DESTDIR=${destroot}
35
36destroot.target     install install-config install-commandmode install-init
37
38configure.args      --with-cgiurl=/nagios/cgi-bin \
39            --with-htmurl=/nagios \
40            --with-nagios-user=nagios \
41            --with-nagios-grp=nagios \
42            --with-command-grp=nagios \
43            --with-gd-lib=${prefix}/lib \
44            --with-gd-inc=${prefix}/include \
45            --sbindir=${prefix}/sbin/nagios \
46            --libexecdir=${prefix}/libexec/nagios \
47            --datadir=${prefix}/share/nagios \
48            --with-lockfile=${prefix}/var/nagios/nagios.lock \
49            --with-init-dir=${prefix}/var/nagios \
50            --sysconfdir=${sysconfdir} \
51            --localstatedir=${prefix}/var/nagios \
52            --with-httpd-conf=/etc/apache2/httpd.conf
53
54platform darwin 8 {
55    configure.args-delete --with-httpd-conf=/etc/apache2/httpd.conf
56    configure.args-append --with-httpd-conf=/etc/httpd/httpd.conf
57}
58
59startupitem.create      yes
60startupitem.start       "${prefix}/var/nagios/nagios.init start"
61startupitem.stop        "${prefix}/var/nagios/nagios.init stop"
62
63post-patch {
64        reinplace "s|INIT_OPTS=-o root -g root|INIT_OPTS=-o nagios -g nagios|g" \
65                "${worksrcpath}/Makefile.in"
66
67    reinplace "s|daemon-init \$(DESTDIR)\$(INIT_DIR)/nagios|daemon-init \$(DESTDIR)\$(INIT_DIR)/nagios.init|g" \
68        "${worksrcpath}/Makefile.in"
69
70    reinplace "s|NagiosLockDir=/var/lock/subsys|NagiosLockDir=${prefix}/var/nagios|g" \
71        ${worksrcpath}/daemon-init.in
72    reinplace "s|su -|su -m|g" \
73        ${worksrcpath}/daemon-init.in
74}
75
76add_users nagios group=nagios
77
78post-destroot {
79# Keep the empty command file directory created by 'make install-commandmode'
80        destroot.keepdirs ${destroot}${prefix}/var/nagios/rw
81
82# Nagios sample files no longer install with -sample suffixes, so do this manually for safety
83    foreach cfgfile [glob ${destroot}${sysconfdir}/*.cfg] {
84        file rename ${cfgfile} ${cfgfile}-sample
85    }
86    foreach cfgfile [glob ${destroot}${sysconfdir}/objects/*.cfg] {
87        file rename ${cfgfile} ${cfgfile}-sample
88    }
89}
90
91
92notes "
93************************************************************
94The basic steps to complete the installation are below.  But Nagios is\
95a complex program so you should read the documentation online at\
96http://www.nagios.org or locally at ${prefix}/share/nagios/docs/index.html\
97to fully understand Nagios.
98************************************************************
99
100IMPORTANT: A user and group called 'nagios' has been created and you must run\
101       nagios as that user.
102
103
104
1051) Setup Apache's httpd.conf file for Nagios (restart Apache when done)
106
107   Insert the \"Nagios stuff\" text block somewhere *above* your Apache cgi-bin\
108   ScriptAlias statement:
109
110    ScriptAlias /cgi-bin/ \"/Library/WebServer/CGI-Executables/\"
111
112#
113# Nagios stuff
114
115ScriptAlias /nagios/cgi-bin/ \"${prefix}/sbin/nagios/\"
116<Directory \"${prefix}/sbin/nagios\">
117 AllowOverride None
118    Options ExecCGI
119    Order allow,deny
120    Allow from all
121    AuthName \"Nagios Access\"
122    AuthType Basic
123    AuthUserFile ${prefix}/etc/nagios/htpasswd.users
124    require valid-user
125</Directory>
126
127Alias /nagios \"${prefix}/share/nagios\"
128<Directory \"${prefix}/share/nagios\">
129    Options None
130    AllowOverride AuthConfig
131    Order allow,deny
132    Allow from all
133</Directory>
134
135# End Nagios stuff
136#
137
138
1392) Configure the Nagios sample files in ${prefix}/etc/nagios.
140
141a) First, backup the Nagios sample files.
142
143   cd ${prefix}/etc/nagios
144   sudo mkdir sample
145   sudo cp *.cfg-sample sample/
146
147b) Then rename the sample files for use.
148
149   sudo -s
150   for i in *cfg-sample; do mv \$i `echo \$i | sed -e s/cfg-sample/cfg/`; done;
151   exit
152
153c) Configure the default commands.cfg file to your requirements.  Then test\
154   the Nagios configuration with this command until you get no errors:
155
156   sudo nagios -v ${prefix}/etc/nagios/nagios.cfg
157
158
1593) Set user 'nagiosadmin' as a \"superuser\" to browse all hosts/services in
160   ${prefix}/etc/nagios/cgi.cfg
161
162   authorized_for_system_information= nagiosadmin
163   authorized_for_configuration_information= nagiosadmin
164   authorized_for_system_commands= nagiosadmin
165   authorized_for_all_services= nagiosadmin
166   authorized_for_all_hosts= nagiosadmin
167   authorized_for_all_service_commands= nagiosadmin
168   authorized_for_all_host_commands= nagiosadmin
169
170
1714) Create a 'nagiosadmin' Apache user/password to correspond with the Nagios Apache\
172   user created above
173
174    htpasswd -c ${prefix}/etc/nagios/htpasswd.users nagiosadmin
175
176   Create other users as desired, omit '-c' since it creates the password file.  Make\
177   additional users login names match Nagios contact names to restrict web viewing to your\
178   host's by contact.
179
180
1815) Set Nagios to start at system boot, and start Nagios
182
183   Run launchctl so Nagios will start at system boot
184    sudo launchctl load -w /Library/LaunchDaemons/org.macports.nagios.plist
185
186   You may now start Nagios manually with this command (or a reboot):
187    sudo ${prefix}/var/nagios/nagios.init start
188
189
1906) You may now login as 'nagiosadmin' to the Nagios web interface at http://localhost/nagios
191
192
193NOTE: The SMTP server Postfix is required to enable Nagios email notifications
194
195
196File Locations:
197
198    Configuration files: ${prefix}/etc/nagios
199    Nagios plugins: ${prefix}/libexec/nagios
200    Lock file:  ${prefix}/var/nagios/nagios.lock
201    Init file:  ${prefix}/var/nagios/nagios.init
202    HTML URL:  http://localhost/nagios/
203    CGI URL:  http://localhost/nagios/cgi-bin/
204"
Note: See TracBrowser for help on using the repository browser.