Ticket #43008: patch-nagios-Portfile2.diff
File patch-nagios-Portfile2.diff, 12.4 KB (added by jul_bsd@…, 10 years ago) |
---|
-
net/nagios/Portfile
old new 1 # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 1 2 # $Id: Portfile 109427 2013-08-15 13:11:47Z ryandesign@macports.org $ 2 3 3 PortSystem 4 PortSystem 1.0 4 5 5 name nagios 6 version 3.5.0 7 revision 2 8 categories net 9 license GPL-2 10 maintainers markd openmaintainer 11 platforms darwin 12 13 description Nagios is a host and service monitoring program 14 15 long_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 21 homepage http://nagios.org 22 23 livecheck.regex nagios-(\[0-9.\]+)${extract.suffix} 24 25 master_sites sourceforge:project/nagios/nagios-3.x/nagios-${version} 26 checksums rmd160 d75a764486fd3dc0462fb49924698754852d39be \ 27 sha256 469381b2954392689c85d3db733e8da4bd43b806b3d661d1a7fbd52dacc084db 28 29 worksrcdir ${name} 30 31 depends_build port:gd2 32 depends_lib port:openssl \ 33 port:nagios-plugins 34 35 set sysconfdir ${prefix}/etc/${name} 36 destroot.destdir prefix=${prefix} DESTDIR=${destroot} 37 38 destroot.target install install-config install-commandmode install-init 39 40 configure.args --with-cgiurl=/nagios/cgi-bin \ 41 --with-htmurl=/nagios \ 42 --with-nagios-user=nagios \ 43 --with-nagios-grp=nagios \ 44 --with-command-grp=nagios \ 45 --with-gd-lib=${prefix}/lib \ 46 --with-gd-inc=${prefix}/include \ 47 --sbindir=${prefix}/sbin/nagios \ 48 --libexecdir=${prefix}/libexec/nagios \ 49 --datadir=${prefix}/share/nagios \ 50 --with-lockfile=${prefix}/var/nagios/nagios.lock \ 51 --with-init-dir=${prefix}/var/nagios \ 52 --sysconfdir=${sysconfdir} \ 53 --localstatedir=${prefix}/var/nagios \ 54 --with-httpd-conf=/etc/apache2/httpd.conf 6 name nagios 7 version 4.0.7 8 categories net 9 license GPL-2 10 maintainers markd openmaintainer 11 platforms darwin 12 13 description Nagios is a host and service monitoring program 14 15 long_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 21 homepage http://nagios.org 22 master_sites sourceforge:project/nagios/nagios-4.x/nagios-${version} 23 checksums rmd160 deb4278a478e8d58e38bc84a3691945a52bc89af \ 24 sha256 ef1de1d106f6572a88547f3ed37a744c5d4fa778859ce44fc9043da597c50799 25 26 livecheck.regex nagios-(\[0-9.\]+)${extract.suffix} 27 28 depends_build port:gd2 29 depends_lib port:openssl port:nagios-plugins 30 31 set sysconfdir ${prefix}/etc/${name} 32 destroot.destdir prefix=${prefix} DESTDIR=${destroot} 33 34 destroot.target install install-config install-commandmode install-init 35 destroot.asroot yes 36 install.asroot yes 37 38 ## iobroker: http://tracker.nagios.org/view.php?id=484 39 # --with-iobroker=select => not compiling (default: poll) 40 configure.args --with-cgiurl=/nagios/cgi-bin \ 41 --with-htmurl=/nagios \ 42 --with-nagios-user=nagios \ 43 --with-nagios-grp=nagios \ 44 --with-command-grp=nagios \ 45 --with-gd-lib=${prefix}/lib \ 46 --with-gd-inc=${prefix}/include \ 47 --sbindir=${prefix}/sbin/nagios \ 48 --libexecdir=${prefix}/libexec/nagios \ 49 --datadir=${prefix}/share/nagios \ 50 --with-lockfile=${prefix}/var/nagios/nagios.lock \ 51 --with-init-dir=${prefix}/var/nagios \ 52 --sysconfdir=${sysconfdir} \ 53 --localstatedir=${prefix}/var/nagios \ 54 --with-httpd-conf=/etc/apache2/httpd.conf 55 55 56 56 platform darwin 8 { 57 58 57 configure.args-delete --with-httpd-conf=/etc/apache2/httpd.conf 58 configure.args-append --with-httpd-conf=/etc/httpd/httpd.conf 59 59 } 60 60 61 startupitem.create yes 62 startupitem.start "${prefix}/var/nagios/nagios.init start" 63 startupitem.stop "${prefix}/var/nagios/nagios.init stop" 61 startupitem.create yes 62 ## Note: why using a linux chkconfig file??? 63 #startupitem.start "${prefix}/var/nagios/nagios.init start" 64 #startupitem.stop "${prefix}/var/nagios/nagios.init stop" 65 startupitem.executable ${prefix}/bin/nagios ${prefix}/etc/nagios/nagios.cfg 66 startupitem.pidfile ${prefix}/var/nagios/nagios.lock 64 67 65 68 post-patch { 66 69 reinplace "s|INIT_OPTS=-o root -g root|INIT_OPTS=-o nagios -g nagios|g" \ 67 70 "${worksrcpath}/Makefile.in" 68 71 69 70 72 reinplace "s|daemon-init \$(DESTDIR)\$(INIT_DIR)/nagios|daemon-init \$(DESTDIR)\$(INIT_DIR)/nagios.init|g" \ 73 "${worksrcpath}/Makefile.in" 71 74 72 73 74 75 75 reinplace "s|NagiosLockDir=/var/lock/subsys|NagiosLockDir=${prefix}/var/nagios|g" \ 76 ${worksrcpath}/daemon-init.in 77 reinplace "s|su -|su -m|g" \ 78 ${worksrcpath}/daemon-init.in 76 79 } 77 80 78 81 add_users nagios group=nagios 79 82 80 83 post-destroot { 81 84 # Keep the empty command file directory created by 'make install-commandmode' 82 destroot.keepdirs ${destroot}${prefix}/var/nagios/rw 85 destroot.keepdirs ${destroot}${prefix}/var/nagios/rw \ 86 ${destroot}${prefix}/var/${name}/spool/checkresults 83 87 84 88 # Nagios sample files no longer install with -sample suffixes, so do this manually for safety 85 foreach cfgfile [glob ${destroot}${sysconfdir}/*.cfg] { 86 file rename ${cfgfile} ${cfgfile}-sample 87 } 88 foreach cfgfile [glob ${destroot}${sysconfdir}/objects/*.cfg] { 89 file rename ${cfgfile} ${cfgfile}-sample 90 } 89 foreach cfgfile [glob ${destroot}${sysconfdir}/*.cfg] { 90 file rename ${cfgfile} ${cfgfile}-sample 91 } 92 foreach cfgfile [glob ${destroot}${sysconfdir}/objects/*.cfg] { 93 file rename ${cfgfile} ${cfgfile}-sample 94 } 95 96 xinstall -d ${destroot}${prefix}/share/examples/${name}/ 97 copy ${filespath}/apache-nagios.conf ${destroot}${prefix}/share/examples/${name}/ 98 copy ${filespath}/nginx-nagios.conf ${destroot}${prefix}/share/examples/${name}/ 99 reinplace "s|%%PREFIX%%|${prefix}|g" \ 100 ${destroot}${prefix}/share/examples/${name}/apache-nagios.conf \ 101 ${destroot}${prefix}/share/examples/${name}/nginx-nagios.conf 102 xinstall -d ${destroot}${prefix}/var/${name}/spool/checkresults 91 103 } 92 104 93 105 … … 100 112 ************************************************************ 101 113 102 114 IMPORTANT: A user and group called 'nagios' has been created and you must run\ 103 115 nagios as that user. 104 116 105 117 106 107 1) Setup Apache's httpd.conf file for Nagios (restart Apache when done) 118 1) Setup your webserver 119 a) Apache's httpd.conf file for Nagios (restart Apache when done) 120 Example configuration in ${prefix}/share/examples/${name}/apache-nagios.conf 108 121 109 122 Insert the \"Nagios stuff\" text block somewhere *above* your Apache cgi-bin\ 110 123 ScriptAlias statement: 111 124 112 ScriptAlias /cgi-bin/ \"/Library/WebServer/CGI-Executables/\" 113 114 # 115 # Nagios stuff 116 117 ScriptAlias /nagios/cgi-bin/ \"${prefix}/sbin/nagios/\" 118 <Directory \"${prefix}/sbin/nagios\"> 119 AllowOverride None 120 Options ExecCGI 121 Order allow,deny 122 Allow from all 123 AuthName \"Nagios Access\" 124 AuthType Basic 125 AuthUserFile ${prefix}/etc/nagios/htpasswd.users 126 require valid-user 127 </Directory> 128 129 Alias /nagios \"${prefix}/share/nagios\" 130 <Directory \"${prefix}/share/nagios\"> 131 Options None 132 AllowOverride AuthConfig 133 Order allow,deny 134 Allow from all 135 </Directory> 125 ScriptAlias /cgi-bin/ \"/Library/WebServer/CGI-Executables/\" 136 126 137 # End Nagios stuff 138 # 127 (is it only relevant to Apple Apache or also macports?) 139 128 129 b) Nginx w php*-fpm and fcgiwrap 130 Example configuration in ${prefix}/share/examples/${name}/nginx-nagios.conf 131 Configured for localhost:8081 132 http://localhost:8081/ 140 133 141 134 2) Configure the Nagios sample files in ${prefix}/etc/nagios. 142 135 … … 152 145 for i in *cfg-sample; do mv \$i `echo \$i | sed -e s/cfg-sample/cfg/`; done; 153 146 exit 154 147 155 c) Configure the default commands.cfg file to your requirements. Then test\ 148 c) Configure at least the default commands.cfg and contacts.cfg files to your \ 149 requirements. Then test\ 156 150 the Nagios configuration with this command until you get no errors: 157 151 158 152 sudo nagios -v ${prefix}/etc/nagios/nagios.cfg … … 160 154 161 155 3) Set user 'nagiosadmin' as a \"superuser\" to browse all hosts/services in 162 156 ${prefix}/etc/nagios/cgi.cfg 157 (default configuration) 163 158 164 159 authorized_for_system_information= nagiosadmin 165 160 authorized_for_configuration_information= nagiosadmin … … 173 168 4) Create a 'nagiosadmin' Apache user/password to correspond with the Nagios Apache\ 174 169 user created above 175 170 176 171 htpasswd -c ${prefix}/etc/nagios/htpasswd.users nagiosadmin 177 172 178 173 Create other users as desired, omit '-c' since it creates the password file. Make\ 179 174 additional users login names match Nagios contact names to restrict web viewing to your\ … … 183 178 5) Set Nagios to start at system boot, and start Nagios 184 179 185 180 Run launchctl so Nagios will start at system boot 186 181 sudo launchctl load -w /Library/LaunchDaemons/org.macports.nagios.plist 187 182 188 183 You may now start Nagios manually with this command (or a reboot): 189 184 sudo ${prefix}/var/nagios/nagios.init start 190 185 191 186 192 187 6) You may now login as 'nagiosadmin' to the Nagios web interface at http://localhost/nagios 193 188 189 7) You can monitor nagios itself with the following commands 190 # ${prefix}/libexec/nagios/check_nagios -t 20 -e 5 -F ${prefix}/var/nagios/nagios.log -C nagios (NOK: Abort trap: 6) 191 # nagiostats 192 As input for mrtg 193 # nagiostats --mrtg 194 Non-official input to cacti 195 http://forums.cacti.net/viewtopic.php?f=12&t=33806&p=221089 196 http://forums.cacti.net/viewtopic.php?f=12&t=34834 197 http://forums.cacti.net/viewtopic.php?f=12&t=17729 198 194 199 195 200 NOTE: The SMTP server Postfix is required to enable Nagios email notifications 196 201 197 202 198 203 File Locations: 199 204 200 Configuration files: ${prefix}/etc/nagios 201 Nagios plugins: ${prefix}/libexec/nagios 202 Lock file: ${prefix}/var/nagios/nagios.lock 203 Init file: ${prefix}/var/nagios/nagios.init 204 HTML URL: http://localhost/nagios/ 205 CGI URL: http://localhost/nagios/cgi-bin/ 205 Configuration files: ${prefix}/etc/nagios 206 Nagios plugins: ${prefix}/libexec/nagios 207 Lock file: ${prefix}/var/nagios/nagios.lock 208 Init file: ${prefix}/var/nagios/nagios.init 209 HTML URL: http://localhost/nagios/ 210 CGI URL: http://localhost/nagios/cgi-bin/ 211 206 212 " 213 214 subport ${name}3 { 215 version 3.5.1 216 master_sites sourceforge:project/nagios/nagios-3.x/nagios-${version} 217 checksums rmd160 0ce5693a745f617c9fbf627f18af27b793de884d \ 218 sha256 ca9dd68234fa090b3c35ecc8767b2c9eb743977eaf32612fa9b8341cc00a0f99 219 worksrcdir ${name} 220 221 conflicts ${name} 222 223 } 224 225 ## FIXME! universal: lot of "Undefined symbols for architecture x86_64:" 226 variant universal {} 227 #build.args CFLAGS="${configure.cflags} [get_canonical_archflags cc]" 228 configure.cflags-append "${configure.cflags} [get_canonical_archflags cc]" 229 230 variant nagvis description { nagvis visualization addon } { 231 set n_version 1.7 232 set n_version_minor 10 233 master_sites sourceforge:projects/nagvis/files/NagVis ${n_version}/:nagvis 234 distfiles nagvis-${n_version}.${n_version_minor}${extract.suffix}:nagvis 235 ## http://docs.nagvis.org/1.7/en_US/index.html 236 }