Ticket #43008: patch-nagios-Portfile3.diff

File patch-nagios-Portfile3.diff, 12.6 KB (added by jul_bsd@…, 10 years ago)
  • net/nagios/Portfile

    old new  
    1 # $Id: Portfile 125738 2014-09-25 14:43:03Z mf2k@macports.org $
     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
     2# $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             nomaintainer
    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.8
     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  b53631755e0a23aba918a99f58b7bea237fdd799 \
     24                    sha256  8b268d250c97851775abe162f46f64724f95f367d752ae4630280cc5d368ca4b
     25
     26livecheck.regex     nagios-(\[0-9.\]+)${extract.suffix}
     27
     28depends_build       port:gd2
     29depends_lib         port:openssl port:nagios-plugins
     30
     31## Only for 4.0.8: https://github.com/NagiosEnterprises/nagioscore/commit/859d45bc59c2a1a22cc40bb2562b36ca3b89a8c6
     32patchfiles          patch-lib-runcmd.c.diff
     33
     34set sysconfdir      ${prefix}/etc/${name}
     35destroot.destdir    prefix=${prefix} DESTDIR=${destroot}
     36
     37destroot.target     install install-config install-commandmode install-init
     38destroot.asroot     yes
     39install.asroot      yes
     40
     41## iobroker: http://tracker.nagios.org/view.php?id=484
     42#            --with-iobroker=select => not compiling (default: poll)
     43configure.args      --with-cgiurl=/nagios/cgi-bin \
     44                    --with-htmurl=/nagios \
     45                    --with-nagios-user=nagios \
     46                    --with-nagios-grp=nagios \
     47                    --with-command-grp=nagios \
     48                    --with-gd-lib=${prefix}/lib \
     49                    --with-gd-inc=${prefix}/include \
     50                    --sbindir=${prefix}/sbin/nagios \
     51                    --libexecdir=${prefix}/libexec/nagios \
     52                    --datadir=${prefix}/share/nagios \
     53                    --with-lockfile=${prefix}/var/nagios/nagios.lock \
     54                    --with-init-dir=${prefix}/var/nagios \
     55                    --sysconfdir=${sysconfdir} \
     56                    --localstatedir=${prefix}/var/nagios \
     57                    --with-httpd-conf=/etc/apache2/httpd.conf
    5558
    5659platform darwin 8 {
    57         configure.args-delete --with-httpd-conf=/etc/apache2/httpd.conf
    58         configure.args-append --with-httpd-conf=/etc/httpd/httpd.conf
     60    configure.args-delete --with-httpd-conf=/etc/apache2/httpd.conf
     61    configure.args-append --with-httpd-conf=/etc/httpd/httpd.conf
    5962}
    6063
    61 startupitem.create      yes
    62 startupitem.start       "${prefix}/var/nagios/nagios.init start"
    63 startupitem.stop        "${prefix}/var/nagios/nagios.init stop"
     64startupitem.create  yes
     65## Note: why using a linux chkconfig file???
     66#startupitem.start  "${prefix}/var/nagios/nagios.init start"
     67#startupitem.stop   "${prefix}/var/nagios/nagios.init stop"
     68startupitem.executable ${prefix}/bin/nagios ${prefix}/etc/nagios/nagios.cfg
     69startupitem.pidfile ${prefix}/var/nagios/nagios.lock
    6470
    6571post-patch {
    6672        reinplace "s|INIT_OPTS=-o root -g root|INIT_OPTS=-o nagios -g nagios|g" \
    6773                "${worksrcpath}/Makefile.in"
    6874
    69         reinplace "s|daemon-init \$(DESTDIR)\$(INIT_DIR)/nagios|daemon-init \$(DESTDIR)\$(INIT_DIR)/nagios.init|g" \
    70                 "${worksrcpath}/Makefile.in"
     75    reinplace "s|daemon-init \$(DESTDIR)\$(INIT_DIR)/nagios|daemon-init \$(DESTDIR)\$(INIT_DIR)/nagios.init|g" \
     76        "${worksrcpath}/Makefile.in"
    7177
    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
     78    reinplace "s|NagiosLockDir=/var/lock/subsys|NagiosLockDir=${prefix}/var/nagios|g" \
     79        ${worksrcpath}/daemon-init.in
     80    reinplace "s|su -|su -m|g" \
     81        ${worksrcpath}/daemon-init.in
    7682}
    7783
    7884add_users nagios group=nagios
    7985
    8086post-destroot {
    8187# Keep the empty command file directory created by 'make install-commandmode'
    82         destroot.keepdirs ${destroot}${prefix}/var/nagios/rw
     88        destroot.keepdirs ${destroot}${prefix}/var/nagios/rw \
     89            ${destroot}${prefix}/var/${name}/spool/checkresults
    8390
    8491# 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         }
     92    foreach cfgfile [glob ${destroot}${sysconfdir}/*.cfg] {
     93        file rename ${cfgfile} ${cfgfile}-sample
     94    }
     95    foreach cfgfile [glob ${destroot}${sysconfdir}/objects/*.cfg] {
     96        file rename ${cfgfile} ${cfgfile}-sample
     97    }
     98
     99    xinstall -d ${destroot}${prefix}/share/examples/${name}/
     100    copy ${filespath}/apache-nagios.conf ${destroot}${prefix}/share/examples/${name}/
     101    copy ${filespath}/nginx-nagios.conf ${destroot}${prefix}/share/examples/${name}/
     102    reinplace "s|%%PREFIX%%|${prefix}|g" \
     103        ${destroot}${prefix}/share/examples/${name}/apache-nagios.conf \
     104        ${destroot}${prefix}/share/examples/${name}/nginx-nagios.conf
     105    xinstall -d ${destroot}${prefix}/var/${name}/spool/checkresults
    91106}
    92107
    93108
     
    100115************************************************************
    101116
    102117IMPORTANT: A user and group called 'nagios' has been created and you must run\
    103            nagios as that user.
     118       nagios as that user.
    104119
    105120
    106 
    107 1) Setup Apache's httpd.conf file for Nagios (restart Apache when done)
     1211) Setup your webserver
     122  a) Apache's httpd.conf file for Nagios (restart Apache when done)
     123     Example configuration in ${prefix}/share/examples/${name}/apache-nagios.conf
    108124
    109125   Insert the \"Nagios stuff\" text block somewhere *above* your Apache cgi-bin\
    110126   ScriptAlias statement:
    111127
    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>
     128    ScriptAlias /cgi-bin/ \"/Library/WebServer/CGI-Executables/\"
    136129
    137 # End Nagios stuff
    138 #
     130   (is it only relevant to Apple Apache or also macports?)
    139131
     132  b) Nginx w php*-fpm and fcgiwrap
     133     Example configuration in ${prefix}/share/examples/${name}/nginx-nagios.conf
     134     Configured for localhost:8081
     135         http://localhost:8081/
    140136
    1411372) Configure the Nagios sample files in ${prefix}/etc/nagios.
    142138
     
    152148   for i in *cfg-sample; do mv \$i `echo \$i | sed -e s/cfg-sample/cfg/`; done;
    153149   exit
    154150
    155 c) Configure the default commands.cfg file to your requirements.  Then test\
     151c) Configure at least the default commands.cfg and contacts.cfg  files to your \
     152   requirements.  Then test\
    156153   the Nagios configuration with this command until you get no errors:
    157154
    158155   sudo nagios -v ${prefix}/etc/nagios/nagios.cfg
     
    160157
    1611583) Set user 'nagiosadmin' as a \"superuser\" to browse all hosts/services in
    162159   ${prefix}/etc/nagios/cgi.cfg
     160   (default configuration)
    163161
    164162   authorized_for_system_information= nagiosadmin
    165163   authorized_for_configuration_information= nagiosadmin
     
    1731714) Create a 'nagiosadmin' Apache user/password to correspond with the Nagios Apache\
    174172   user created above
    175173
    176         htpasswd -c ${prefix}/etc/nagios/htpasswd.users nagiosadmin
     174    htpasswd -c ${prefix}/etc/nagios/htpasswd.users nagiosadmin
    177175
    178176   Create other users as desired, omit '-c' since it creates the password file.  Make\
    179177   additional users login names match Nagios contact names to restrict web viewing to your\
     
    1831815) Set Nagios to start at system boot, and start Nagios
    184182
    185183   Run launchctl so Nagios will start at system boot
    186         sudo launchctl load -w /Library/LaunchDaemons/org.macports.nagios.plist
     184    sudo launchctl load -w /Library/LaunchDaemons/org.macports.nagios.plist
    187185
    188186   You may now start Nagios manually with this command (or a reboot):
    189         sudo ${prefix}/var/nagios/nagios.init start
     187    sudo ${prefix}/var/nagios/nagios.init start
    190188
    191189
    1921906) You may now login as 'nagiosadmin' to the Nagios web interface at http://localhost/nagios
    193191
     1927) You can monitor nagios itself with the following commands
     193       # ${prefix}/libexec/nagios/check_nagios -t 20 -e 5 -F ${prefix}/var/nagios/nagios.log -C nagios    (NOK: Abort trap: 6)
     194       # nagiostats
     195   As input for mrtg
     196       # nagiostats --mrtg
     197   Non-official input to cacti
     198       http://forums.cacti.net/viewtopic.php?f=12&t=33806&p=221089
     199       http://forums.cacti.net/viewtopic.php?f=12&t=34834
     200       http://forums.cacti.net/viewtopic.php?f=12&t=17729
     201
    194202
    195203NOTE: The SMTP server Postfix is required to enable Nagios email notifications
    196204
    197205
    198206File Locations:
    199207
    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/
     208    Configuration files: ${prefix}/etc/nagios
     209    Nagios plugins: ${prefix}/libexec/nagios
     210    Lock file:  ${prefix}/var/nagios/nagios.lock
     211     Init file:  ${prefix}/var/nagios/nagios.init
     212    HTML URL:  http://localhost/nagios/
     213    CGI URL:  http://localhost/nagios/cgi-bin/
     214
    206215"
     216
     217subport ${name}3 {
     218    version             3.5.1
     219    master_sites        sourceforge:project/nagios/nagios-3.x/nagios-${version}
     220    checksums           rmd160  0ce5693a745f617c9fbf627f18af27b793de884d \
     221                        sha256  ca9dd68234fa090b3c35ecc8767b2c9eb743977eaf32612fa9b8341cc00a0f99
     222    worksrcdir          ${name}
     223
     224    conflicts ${name}
     225
     226}
     227
     228## FIXME! universal: lot of "Undefined symbols for architecture x86_64:"
     229variant universal {}
     230#build.args          CFLAGS="${configure.cflags} [get_canonical_archflags cc]"
     231configure.cflags-append          "${configure.cflags} [get_canonical_archflags cc]"
     232
     233variant nagvis description { nagvis visualization addon } {
     234    set n_version       1.7
     235    set n_version_minor 10
     236    master_sites        sourceforge:projects/nagvis/files/NagVis ${n_version}/:nagvis
     237    distfiles           nagvis-${n_version}.${n_version_minor}${extract.suffix}:nagvis
     238    ## http://docs.nagvis.org/1.7/en_US/index.html
     239}