Search
j0ke.net Open Build Service
>
Projects
>
home:netmax
>
nagios
> Changes
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
Changes of Revision 7
[-]
[+]
Added
nagios.spec
@@ -0,0 +1,454 @@ +%define name nagios +%define version 2.10 +%define release 1 +%define nsusr nagios +%define nsgrp nagios +%define cmdgrp nagiocmd +%define wwwusr wwwrun +%define wwwgrp www + +# Performance data handling method to use. By default we will use +# the file-based one (as existed in NetSaint). +# You can select the external command based method (the defaut for +# Nagios) by specifying +# --define 'PERF_EXTERNAL 1' +# in the rpm command-line +%{!?PERF_EXTERNAL: %define PERF_EXTERNAL 0} + +# Embedded Perl stuff, specify +# --define 'EMBPERL 1' +# in the rpm command-line to enable it +%{!?EMBPERL: %define EMBPERL 0} + +# Macro that print mesages to syslog at package (un)install time +%define nnmmsg logger -t %{name}/rpm + +Summary: Host/service/network monitoring program +Name: %{name} +Version: %{version} +Release: %{release} +License: GPL +Group: Application/System +Source0: %{name}-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-buildroot +Prefix: %{_prefix} +Prefix: /etc/init.d +Prefix: /etc/nagios +Prefix: /var/log/nagios +Prefix: /var/spool/nagios +Requires: gd > 1.8 zlib libpng libjpeg bash grep +PreReq: /bin/logger, sed, mktemp +BuildRequires: gd-devel > 1.8 zlib-devel libpng-devel libjpeg-devel glibc-devel libgcc gcc gcc-c++ perl +%if 0%{?fedora_version} == 7 +BuildRequires: perl-ExtUtils-MakeMaker +%endif + +%description +Nagios is a program that will monitor hosts and services on your +network. It has the ability to email or page you when a problem arises +and when a problem is resolved. Nagios is written in C and is +designed to run under Linux (and some other *NIX variants) as a +background process, intermittently running checks on various services +that you specify. + +The actual service checks are performed by separate "plugin" programs +which return the status of the checks to Nagios. The plugins are +available at http://sourceforge.net/projects/nagiosplug + +This package provide core programs for nagios. The web interface, +documentation, and development files are built as separate packages + + +%package www +Group: Application/System +Summary: Provides the HTML and CGI files for the Nagios web interface. +Requires: %{name} = %{version} +Requires: http_daemon + + +%description www +Nagios is a program that will monitor hosts and services on your +network. It has the ability to email or page you when a problem arises +and when a problem is resolved. Nagios is written in C and is +designed to run under Linux (and some other *NIX variants) as a +background process, intermittently running checks on various services +that you specify. + +Several CGI programs are included with Nagios in order to allow you +to view the current service status, problem history, notification +history, and log file via the web. This package provides the HTML and +CGI files for the Nagios web interface. In addition, HTML +documentation is included in this package + + +%package devel +Group: Application/System +Summary: Provides include files that Nagios-related applications may compile against. +Requires: %{name} = %{version} + +%description devel +Nagios is a program that will monitor hosts and services on your +network. It has the ability to email or page you when a problem arises +and when a problem is resolved. Nagios is written in C and is +designed to run under Linux (and some other *NIX variants) as a +background process, intermittently running checks on various services +that you specify. + +This package provides include files that Nagios-related applications +may compile against. + + +%prep +%setup -q + + +%pre +# Create `nagios' user on the system if necessary +if /usr/bin/id %{nsusr} > /dev/null 2>&1 ; then + : # user already exists +else + /usr/sbin/useradd -r -d /var/log/nagios -s /bin/sh -c "%{nsusr}" %{nsusr} || \ + %nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process. +fi + +# id cannot tell us if the group already exists +# so just try to create it and assume it works +/usr/sbin/groupadd %{nsgrp} > /dev/null 2>&1 +/usr/sbin/groupadd %{cmdgrp} > /dev/null 2>&1 + +# if LSB standard /etc/init.d does not exist, +# create it as a symlink to the first match we find +if [ -d /etc/init.d -o -L /etc/init.d ]; then + : # we're done +elif [ -d /etc/rc.d/init.d ]; then + ln -s /etc/rc.d/init.d /etc/init.d +elif [ -d /usr/local/etc/rc.d ]; then + ln -s /usr/local/etc/rc.d /etc/init.d +elif [ -d /sbin/init.d ]; then + ln -s /sbin/init.d /etc/init.d +fi + + +%preun +if [ "$1" = 0 ]; then + /sbin/service nagios stop > /dev/null 2>&1 + /sbin/chkconfig --del nagios +fi + +%postun +if [ "$1" -ge "1" ]; then + /sbin/service nagios condrestart >/dev/null 2>&1 || : +fi +# Delete nagios user and group +# (if grep doesn't find a match, then it is NIS or LDAP served and cannot be deleted) +if [ $1 = 0 ]; then + /bin/grep '^%{nsusr}:' /etc/passwd > /dev/null 2>&1 && /usr/sbin/userdel %{nsusr} || %nnmmsg "User %{nsusr} could not be deleted." + /bin/grep '^%{nsgrp}:' /etc/group > /dev/null 2>&1 && /usr/sbin/groupdel %{nsgrp} || %nnmmsg "Group %{nsgrp} could not be deleted." + /bin/grep '^%{cmdgrp}:' /etc/group > /dev/null 2>&1 && /usr/sbin/groupdel %{cmdgrp} || %nnmmsg "Group %{cmdgrp} could not be deleted." +fi + + +%post www +# If apache is installed, and we can find the apache user, set a shell var +wwwusr=`awk '/^[ \t]*User[ \t]+[a-zA-Z0-9]+/ {print $2}' /etc/apache2/*.conf` +if [ "z" == "z$wwwusr" ]; then # otherwise, use the default + wwwusr=%{wwwusr} +fi +# if apache user is not in cmdgrp, add it +if /usr/bin/id -Gn $wwwusr 2>/dev/null | /bin/grep -q %{cmdgrp} > /dev/null 2>&1 ; then + : # $wwwusr (default: apache) is already in nagiocmd group +else + # first find apache primary group + pgrp=`/usr/bin/id -gn $wwwusr 2>/dev/null` + # filter apache primary group from secondary groups + sgrps=`/usr/bin/id -Gn $wwwusr 2>/dev/null | /bin/sed "s/^$pgrp //;s/ $pgrp //;s/^$pgrp$//;s/ /,/g;"` + if [ "z" == "z$sgrps" ] ; then + sgrps=%{nsgrp} + else + sgrps=$sgrps,%{cmdgrp} + fi + # modify apache user, adding it to cmdgrp + /usr/sbin/usermod -G $sgrps $wwwusr >/dev/null 2>&1 + %nnmmsg "User $wwwusr added to group %{cmdgrp} so sending commands to Nagios from the command CGI is possible." +fi + + +%preun www +if [ $1 = 0 ]; then +if test -f /etc/apache2/httpd.conf; then + TEMPFILE=`mktemp /etc/apache2/httpd.conf.tmp.XXXXXX` + if grep "^ *Include /etc/apache2/conf.d/nagios.conf" /etc/apache2/httpd.conf > /dev/null; then + grep -v "^ *Include /etc/apache2/conf.d/nagios.conf" /etc/apache2/httpd.conf > $TEMPFILE + mv $TEMPFILE /etc/apache2/httpd.conf + chmod 644 /etc/apache2/httpd.conf + /etc/init.d/apache2 restart + fi +fi +fi + + +%build +export PATH=$PATH:/usr/sbin +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \ +./configure \ + --with-init-dir=/etc/init.d \ + --with-cgiurl=/nagios/cgi-bin \ + --with-htmurl=/nagios \ + --with-lockfile=/var/run/nagios.pid \ + --with-nagios-user=%{nsusr} \ + --with-nagios-group=%{nsgrp} \