require nagios-plugins

change lock file location from /var/run to /run
configure by default to use /etc/nagios/conf.d directory [release 3.5.1-2mamba;Wed May 07 2014]
This commit is contained in:
Silvan Calarco 2024-01-06 07:30:34 +01:00
parent 80be7b0064
commit e50dcc68b4
9 changed files with 530 additions and 0 deletions

View File

@ -1,2 +1,9 @@
# nagios
NAGIOS is an application, system and network monitoring application.
It can escalate problems by email, pager or any other medium.
It is also useful for incident or SLA reporting.
Nagios is written in C and is designed 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.
This package provide core programs for nagios.

View File

@ -0,0 +1,26 @@
diff -ru nagios/sample-config/httpd.conf.in nagios-om/sample-config/httpd.conf.in
--- nagios/sample-config/httpd.conf.in 2005-11-26 23:47:52.000000000 +0100
+++ nagios-om/sample-config/httpd.conf.in 2012-11-16 17:40:55.000000000 +0100
@@ -6,9 +6,9 @@
# configuration file. Customize the paths, etc. as
# needed to fit your system.
-ScriptAlias @cgiurl@ "@sbindir@"
+ScriptAlias @cgiurl@ "@cgidir@"
-<Directory "@sbindir@">
+<Directory "@cgidir@">
# SSLRequireSSL
Options ExecCGI
AllowOverride None
diff -ru nagios/subst.in nagios-om/subst.in
--- nagios/subst.in 2009-07-08 00:34:51.000000000 +0200
+++ nagios-om/subst.in 2012-11-16 17:41:38.000000000 +0100
@@ -31,6 +31,7 @@
s|\@datadir\@|@datadir@|g;
s|\@sbindir\@|@sbindir@|g;
s|\@bindir\@|@bindir@|g;
+ s|\@cgidir\@|@libdir@/cgi-bin/|g;
s|\@htmurl\@|@htmurl@|g;
s|\@cgiurl\@|@cgiurl@|g;
s|\@MAIL_PROG\@|@MAIL_PROG@|g;

View File

@ -0,0 +1,21 @@
diff -ru nagios/sample-config/httpd.conf.in nagios-om/sample-config/httpd.conf.in
--- nagios/sample-config/httpd.conf.in 2012-11-16 17:43:48.000000000 +0100
+++ nagios-om/sample-config/httpd.conf.in 2012-11-16 17:45:04.000000000 +0100
@@ -19,7 +19,7 @@
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
- AuthUserFile @sysconfdir@/htpasswd.users
+ AuthUserFile @sysconfdir@/private/htpasswd.users
Require valid-user
</Directory>
@@ -36,7 +36,7 @@
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
- AuthUserFile @sysconfdir@/htpasswd.users
+ AuthUserFile @sysconfdir@/private/htpasswd.users
Require valid-user
</Directory>

View File

@ -0,0 +1,20 @@
diff -ru nagios/Makefile.in nagios-om/Makefile.in
--- nagios/Makefile.in 2012-06-21 13:16:10.000000000 +0200
+++ nagios-om/Makefile.in 2012-11-16 17:37:07.000000000 +0100
@@ -290,6 +290,7 @@
@echo ""
install-webconf:
+ $(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTTPD_CONF)
$(INSTALL) -m 644 sample-config/httpd.conf $(DESTDIR)$(HTTPD_CONF)/nagios.conf
@echo ""
@@ -334,7 +335,7 @@
@echo ""
-fullinstall: install install-init install-commandmode install-webconf
+fullinstall: install install-init install-commandmode install-webconf install-config
# Uninstall is too destructive if base install directory is /usr, etc.
#uninstall:

View File

@ -0,0 +1,51 @@
diff -ru nagios/daemon-init.in nagios-om/daemon-init.in
--- nagios/daemon-init.in 2010-10-23 11:59:18.000000000 +0200
+++ nagios-om/daemon-init.in 2012-11-16 17:30:08.000000000 +0100
@@ -58,11 +58,14 @@
printstatus_nagios()
{
- if status_nagios $1 $2; then
+ status_nagios $1 $2
+ RETVAL=$?
+ if [ $RETVAL = 0 ]; then
echo "nagios (pid $NagiosPID) is running..."
else
echo "nagios is not running"
fi
+ return $RETVAL
}
@@ -94,6 +97,11 @@
. /etc/init.d/functions
fi
+# Source an extra configuration file
+if [ -f /etc/sysconfig/nagios ]; then
+ . /etc/sysconfig/nagios
+fi
+
prefix=@prefix@
exec_prefix=@exec_prefix@
NagiosBin=@bindir@/nagios
@@ -129,7 +137,9 @@
echo -n "Starting nagios:"
$NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
if [ $? -eq 0 ]; then
- su - $NagiosUser -c "touch $NagiosVarDir/nagios.log $NagiosRetentionFile"
+ pidof nagios > $NagiosRunFile
+ touch $NagiosVarDir/nagios.log $NagiosRetentionFile
+ chown $NagiosUser:$NagiosGroup $NagiosVarDir/nagios.log $NagiosRetentionFile
rm -f $NagiosCommandFile
touch $NagiosRunFile
chown $NagiosUser:$NagiosGroup $NagiosRunFile
@@ -228,7 +238,7 @@
*)
echo "Usage: nagios {start|stop|restart|reload|force-reload|status|checkconfig}"
- exit 1
+ exit 2
;;
esac

View File

@ -0,0 +1,10 @@
diff -ru nagios/p1.pl nagios-om/p1.pl
--- nagios/p1.pl 2008-05-19 20:02:08.000000000 +0200
+++ nagios-om/p1.pl 2012-11-16 18:32:58.000000000 +0100
@@ -1,4 +1,5 @@
- package Embed::Persistent;
+#!/usr/bin/perl
+package Embed::Persistent;
# p1.pl for Nagios

11
nagios-3.5.1-confd.patch Normal file
View File

@ -0,0 +1,11 @@
diff -Nru nagios.orig/sample-config/nagios.cfg.in nagios/sample-config/nagios.cfg.in
--- nagios.orig/sample-config/nagios.cfg.in 2013-08-30 19:46:14.000000000 +0200
+++ nagios/sample-config/nagios.cfg.in 2014-05-07 15:02:57.781679579 +0200
@@ -53,6 +53,7 @@
#cfg_dir=@sysconfdir@/printers
#cfg_dir=@sysconfdir@/switches
#cfg_dir=@sysconfdir@/routers
+cfg_dir=@sysconfdir@/conf.d

31
nagios.htaccess Normal file
View File

@ -0,0 +1,31 @@
ScriptAlias /nagios/cgi-bin "@libdir@/nagios/cgi-bin/"
<Directory "@libdir@/nagios/cgi-bin/">
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios/private/htpasswd.users
Require valid-user
</Directory>
Alias /nagios "/usr/share/nagios/html/"
<Directory "/usr/share/nagios/html/">
Options None
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios/private/htpasswd.users
Require valid-user
</Directory>

353
nagios.spec Normal file
View File

@ -0,0 +1,353 @@
%define nsusr nagios
%define nsgrp nagios
%define cmdgrp nagioscmd
Name: nagios
Version: 3.5.1
Release: 2mamba
Summary: An Open Source host, service and network monitoring program
Group: Network/Monitoring
Vendor: openmamba
Distribution: openmamba
Packager: Davide Madrisan <davide.madrisan@gmail.com>
URL: http://www.nagios.org/
Source0: http://downloads.sourceforge.net/sourceforge/nagios/nagios-%{version}.tar.gz
Source1: nagios.htaccess
Patch0: %{name}-3.4.2-nagios_initscripts.patch
Patch1: %{name}-3.4.2-makefile_install,patch
Patch2: %{name}-3.4.2-fix_path_to_cgi_executables.patch
Patch3: %{name}-3.4.2-fix_path_to_passwd_file_in_apache_s_config_file.patch
Patch4: %{name}-3.4.2-p1_missing_interpreter.patch
Patch5: nagios-3.5.1-confd.patch
License: GPL
## AUTOBUILDREQ-BEGIN
BuildRequires: glibc-devel
BuildRequires: libgd-devel
BuildRequires: libjpeg-devel
BuildRequires: libltdl-devel
BuildRequires: libpng-devel
BuildRequires: libz-devel
BuildRequires: perl-devel
## AUTOBUILDREQ-END
BuildRequires: mailx
BuildRequires: perl(CPAN)
BuildRequires: perl(ExtUtils::MakeMaker)
BuildRequires: perl(ExtUtils::Embed)
BuildRequires: perl(Test::Harness)
BuildRequires: perl(Test::HTML::Lint)
BuildRequires: perl(Test::More)
BuildRequires: perl(Test::Simple)
Requires: mailx
Requires: nagios-plugins
BuildRoot: %{_tmppath}/%{name}-%{version}-root
%description
NAGIOS is an application, system and network monitoring application.
It can escalate problems by email, pager or any other medium.
It is also useful for incident or SLA reporting.
Nagios is written in C and is designed 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.
This package provide core programs for nagios.
%package www
Group: Network/Monitoring
Summary: Provides the HTML and CGI files for the Nagios web interface
Requires(pre): %{name} = %{?epoch:%epoch:}%{version}-%{release}
Requires(pre): apache
Requires(pre): apache-mod_php
%description www
Nagios is an application, system and network monitoring application.
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: Development/Libraries
Summary: Development files for %{name}
Requires: %{name} = %{?epoch:%epoch:}%{version}-%{release}
%description devel
This package provides include files that Nagios-related applications may compile against.
%prep
%setup -q -n %{name}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%build
%configure \
--prefix=%{_datadir}/%{name} \
--exec-prefix=%{_localstatedir}/lib/%{name} \
--bindir=%{_sbindir} \
--datadir=%{_datadir}/%{name}/html \
--libdir=%{_libdir}/%{name} \
--libexecdir=%{_libdir}/%{name}/plugins \
--localstatedir=%{_localstatedir}/log/%{name} \
--sysconfdir=%{_sysconfdir}/%{name} \
--enable-embedded-perl \
--enable-event-broker \
--enable-nanosleep \
--with-init-dir=%{_initrddir} \
--with-cgiurl=/%{name}/cgi-bin \
--with-htmlurl=/%{name} \
--with-httpd_conf=%{_sysconfdir}/httpd/httpd.d \
--with-lockfile=/run/%{name}.pid \
--with-checkresult-dir=%{_localstatedir}/spool/%{name} \
--with-nagios-user=%{nsusr} --with-nagios-grp=%{nsgrp} \
--with-command-group=%{cmdgrp} \
--with-gd-lib=%{_libdir} \
--with-gd-inc=%{_includedir} \
--with-perlcache \
--with-template-objects \
--with-template-extinfo \
--with-mail=/bin/mailx \
STRIP=/bin/true
%make %{?_smp_mflags} all
sed -e "s|@libdir@/|%{_libdir}/|" %{S:1} > %{name}.htaccess
sed -i -e "\
s|\(NagiosCommandFile=\).*|\1%{_localstatedir}/spool/%{name}/rw/nagios.cmd|" \
daemon-init
cd sample-config
sed -i \
-e "s|resource.cfg|private/resource.cfg|" \
-e "s|\(command_file=\).*|\1%{_localstatedir}/spool/%{name}/rw/nagios.cmd|" \
nagios.cfg
sed -i "\
s,\(#\$USER2\$=\).*,\1%{_libdir}/nagios/eventhandlers," \
resource.cfg
cd ..
# make daemonchk.cgi and event handlers
cd contrib
%make daemonchk.cgi \
traceroute.cgi \
mini_epn \
convertcfg
cd eventhandlers
for f in `find . -type f`; do
sed -i "\
s,/usr/local/nagios/etc,%{_sysconfdir}/nagios,
s,/usr/local/nagios/libexec,%{_libdir}/nagios,
s,/usr/local/nagios/var/rw/nagios.cmd,%{_localstatedir}/spool/%{name}/rw/nagios.cmd," $f
done
%install
[ "%{buildroot}" != / ] && rm -rf %{buildroot}
make \
DESTDIR=%{buildroot} \
INSTALL_OPTS="" COMMAND_OPTS="" INIT_OPTS="" \
CGIDIR="%{_libdir}/%{name}/cgi-bin" \
CFGDIR="%{_sysconfdir}/%{name}" fullinstall
# Private files
install -d -m 0755 %{buildroot}%{_sysconfdir}/%{name}/private
mv %{buildroot}%{_sysconfdir}/%{name}/resource.cfg \
%{buildroot}%{_sysconfdir}/%{name}/private/resource.cfg
install -d %{buildroot}%{_sysconfdir}/%{name}/private
touch %{buildroot}%{_sysconfdir}/%{name}/private/htpasswd.users
# Install header-file
install -D -m 0644 include/locations.h \
%{buildroot}%{_includedir}/%{name}/locations.h
install -d %{buildroot}%{_sysconfdir}/sysconfig
touch %{buildroot}%{_sysconfdir}/sysconfig/%{name}
install -d %{buildroot}%{_localstatedir}/spool/%{name}/rw
install -d -m 0755 %{buildroot}%{_libdir}/%{name}/plugins/eventhandlers
# Install eventhandlers
pwd
install -d %{buildroot}%{_libdir}/nagios/eventhandlers
find ./contrib/eventhandlers/ -type f -exec \
install -m 0755 {} %{buildroot}%{_libdir}/%{name}/eventhandlers/ ';'
# Fix strange permission
chmod 755 %{buildroot}%{_sbindir}/nagiostats
chmod 755 %{buildroot}%{_libdir}/nagios/cgi-bin
chmod 755 %{buildroot}%{_libdir}/nagios/cgi-bin/*
# Create conf.d directory
install -d %{buildroot}%{_sysconfdir}/nagios/conf.d
%clean
[ "%{buildroot}" != / ] && rm -rf %{buildroot}
%pre
%{_bindir}/getent group %{cmdgrp} >/dev/null || %{_sbindir}/groupadd -r %{cmdgrp}
%{_bindir}/getent group %{nsgrp} >/dev/null || %{_sbindir}/groupadd -r %{nsgrp}
%{_bindir}/getent passwd %{nsusr} >/dev/null || \
%{_sbindir}/useradd -r -c "Nagios Network Monitoring"\
-d %{_localstatedir}/spool/%{name}\
-s /bin/bash -g %{nsgrp} %{nsusr} >/dev/null 2>&1
exit 0
%preun
if [ $1 = 0 ]; then
/sbin/service %{name} stop >/dev/null 2>&1
/sbin/chkconfig --del %{name}
%{_sbindir}/userdel %{nsusr} >/dev/null 2>&1
%{_sbindir}/groupdel %{nsgrp} >/dev/null 2>&1
%{_sbindir}/groupdel %{cmdgrp} >/dev/null 2>&1
fi
exit 0
%post
if [ $1 -eq 1 ]; then
/sbin/chkconfig --add %{name}
# add apache user to %{nsgrp} so sending commands to nagios
# from the command CGI is possible
%{_sbindir}/usermod -G %{nsgrp} apache >/dev/null 2>&1
fi
exit 0
%preun www
if [ $1 = 0 ]; then
[ -e %{_localstatedir}/lock/subsys/httpd ] && /sbin/service httpd reload 2>&1
fi
exit 0
%post www
if [ $1 -eq 1 ]; then
RANDOM_PASSWD=`/usr/bin/mkpasswd -l 10 -s 0 2>/dev/null`
%{_bindir}/htpasswd \
-bc %{_sysconfdir}/%{name}/private/htpasswd.users nagiosadmin \
$RANDOM_PASSWD >/dev/null 2>&1
[ -e %{_localstatedir}/lock/subsys/httpd ] && /sbin/service httpd reload
fi
exit 0
%postun www
if [ $1 -ge 1 ]; then
/sbin/service httpd condrestart >/dev/null 2>&1 || :
fi
exit 0
%files
%defattr(-,root,root)
%{_sbindir}/nagios
%{_sbindir}/nagiostats
%{_sbindir}/p1.pl
%dir %{_sysconfdir}/nagios
%dir %{_sysconfdir}/nagios/conf.d
%attr(644,root,root) %config(noreplace) %{_sysconfdir}/nagios/*.cfg
%dir %{_sysconfdir}/%{name}/objects
%attr(644,root,root) %config(noreplace) %{_sysconfdir}/%{name}/objects/*.cfg
%dir %{_sysconfdir}/nagios/private
%attr(640,root,%{nsgrp}) %config(noreplace) %{_sysconfdir}/nagios/private/resource.cfg
%config(noreplace) %attr(0644,root,root) %{_sysconfdir}/sysconfig/%{name}
%{_initrddir}/nagios
%attr(0755,%{nsusr},%{nsgrp}) %dir %{_localstatedir}/spool/%{name}
%attr(2775,%{nsusr},%{nsgrp}) %{_localstatedir}/spool/%{name}/rw
%attr(0755,%{nsusr},%{nsgrp}) %dir %{_localstatedir}/log/%{name}
%attr(0755,%{nsusr},%{nsgrp}) %dir %{_localstatedir}/log/%{name}/archives
%{_libdir}/%{name}/eventhandlers
%dir %{_datadir}/%{name}
%files www
%defattr(-,root,root)
%dir %{_datadir}/%{name}/html
%{_datadir}/%{name}/html/index.php
%{_datadir}/%{name}/html/main.php
%{_datadir}/%{name}/html/rss-corefeed.php
%{_datadir}/%{name}/html/rss-newsfeed.php
%{_datadir}/%{name}/html/side.php
%config(noreplace) %{_datadir}/%{name}/html/config.inc.php
%{_datadir}/%{name}/html/*.txt
%{_datadir}/%{name}/html/contexthelp
%dir %{_datadir}/%{name}/html/images
%{_datadir}/%{name}/html/images/*.gif
%{_datadir}/%{name}/html/images/*.ico
%{_datadir}/%{name}/html/images/*.jpg
%{_datadir}/%{name}/html/images/[^s]*.png
%{_datadir}/%{name}/html/images/sflogo.png
%config(noreplace) %{_datadir}/%{name}/html/images/sblogo.png
%{_datadir}/%{name}/html/images/logos
%{_datadir}/%{name}/html/includes
%{_datadir}/%{name}/html/js
%{_datadir}/%{name}/html/stylesheets
%dir %{_libdir}/nagios/cgi-bin
%{_libdir}/nagios/cgi-bin/*
%config(noreplace) %{_sysconfdir}/httpd/httpd.d/nagios.conf
%attr(0640,root,%{nsgrp}) %config(noreplace) %{_sysconfdir}/%{name}/private/htpasswd.users
%files devel
%defattr(-,root,root)
%dir %{_includedir}/nagios
%{_includedir}/nagios/*.h
%changelog
* Wed May 07 2014 Silvan Calarco <silvan.calarco@mambasoft.it> 3.5.1-2mamba
- require nagios-plugins
- change lock file location from /var/run to /run
- configure by default to use /etc/nagios/conf.d directory
* Fri Aug 30 2013 Automatic Build System <autodist@mambasoft.it> 3.5.1-1mamba
- automatic update by autodist
* Fri Mar 15 2013 Automatic Build System <autodist@mambasoft.it> 3.5.0-1mamba
- automatic version update by autodist
* Sun Jan 20 2013 Automatic Build System <autodist@mambasoft.it> 3.4.4-1mamba
- automatic version update by autodist
* Sat Dec 15 2012 Davide Madrisan <davide.madrisan@gmail.com> 3.4.3-1mamba
- update to 3.4.3
- enable embedded perl by default
- update apache configuration
- do not replace %{_datadir}/%{name}/html/images/sblogo.png while updating nagios
* Wed Nov 03 2010 Automatic Build System <autodist@mambasoft.it> 3.2.3-1mamba
- automatic update by autodist
* Wed May 12 2010 Automatic Build System <autodist@mambasoft.it> 3.2.1-1mamba
- automatic update by autodist
* Wed Aug 19 2009 Automatic Build System <autodist@mambasoft.it> 3.2.0-1mamba
- automatic update by autodist
* Mon Jul 13 2009 Automatic Build System <autodist@mambasoft.it> 3.1.2-1mamba
- automatic update by autodist
* Mon Mar 02 2009 Silvan Calarco <silvan.calarco@mambasoft.it> 3.1.0-1mamba
- automatic update by autodist
* Wed Dec 24 2008 Silvan Calarco <silvan.calarco@mambasoft.it> 3.0.6-1mamba
- automatic update by autodist
* Fri Oct 24 2008 gil <puntogil@libero.it> 3.0.4-1mamba
- update to 3.0.4
* Tue Oct 11 2005 Davide Madrisan <davide.madrisan@qilinux.it> 1.2-7qilnx
- remove exec permissions from /etc/httpd/nagios.conf
* Wed Dec 15 2004 Davide Madrisan <davide.madrisan@qilinux.it> 1.2-6qilnx
- do create the directory /var/log/nagios/archives needed to backup logs
* Tue Jul 13 2004 Davide Madrisan <davide.madrisan@qilinux.it> 1.2-5qilnx
- added support for the nrpe extra plugin
* Wed Jul 07 2004 Davide Madrisan <davide.madrisan@qilinux.it> 1.2-4qilnx
- added some default entries in the services.cfg file
- added support for hosts and services icons
* Tue Jul 06 2004 Davide Madrisan <davide.madrisan@qilinux.it> 1.2-3qilnx
- fixed paths in the eventhandlers scripts
* Fri Jul 02 2004 Davide Madrisan <davide.madrisan@qilinux.it> 1.2-2qilnx
- specfile fixes
- added nagios-1.2-daemon_init patch
* Tue Jun 29 2004 Davide Madrisan <davide.madrisan@qilinux.it> 1.2-1qilnx
- first build