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
    12# $Id: Portfile 109427 2013-08-15 13:11:47Z ryandesign@macports.org $
    23
    3 PortSystem      1.0
     4PortSystem         1.0
    45
    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
     6name               nagios
     7version            4.0.7
     8categories         net
     9license            GPL-2
     10maintainers        markd openmaintainer
     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
     22master_sites        sourceforge:project/nagios/nagios-4.x/nagios-${version}
     23checksums           rmd160  deb4278a478e8d58e38bc84a3691945a52bc89af \
     24                    sha256  ef1de1d106f6572a88547f3ed37a744c5d4fa778859ce44fc9043da597c50799
     25
     26livecheck.regex     nagios-(\[0-9.\]+)${extract.suffix}
     27
     28depends_build       port:gd2
     29depends_lib         port:openssl port:nagios-plugins
     30
     31set sysconfdir      ${prefix}/etc/${name}
     32destroot.destdir    prefix=${prefix} DESTDIR=${destroot}
     33
     34destroot.target     install install-config install-commandmode install-init
     35destroot.asroot     yes
     36install.asroot      yes
     37
     38## iobroker: http://tracker.nagios.org/view.php?id=484
     39#            --with-iobroker=select => not compiling (default: poll)
     40configure.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
    5555
    5656platform darwin 8 {
    57         configure.args-delete --with-httpd-conf=/etc/apache2/httpd.conf
    58         configure.args-append --with-httpd-conf=/etc/httpd/httpd.conf
     57    configure.args-delete --with-httpd-conf=/etc/apache2/httpd.conf
     58    configure.args-append --with-httpd-conf=/etc/httpd/httpd.conf
    5959}
    6060
    61 startupitem.create      yes
    62 startupitem.start       "${prefix}/var/nagios/nagios.init start"
    63 startupitem.stop        "${prefix}/var/nagios/nagios.init stop"
     61startupitem.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"
     65startupitem.executable ${prefix}/bin/nagios ${prefix}/etc/nagios/nagios.cfg
     66startupitem.pidfile ${prefix}/var/nagios/nagios.lock
    6467
    6568post-patch {
    6669        reinplace "s|INIT_OPTS=-o root -g root|INIT_OPTS=-o nagios -g nagios|g" \
    6770                "${worksrcpath}/Makefile.in"
    6871
    69         reinplace "s|daemon-init \$(DESTDIR)\$(INIT_DIR)/nagios|daemon-init \$(DESTDIR)\$(INIT_DIR)/nagios.init|g" \
    70                 "${worksrcpath}/Makefile.in"
     72    reinplace "s|daemon-init \$(DESTDIR)\$(INIT_DIR)/nagios|daemon-init \$(DESTDIR)\$(INIT_DIR)/nagios.init|g" \
     73        "${worksrcpath}/Makefile.in"
    7174
    72         reinplace "s|NagiosLockDir=/var/lock/subsys|NagiosLockDir=${prefix}/var/nagios|g" \
    73                 ${worksrcpath}/daemon-init.in
    74         reinplace "s|su -|su -m|g" \
    75                 ${worksrcpath}/daemon-init.in
     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
    7679}
    7780
    7881add_users nagios group=nagios
    7982
    8083post-destroot {
    8184# 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
    8387
    8488# 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
    91103}
    92104
    93105
     
    100112************************************************************
    101113
    102114IMPORTANT: A user and group called 'nagios' has been created and you must run\
    103            nagios as that user.
     115       nagios as that user.
    104116
    105117
    106 
    107 1) Setup Apache's httpd.conf file for Nagios (restart Apache when done)
     1181) 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
    108121
    109122   Insert the \"Nagios stuff\" text block somewhere *above* your Apache cgi-bin\
    110123   ScriptAlias statement:
    111124
    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/\"
    136126
    137 # End Nagios stuff
    138 #
     127   (is it only relevant to Apple Apache or also macports?)
    139128
     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/
    140133
    1411342) Configure the Nagios sample files in ${prefix}/etc/nagios.
    142135
     
    152145   for i in *cfg-sample; do mv \$i `echo \$i | sed -e s/cfg-sample/cfg/`; done;
    153146   exit
    154147
    155 c) Configure the default commands.cfg file to your requirements.  Then test\
     148c) Configure at least the default commands.cfg and contacts.cfg  files to your \
     149   requirements.  Then test\
    156150   the Nagios configuration with this command until you get no errors:
    157151
    158152   sudo nagios -v ${prefix}/etc/nagios/nagios.cfg
     
    160154
    1611553) Set user 'nagiosadmin' as a \"superuser\" to browse all hosts/services in
    162156   ${prefix}/etc/nagios/cgi.cfg
     157   (default configuration)
    163158
    164159   authorized_for_system_information= nagiosadmin
    165160   authorized_for_configuration_information= nagiosadmin
     
    1731684) Create a 'nagiosadmin' Apache user/password to correspond with the Nagios Apache\
    174169   user created above
    175170
    176         htpasswd -c ${prefix}/etc/nagios/htpasswd.users nagiosadmin
     171    htpasswd -c ${prefix}/etc/nagios/htpasswd.users nagiosadmin
    177172
    178173   Create other users as desired, omit '-c' since it creates the password file.  Make\
    179174   additional users login names match Nagios contact names to restrict web viewing to your\
     
    1831785) Set Nagios to start at system boot, and start Nagios
    184179
    185180   Run launchctl so Nagios will start at system boot
    186         sudo launchctl load -w /Library/LaunchDaemons/org.macports.nagios.plist
     181    sudo launchctl load -w /Library/LaunchDaemons/org.macports.nagios.plist
    187182
    188183   You may now start Nagios manually with this command (or a reboot):
    189         sudo ${prefix}/var/nagios/nagios.init start
     184    sudo ${prefix}/var/nagios/nagios.init start
    190185
    191186
    1921876) You may now login as 'nagiosadmin' to the Nagios web interface at http://localhost/nagios
    193188
     1897) 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
    194199
    195200NOTE: The SMTP server Postfix is required to enable Nagios email notifications
    196201
    197202
    198203File Locations:
    199204
    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
    206212"
     213
     214subport ${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:"
     226variant universal {}
     227#build.args          CFLAGS="${configure.cflags} [get_canonical_archflags cc]"
     228configure.cflags-append          "${configure.cflags} [get_canonical_archflags cc]"
     229
     230variant 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}