diff --git a/nagios-0001-default-init.patch b/nagios-0001-default-init.patch new file mode 100644 index 0000000000000000000000000000000000000000..422f0decb26b409cf7ba9ed483a9ffa59177679d --- /dev/null +++ b/nagios-0001-default-init.patch @@ -0,0 +1,88 @@ +diff -up ./startup/default-init.in.fix_el6_init ./startup/default-init.in +--- ./startup/default-init.in.fix_el6_init 2019-01-15 09:58:00.000000000 -0500 ++++ ./startup/default-init.in 2019-02-05 09:38:09.463144849 -0500 +@@ -1,6 +1,6 @@ + #!/bin/sh + # +-# chkconfig: 345 99 01 ++# chkconfig: - 99 01 + # description: Nagios network monitor + # processname: nagios + # File : nagios +@@ -24,6 +24,9 @@ + # - Clean out redhat macros and other dependencies + # 2003-01-11 Ethan Galstad + # - Updated su syntax (Gary Miller) ++# 2018-11-28 Justin Paulsen ++# - Patched for EPEL release of Nagioscore 4.4.2 ++# - - nagios-0001-default-init.patch + # + # Description: Starts and stops the Nagios monitor + # used to provide network services status. +@@ -91,12 +94,12 @@ check_config () + echo "ERROR: Could not delete '$NagiosCfgtestFile'" + exit 8 + fi +- if ! su $NagiosUser -c "touch $NagiosCfgtestFile"; then ++ if ! su $NagiosUser -c "touch $NagiosCfgtestFile" -s /bin/sh ; then + echo "ERROR: Could not create or update '$NagiosCfgtestFile'" + exit 8 + fi + +- TMPFILE=$(mktemp /tmp/.configtest.XXXXXXXX) ++ TMPFILE=$(mktemp $NagiosCfgtestFile.XXX) + $NagiosBin -vp $NagiosCfgFile > "$TMPFILE" + WARN=`grep ^"Total Warnings:" "$TMPFILE" |awk -F: '{print \$2}' |sed s/' '//g` + ERR=`grep ^"Total Errors:" "$TMPFILE" |awk -F: '{print \$2}' |sed s/' '//g` +@@ -138,11 +141,14 @@ status_nagios () + + printstatus_nagios () + { +- if status_nagios; 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 + } + + killproc_nagios () +@@ -157,7 +163,17 @@ pid_nagios () + return 1 + fi + +- NagiosPID=`head -n 1 $NagiosRunFile` ++ export NagiosPID=`head -n 1 $NagiosRunFile` ++ if [[ -z "$NagiosPID" ]]; then ++ echo "No usable PID found in $NagiosRunFile" ++ exit 1 ++ fi ++ ++ regex='^[0-9]+$' ++ if ! [[ $NagiosPID =~ $regex ]]; then ++ echo "PID not number found in $NagiosRunFile" ++ exit 1 ++ fi + } + + # Check that nagios exists. +@@ -188,7 +204,7 @@ case "$1" in + fi + fi + +- su $NagiosUser -c "touch $NagiosVarDir/nagios.log $NagiosRetentionFile" ++ su $NagiosUser -c "touch $NagiosVarDir/nagios.log $NagiosRetentionFile" -s /bin/sh + @BIN_RM@ -f $NagiosCommandFile + touch $NagiosRunFile + $NagiosBin -d $NagiosCfgFile +@@ -281,6 +297,7 @@ case "$1" in + *) + echo "Usage: nagios {start|stop|restart|reload|force-reload|status|checkconfig|configtest}" + exit 1 ++ exit 2 + ;; + + esac diff --git a/nagios-0002-Fix-installation-of-httpd-conf.d-config-file.patch b/nagios-0002-Fix-installation-of-httpd-conf.d-config-file.patch new file mode 100644 index 0000000000000000000000000000000000000000..bcd92b26ad0caed976ea607976ed400f4d8079c3 --- /dev/null +++ b/nagios-0002-Fix-installation-of-httpd-conf.d-config-file.patch @@ -0,0 +1,11 @@ +diff -up ./Makefile.in.fix_httpd_conf_d ./Makefile.in +--- ./Makefile.in.fix_httpd_conf_d 2018-11-28 12:36:22.206486501 -0600 ++++ ./Makefile.in 2018-11-28 12:37:26.098414877 -0600 +@@ -337,6 +337,7 @@ install-groups-users: + @autoconf-macros/add_group_user $(DIST) $(NAGIOS_USER) $(NAGIOS_GRP) 1 + + install-webconf: ++ $(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(HTTPD_CONF) + $(INSTALL) -m 644 sample-config/httpd.conf $(DESTDIR)$(HTTPD_CONF)/nagios.conf + if [ $(LN_HTTPD_SITES_ENABLED) -eq 1 ]; then \ + $(LN_S) $(DESTDIR)$(HTTPD_CONF)/nagios.conf $(DESTDIR)/etc/apache2/sites-enabled/nagios.conf; \ diff --git a/nagios-0003-Install-config-files-too.patch b/nagios-0003-Install-config-files-too.patch new file mode 100644 index 0000000000000000000000000000000000000000..4bf4aa23597491d90542f2a22c11106bad21904f --- /dev/null +++ b/nagios-0003-Install-config-files-too.patch @@ -0,0 +1,12 @@ +diff -up ./Makefile.in.install_config ./Makefile.in +--- ./Makefile.in.install_config 2017-04-19 19:11:47.783707415 -0400 ++++ ./Makefile.in 2017-04-19 19:11:47.785707384 -0400 +@@ -377,7 +377,7 @@ dox: + doxygen doxy.conf + + +-fullinstall: install install-init install-commandmode install-webconf install-devel ++fullinstall: install install-init install-commandmode install-webconf install-devel install-config + + # Uninstall is too destructive if base install directory is /usr, etc. + #uninstall: diff --git a/nagios-0004-Fix-path-to-CGI-executables.patch b/nagios-0004-Fix-path-to-CGI-executables.patch new file mode 100644 index 0000000000000000000000000000000000000000..d3fdfe79267eb7fe501d4753eff14dc864734462 --- /dev/null +++ b/nagios-0004-Fix-path-to-CGI-executables.patch @@ -0,0 +1,50 @@ +From 3bdd7e40e1c7e7484edcb53b01ef3cd446305466 Mon Sep 17 00:00:00 2001 +From: Peter Lemenkov +Date: Mon, 15 Nov 2010 15:07:49 +0300 +Subject: [PATCH 08/12] Fix path to CGI executables + +See rhbz #653291 for additional details: + +https://bugzilla.redhat.com/653291 + +Signed-off-by: Peter Lemenkov + + +Modified for 4.0.8 - Scott Wilkerson + +--- + sample-config/httpd.conf.in | 4 ++-- + subst.in | 1 + + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/sample-config/httpd.conf.in b/sample-config/httpd.conf.in +index 71d4fbb..1b1e693 100644 +--- a/sample-config/httpd.conf.in ++++ b/sample-config/httpd.conf.in +@@ -5,9 +5,9 @@ + # configuration file. Customize the paths, etc. as + # needed to fit your system. + +-ScriptAlias @cgiurl@ "@sbindir@" ++ScriptAlias @cgiurl@ "@cgidir@" + +- ++ + # SSLRequireSSL + Options ExecCGI + AllowOverride None +diff --git a/subst.in b/subst.in +index a8e2c06..bbffb3a 100755 +--- a/subst.in ++++ b/subst.in +@@ -35,6 +35,7 @@ while ($f = shift @ARGV) { + s|\@datarootdir\@|@datarootdir@|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; +-- +1.8.3.1 + diff --git a/nagios-0005-Fixed-path-to-passwd-file-in-Apache-s-config-file.patch b/nagios-0005-Fixed-path-to-passwd-file-in-Apache-s-config-file.patch new file mode 100644 index 0000000000000000000000000000000000000000..1019607de860ff7454707985c15ef720b101af4a --- /dev/null +++ b/nagios-0005-Fixed-path-to-passwd-file-in-Apache-s-config-file.patch @@ -0,0 +1,39 @@ +diff -up ./sample-config/httpd.conf.in.fix_path_to_passwd ./sample-config/httpd.conf.in +--- ./sample-config/httpd.conf.in.fix_path_to_passwd 2016-10-24 10:10:28.000000000 -0400 ++++ ./sample-config/httpd.conf.in 2016-11-08 14:37:02.117929826 -0500 +@@ -18,7 +18,7 @@ ScriptAlias @cgiurl@ "@sbindir@" + + AuthName "Nagios Access" + AuthType Basic +- AuthUserFile @sysconfdir@/htpasswd.users ++ AuthUserFile @sysconfdir@/passwd + Require valid-user + + +@@ -31,7 +31,7 @@ ScriptAlias @cgiurl@ "@sbindir@" + + AuthName "Nagios Access" + AuthType Basic +- AuthUserFile @sysconfdir@/htpasswd.users ++ AuthUserFile @sysconfdir@/passwd + Require valid-user + + +@@ -49,7 +49,7 @@ Alias @htmurl@ "@datadir@" + + AuthName "Nagios Access" + AuthType Basic +- AuthUserFile @sysconfdir@/htpasswd.users ++ AuthUserFile @sysconfdir@/passwd + Require valid-user + + +@@ -62,7 +62,7 @@ Alias @htmurl@ "@datadir@" + + AuthName "Nagios Access" + AuthType Basic +- AuthUserFile @sysconfdir@/htpasswd.users ++ AuthUserFile @sysconfdir@/passwd + Require valid-user + + diff --git a/nagios-0006-Added-several-images-to-the-sample-config-revb.patch b/nagios-0006-Added-several-images-to-the-sample-config-revb.patch new file mode 100644 index 0000000000000000000000000000000000000000..09fea7ea542f7414cffda4e915128b9ddb584e03 --- /dev/null +++ b/nagios-0006-Added-several-images-to-the-sample-config-revb.patch @@ -0,0 +1,29 @@ +diff -up ./sample-config/template-object/templates.cfg.in.more_images ./sample-config/template-object/templates.cfg.in +--- ./sample-config/template-object/templates.cfg.in.more_images 2018-11-28 13:10:25.822264939 -0600 ++++ ./sample-config/template-object/templates.cfg.in 2018-11-28 13:16:15.711410141 -0600 +@@ -123,6 +123,7 @@ define host { + notification_interval 30 ; Resend notifications every 30 minutes + notification_options d,r ; Only send notifications for specific host states + contact_groups admins ; Notifications get sent to the admins by default ++ statusmap_image printer.png + register 0 ; DON'T REGISTER THIS - ITS JUST A TEMPLATE + } + +@@ -142,9 +143,17 @@ define host { + notification_interval 30 ; Resend notifications every 30 minutes + notification_options d,r ; Only send notifications for specific host states + contact_groups admins ; Notifications get sent to the admins by default ++ statusmap_image switch.png + register 0 ; DON'T REGISTER THIS - ITS JUST A TEMPLATE + } + ++# Define a template for routers that we can reuse ++define host{ ++ name generic-router ; The name of this host template ++ use generic-switch ; Inherit default values from the generic-host template ++ statusmap_image router.png ++ register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE ++} + + + ############################################################################### diff --git a/nagios-0008-Add-cfg_dir-etc-nagios-conf.d-to-the-main-nagios-con.patch b/nagios-0008-Add-cfg_dir-etc-nagios-conf.d-to-the-main-nagios-con.patch new file mode 100644 index 0000000000000000000000000000000000000000..e22f3333d8b1964d99246158c952bf52544642e7 --- /dev/null +++ b/nagios-0008-Add-cfg_dir-etc-nagios-conf.d-to-the-main-nagios-con.patch @@ -0,0 +1,12 @@ +diff -up ./sample-config/nagios.cfg.in.conf_d ./sample-config/nagios.cfg.in +--- ./sample-config/nagios.cfg.in.conf_d 2017-08-24 17:43:48.000000000 -0400 ++++ ./sample-config/nagios.cfg.in 2017-09-15 18:29:48.659666387 -0400 +@@ -53,6 +53,8 @@ cfg_file=@sysconfdir@/objects/localhost. + #cfg_dir=@sysconfdir@/switches + #cfg_dir=@sysconfdir@/routers + ++cfg_dir=@sysconfdir@/conf.d ++ + + + diff --git a/nagios-0009-fix-localstatedir-for-linux.patch b/nagios-0009-fix-localstatedir-for-linux.patch new file mode 100644 index 0000000000000000000000000000000000000000..3c18043bce0eda066d012d3e267d30add8709a1c --- /dev/null +++ b/nagios-0009-fix-localstatedir-for-linux.patch @@ -0,0 +1,281 @@ +diff -up ./base/Makefile.in.fix_localstatedir ./base/Makefile.in +--- ./base/Makefile.in.fix_localstatedir 2019-01-16 13:29:13.079040249 -0600 ++++ ./base/Makefile.in 2019-01-16 13:32:54.103372583 -0600 +@@ -33,7 +33,7 @@ LIBS=@LIBS@ + + prefix=@prefix@ + exec_prefix=@exec_prefix@ +-LOGDIR=@localstatedir@ ++LOGDIR=@localstatedir@/log/nagios/ + CFGDIR=@sysconfdir@ + BINDIR=@bindir@ + CGIDIR=@cgibindir@ +diff -up ./cgi/Makefile.in.fix_localstatedir ./cgi/Makefile.in +--- ./cgi/Makefile.in.fix_localstatedir 2019-01-16 13:33:14.596032529 -0600 ++++ ./cgi/Makefile.in 2019-01-16 13:33:35.252689754 -0600 +@@ -12,7 +12,7 @@ SRC_LIB=../lib + + prefix=@prefix@ + exec_prefix=@exec_prefix@ +-LOGDIR=@localstatedir@ ++LOGDIR=@localstatedir@/log/nagios/ + CFGDIR=@sysconfdir@ + BINDIR=@bindir@ + CGIDIR=@cgibindir@ +diff -up ./common/Makefile.in.fix_localstatedir ./common/Makefile.in +--- ./common/Makefile.in.fix_localstatedir 2019-01-16 13:33:51.236424521 -0600 ++++ ./common/Makefile.in 2019-01-16 13:34:17.928981586 -0600 +@@ -13,7 +13,7 @@ LDFLAGS=@LDFLAGS@ @LIBS@ + + prefix=@prefix@ + exec_prefix=@exec_prefix@ +-LOGDIR=@localstatedir@ ++LOGDIR=@localstatedir@/log/nagios/ + CFGDIR=@sysconfdir@ + BINDIR=@bindir@ + CGIDIR=@cgibindir@ +diff -up ./html/config.inc.php.in.fix_localstatedir ./html/config.inc.php.in +--- ./html/config.inc.php.in.fix_localstatedir 2019-01-16 13:35:06.875169375 -0600 ++++ ./html/config.inc.php.in 2019-01-16 14:25:51.436714786 -0600 +@@ -9,8 +9,8 @@ $cfg['cgi_base_url']='@cgiurl@'; + + // FILE LOCATION DEFAULTS + $cfg['main_config_file']='@sysconfdir@/nagios.cfg'; // default location of the main Nagios config file +-$cfg['status_file']='@localstatedir@/status.dat'; // default location of Nagios status file +-$cfg['state_retention_file']='@localstatedir@/retention.dat'; // default location of Nagios retention file ++$cfg['status_file']='@localstatedir@/spool/nagios/status.dat'; // default location of Nagios status file ++$cfg['state_retention_file']='@localstatedir@/spool/nagios/retention.dat'; // default location of Nagios retention file + + + +diff -up ./html/Makefile.in.fix_localstatedir ./html/Makefile.in +--- ./html/Makefile.in.fix_localstatedir 2019-01-16 13:37:18.936977949 -0600 ++++ ./html/Makefile.in 2019-01-16 13:37:36.645684091 -0600 +@@ -4,7 +4,7 @@ LDFLAGS=@LDFLAGS@ @LIBS@ + + prefix=@prefix@ + exec_prefix=@exec_prefix@ +-LOGDIR=@localstatedir@ ++LOGDIR=@localstatedir@/log/nagios/ + CFGDIR=@sysconfdir@ + BINDIR=@bindir@ + CGIDIR=@cgibindir@ +diff -up ./include/locations.h.in.fix_localstatedir ./include/locations.h.in +--- ./include/locations.h.in.fix_localstatedir 2019-01-16 13:38:02.700251743 -0600 ++++ ./include/locations.h.in 2019-01-16 14:36:54.105757936 -0600 +@@ -17,18 +17,18 @@ + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + ************************************************************************/ + +-#define DEFAULT_TEMP_FILE "@localstatedir@/tempfile" ++#define DEFAULT_TEMP_FILE "@localstatedir@/spool/nagios/tempfile" + #define DEFAULT_TEMP_PATH "/tmp" +-#define DEFAULT_CHECK_RESULT_PATH "@localstatedir@/spool/checkresults" +-#define DEFAULT_STATUS_FILE "@localstatedir@/status.dat" +-#define DEFAULT_LOG_FILE "@localstatedir@/nagios.log" +-#define DEFAULT_LOG_ARCHIVE_PATH "@localstatedir@/archives/" +-#define DEFAULT_DEBUG_FILE "@localstatedir@/nagios.debug" +-#define DEFAULT_COMMENT_FILE "@localstatedir@/comments.dat" +-#define DEFAULT_DOWNTIME_FILE "@localstatedir@/downtime.dat" +-#define DEFAULT_RETENTION_FILE "@localstatedir@/retention.dat" +-#define DEFAULT_COMMAND_FILE "@localstatedir@/rw/nagios.cmd" +-#define DEFAULT_QUERY_SOCKET "@localstatedir@/rw/nagios.qh" ++#define DEFAULT_CHECK_RESULT_PATH "@localstatedir@/spool/nagios/checkresults" ++#define DEFAULT_STATUS_FILE "@localstatedir@/spool/nagios/status.dat" ++#define DEFAULT_LOG_FILE "@localstatedir@/log/nagios/nagios.log" ++#define DEFAULT_LOG_ARCHIVE_PATH "@localstatedir@/log/nagios/archives/" ++#define DEFAULT_DEBUG_FILE "@localstatedir@/log/nagios/nagios.debug" ++#define DEFAULT_COMMENT_FILE "@localstatedir@/spool/nagios/comments.dat" ++#define DEFAULT_DOWNTIME_FILE "@localstatedir@/spool/nagios/downtime.dat" ++#define DEFAULT_RETENTION_FILE "@localstatedir@/spool/nagios/retention.dat" ++#define DEFAULT_COMMAND_FILE "@localstatedir@/spool/nagios/cmd/nagios.cmd" ++#define DEFAULT_QUERY_SOCKET "@localstatedir@/spool/nagios/cmd/nagios.qh" + #define DEFAULT_CONFIG_FILE "@sysconfdir@/nagios.cfg" + #define DEFAULT_PHYSICAL_HTML_PATH "@datadir@" + #define DEFAULT_URL_HTML_PATH "@htmurl@" +@@ -36,6 +36,6 @@ + #define DEFAULT_URL_CGIBIN_PATH "@cgiurl@" + #define DEFAULT_CGI_CONFIG_FILE "@sysconfdir@/cgi.cfg" + #define DEFAULT_LOCK_FILE "@subsyslockfile@" +-#define DEFAULT_OBJECT_CACHE_FILE "@localstatedir@/objects.cache" +-#define DEFAULT_PRECACHED_OBJECT_FILE "@localstatedir@/objects.precache" +-#define DEFAULT_EVENT_BROKER_FILE "@localstatedir@/broker.socket" ++#define DEFAULT_OBJECT_CACHE_FILE "@localstatedir@/spool/nagios/objects.cache" ++#define DEFAULT_PRECACHED_OBJECT_FILE "@localstatedir@/spool/nagios/objects.precache" ++#define DEFAULT_EVENT_BROKER_FILE "@localstatedir@/spool/nagios/broker.socket" +diff -up ./sample-config/nagios.cfg.in.fix_localstatedir ./sample-config/nagios.cfg.in +--- ./sample-config/nagios.cfg.in.fix_localstatedir 2018-08-16 15:10:12.000000000 -0400 ++++ ./sample-config/nagios.cfg.in 2018-11-30 13:52:14.989761698 -0500 +@@ -15,7 +15,7 @@ + # for historical purposes. This should be the first option specified + # in the config file!!! + +-log_file=@localstatedir@/nagios.log ++log_file=@localstatedir@/log/nagios/nagios.log + + + +@@ -63,7 +63,7 @@ cfg_file=@sysconfdir@/objects/localhost. + # directly) in order to prevent inconsistencies that can occur + # when the config files are modified after Nagios starts. + +-object_cache_file=@localstatedir@/objects.cache ++object_cache_file=@localstatedir@/spool/nagios/objects.cache + + + +@@ -79,7 +79,7 @@ object_cache_file=@localstatedir@/object + # Read the documentation section on optimizing Nagios to find our more + # about how this feature works. + +-precached_object_file=@localstatedir@/objects.precache ++precached_object_file=@localstatedir@/spool/nagios/objects.precache + + + +@@ -92,7 +92,7 @@ precached_object_file=@localstatedir@/ob + # defined as macros in this file and restrictive permissions (600) + # can be placed on this file. + +-resource_file=@sysconfdir@/resource.cfg ++resource_file=@sysconfdir@/private/resource.cfg + + + +@@ -102,7 +102,7 @@ resource_file=@sysconfdir@/resource.cfg + # The contents of the status file are deleted every time Nagios + # restarts. + +-status_file=@localstatedir@/status.dat ++status_file=@localstatedir@/spool/nagios/status.dat + + + +@@ -151,14 +151,14 @@ check_external_commands=1 + # directory level instead of on the file, as the file is deleted every + # time its contents are processed. + +-command_file=@localstatedir@/rw/nagios.cmd ++command_file=@localstatedir@/spool/nagios/cmd/nagios.cmd + + + + # QUERY HANDLER INTERFACE + # This is the socket that is created for the Query Handler interface + +-#query_socket=@localstatedir@/rw/nagios.qh ++#query_socket=@localstatedir@/spool/nagios/cmd/nagios.qh + + + +@@ -176,7 +176,7 @@ lock_file=@subsyslockfile@ + # is created, used, and deleted throughout the time that Nagios is + # running. + +-temp_file=@localstatedir@/nagios.tmp ++temp_file=@localstatedir@/spool/nagios/nagios.tmp + + + +@@ -243,7 +243,7 @@ log_rotation_method=d + # This is the directory where archived (rotated) log files should be + # placed (assuming you've chosen to do log rotation). + +-log_archive_path=@localstatedir@/archives ++log_archive_path=@localstatedir@/log/nagios/archives + + + +@@ -618,7 +618,7 @@ retain_state_information=1 + # This file is used only if the retain_state_information + # variable is set to 1. + +-state_retention_file=@localstatedir@/retention.dat ++state_retention_file=@localstatedir@/spool/nagios/retention.dat + + + +@@ -831,8 +831,8 @@ process_performance_data=0 + # Performance data is only written to these files if the + # enable_performance_data option (above) is set to 1. + +-#host_perfdata_file=@localstatedir@/host-perfdata +-#service_perfdata_file=@localstatedir@/service-perfdata ++#host_perfdata_file=@localstatedir@/log/nagios/host-perfdata ++#service_perfdata_file=@localstatedir@/log/nagios/service-perfdata + + + +@@ -1292,7 +1292,7 @@ debug_verbosity=1 + # DEBUG FILE + # This option determines where Nagios should write debugging information. + +-debug_file=@localstatedir@/nagios.debug ++debug_file=@localstatedir@/log/nagios/nagios.debug + + + +diff -up ./sample-config/template-object/commands.cfg.in.fix_localstatedir ./sample-config/template-object/commands.cfg.in +--- ./sample-config/template-object/commands.cfg.in.fix_localstatedir 2019-01-16 13:50:29.366875513 -0600 ++++ ./sample-config/template-object/commands.cfg.in 2019-01-16 13:51:22.140000845 -0600 +@@ -241,7 +241,7 @@ define command { + define command { + + command_name process-host-perfdata +- command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> @localstatedir@/host-perfdata.out ++ command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> @localstatedir@/log/nagios/host-perfdata.out + } + + +@@ -249,5 +249,5 @@ define command { + define command { + + command_name process-service-perfdata +- command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> @localstatedir@/service-perfdata.out ++ command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> @localstatedir@/log/nagios/service-perfdata.out + } +diff -up ./startup/default-init.in.fix_localstatedir ./startup/default-init.in +--- ./startup/default-init.in.fix_localstatedir 2019-01-16 14:16:54.874599523 -0600 ++++ ./startup/default-init.in 2019-01-16 14:22:55.103634621 -0600 +@@ -41,12 +41,12 @@ + # Our install-time configuration. + NagiosBin=@bindir@/@nagios_name@ + NagiosCfgFile=@sysconfdir@/nagios.cfg +-NagiosCfgtestFile=@localstatedir@/nagios.configtest +-NagiosStatusFile=@localstatedir@/status.dat +-NagiosRetentionFile=@localstatedir@/retention.dat +-NagiosCommandFile=@localstatedir@/rw/nagios.cmd ++NagiosCfgtestFile=@localstatedir@/spool/nagios/nagios.configtest ++NagiosStatusFile=@localstatedir@/spool/nagios/status.dat ++NagiosRetentionFile=@localstatedir@/spool/nagios/retention.dat ++NagiosCommandFile=@localstatedir@/spool/nagios/cmd/nagios.cmd + NagiosRunFile=@subsyslockfile@ +-NagiosVarDir=@localstatedir@ ++NagiosVarDir=@localstatedir@/spool/nagios/ + NagiosCGIDir=@cgibindir@ + NagiosUser=@nagios_user@ + NagiosGroup=@nagios_grp@ +diff -up ./startup/default-service.in.fix_localstatedir ./startup/default-service.in +--- ./startup/default-service.in.fix_localstatedir 2019-01-16 14:23:17.575262522 -0600 ++++ ./startup/default-service.in 2019-01-16 14:23:39.273903222 -0600 +@@ -8,7 +8,7 @@ Type=forking + ExecStartPre=@bindir@/nagios -v @sysconfdir@/nagios.cfg + ExecStart=@bindir@/nagios -d @sysconfdir@/nagios.cfg + ExecStop=@BIN_KILL@ -s TERM ${MAINPID} +-ExecStopPost=@BIN_RM@ -f @localstatedir@/rw/nagios.cmd ++ExecStopPost=@BIN_RM@ -f @localstatedir@/spool/nagios/cmd/nagios.cmd + ExecReload=@BIN_KILL@ -s HUP ${MAINPID} + + [Install] +diff -up ./t-tap/Makefile.in.fix_localstatedir ./t-tap/Makefile.in +--- ./t-tap/Makefile.in.fix_localstatedir 2019-01-16 14:24:14.944312569 -0600 ++++ ./t-tap/Makefile.in 2019-01-16 14:24:42.359858604 -0600 +@@ -42,7 +42,7 @@ LIBS=@LIBS@ ../lib/libnagios.a + + prefix=@prefix@ + exec_prefix=@exec_prefix@ +-LOGDIR=@localstatedir@ ++LOGDIR=@localstatedir@/log/nagios/ + CFGDIR=@sysconfdir@ + BINDIR=@bindir@ + CGIDIR=@cgibindir@ diff --git a/nagios-0010-remove-information-leak.patch b/nagios-0010-remove-information-leak.patch new file mode 100644 index 0000000000000000000000000000000000000000..46c62e11aeff8b905b6611ab8830db85f6357c4c --- /dev/null +++ b/nagios-0010-remove-information-leak.patch @@ -0,0 +1,166 @@ +diff -up ./cgi/extinfo.c.rm_youtube ./cgi/extinfo.c +--- ./cgi/extinfo.c.rm_youtube 2018-11-28 14:23:47.609805066 -0600 ++++ ./cgi/extinfo.c 2018-11-28 14:28:35.513997180 -0600 +@@ -557,27 +557,6 @@ void document_header(int use_stylesheet) + printf("\n", url_stylesheets_path, NAGFUNCS_CSS); + } + +- if (display_type == DISPLAY_HOST_INFO) +- vidurl = "https://www.youtube.com/embed/n3QEAf-MxY4"; +- else if(display_type == DISPLAY_SERVICE_INFO) +- vidurl = "https://www.youtube.com/embed/f_knwQOS6FI"; +- +- if (enable_page_tour == TRUE && vidurl) { +- printf("\n", url_js_path, JQUERY_JS); +- printf("\n", url_js_path, NAGFUNCS_JS); +- printf("\n"); +- } +- + printf("\n"); + + printf("\n"); +diff -up ./cgi/status.c.rm_youtube ./cgi/status.c +--- ./cgi/status.c.rm_youtube 2018-11-28 14:28:56.072653859 -0600 ++++ ./cgi/status.c 2018-11-28 14:32:05.038498204 -0600 +@@ -537,31 +537,8 @@ void document_header(int use_stylesheet) + /* JS function to append content to elements on page */ + printf("\n", url_js_path, NAGFUNCS_JS); +- +- printf("\n"); +- } ++ } + + + +diff -up ./html/main.php.rm_youtube ./html/main.php +--- ./html/main.php.rm_youtube 2018-11-28 14:34:59.249588949 -0600 ++++ ./html/main.php 2018-11-28 14:39:03.703506666 -0600 +@@ -19,20 +19,7 @@ $this_year = '2018'; + + + + +- +- +- +- + + > + diff --git a/nagios-0011-remove-rpmbuild.patch b/nagios-0011-remove-rpmbuild.patch new file mode 100644 index 0000000000000000000000000000000000000000..77c6ce6cde44ce5e4edb0603b6cb8e813dceb9b5 --- /dev/null +++ b/nagios-0011-remove-rpmbuild.patch @@ -0,0 +1,39 @@ +diff -up ./contrib/Makefile.in.remove_rpmbuild ./contrib/Makefile.in +--- ./contrib/Makefile.in.remove_rpmbuild 2019-01-16 15:00:18.627548108 -0600 ++++ ./contrib/Makefile.in 2019-01-16 15:00:38.756215308 -0600 +@@ -84,35 +84,3 @@ $(CGI_O): $(CGI_C) + + %.cgi : %.c + $(CC) $(CFLAGS) $(LDFLAGS) $< $(CGI_O) -o $@ +- +-############################################################################## +-# rpm making automation for CentOS/RHEL. +- +-ARCH ?= $(shell uname -m) +-ifeq ($(ARCH),x86_64) +-RPM_ARCH := x86_64 +-else +- ifeq ($(ARCH),i686) +-RPM_ARCH := i386 +- else +- ifeq ($(ARCH),aarch64) +-RPM_ARCH := aarch64 +- else +-$(error Unknown arch "$(ARCH)".) +- endif +- endif +-endif +- +-rpm: +- # create nagios tar ball. +- @(cd ..;rm -f nagios-@VERSION@) +- @(cd ..;ln -s . nagios-@VERSION@) +- @(cd ..;tar zhcf nagios-@VERSION@.tar.gz --exclude nagios-@VERSION@/nagios-@VERSION@.tar.gz --exclude nagios-@VERSION@/nagios-@VERSION@ --exclude RCS --exclude CVS --exclude build-* --exclude *~ --exclude .git* nagios-@VERSION@/) +- @(cd ..;rm -f nagios-@VERSION@) +- # build the rpm using rpmbuild from ./rmbuild as topdir +- @rm -rf rpmbuild && mkdir -p rpmbuild/SOURCES +- @cp ../nagios-@VERSION@.tar.gz rpmbuild/SOURCES/nagios-@VERSION@.tar.gz +- @rpmbuild -ba --define "_topdir ${PWD}/rpmbuild" ../nagios.spec +- @mv rpmbuild/RPMS/$(RPM_ARCH)/*.rpm . +- @ls -l *.rpm +- diff --git a/nagios-0012-fix-spool.patch b/nagios-0012-fix-spool.patch new file mode 100644 index 0000000000000000000000000000000000000000..f8979d693335100b469a0cd67fbd7e4e2f972abd --- /dev/null +++ b/nagios-0012-fix-spool.patch @@ -0,0 +1,48 @@ +diff -up ./contrib/eventhandlers/disable_active_service_checks.fix_spool ./contrib/eventhandlers/disable_active_service_checks +--- ./contrib/eventhandlers/disable_active_service_checks.fix_spool 2017-08-24 17:43:48.000000000 -0400 ++++ ./contrib/eventhandlers/disable_active_service_checks 2017-09-19 15:21:28.173643069 -0400 +@@ -16,7 +16,7 @@ + + printfcmd="/usr/bin/printf" + +-CommandFile="/usr/local/nagios/var/rw/nagios.cmd" ++CommandFile="/var/spool/nagios/" + + # get the current date/time in seconds since UNIX epoch + datetime=`date +%s` +diff -up ./contrib/eventhandlers/disable_notifications.fix_spool ./contrib/eventhandlers/disable_notifications +--- ./contrib/eventhandlers/disable_notifications.fix_spool 2017-08-24 17:43:48.000000000 -0400 ++++ ./contrib/eventhandlers/disable_notifications 2017-09-19 15:21:28.198643530 -0400 +@@ -14,7 +14,7 @@ + + printfcmd="/usr/bin/printf" + +-CommandFile="/usr/local/nagios/var/rw/nagios.cmd" ++CommandFile="/var/spool/nagios/" + + # get the current date/time in seconds since UNIX epoch + datetime=`date +%s` +diff -up ./contrib/eventhandlers/enable_active_service_checks.fix_spool ./contrib/eventhandlers/enable_active_service_checks +--- ./contrib/eventhandlers/enable_active_service_checks.fix_spool 2017-08-24 17:43:48.000000000 -0400 ++++ ./contrib/eventhandlers/enable_active_service_checks 2017-09-19 15:21:28.199643549 -0400 +@@ -16,7 +16,7 @@ + + printfcmd="/usr/bin/printf" + +-CommandFile="/usr/local/nagios/var/rw/nagios.cmd" ++CommandFile="/var/spool/nagios/" + + # get the current date/time in seconds since UNIX epoch + datetime=`date +%s` +diff -up ./contrib/eventhandlers/submit_check_result.fix_spool ./contrib/eventhandlers/submit_check_result +--- ./contrib/eventhandlers/submit_check_result.fix_spool 2017-08-24 17:43:48.000000000 -0400 ++++ ./contrib/eventhandlers/submit_check_result 2017-09-19 15:21:28.200643567 -0400 +@@ -24,7 +24,7 @@ + + echocmd="/bin/echo" + +-CommandFile="/usr/local/nagios/var/rw/nagios.cmd" ++CommandFile="/var/spool/nagios/" + + # get the current date/time in seconds since UNIX epoch + datetime=`date +%s` diff --git a/nagios-0013-fix-plugin.patch b/nagios-0013-fix-plugin.patch new file mode 100644 index 0000000000000000000000000000000000000000..f090665104f2b5b35138d789f55ee6173f717d71 --- /dev/null +++ b/nagios-0013-fix-plugin.patch @@ -0,0 +1,36 @@ +diff -up ./contrib/eventhandlers/distributed-monitoring/obsessive_svc_handler.fix_plugin ./contrib/eventhandlers/distributed-monitoring/obsessive_svc_handler +--- ./contrib/eventhandlers/distributed-monitoring/obsessive_svc_handler.fix_plugin 2017-08-24 17:43:48.000000000 -0400 ++++ ./contrib/eventhandlers/distributed-monitoring/obsessive_svc_handler 2017-09-19 15:21:28.201643586 -0400 +@@ -21,7 +21,7 @@ + # + + # Location of the submit_check_result_via_nsca script +-SubmitCmd="/usr/local/nagios/libexec/eventhandlers/submit_check_result_via_nsca" ++SubmitCmd="/usr/lib64/nagios/plugins/eventhandlers/submit_check_result_via_nsca" + + # Convert the state string to the corresponding return code + return_code=-1 +diff -up ./contrib/eventhandlers/redundancy-scenario1/handle-master-host-event.fix_plugin ./contrib/eventhandlers/redundancy-scenario1/handle-master-host-event +--- ./contrib/eventhandlers/redundancy-scenario1/handle-master-host-event.fix_plugin 2017-08-24 17:43:48.000000000 -0400 ++++ ./contrib/eventhandlers/redundancy-scenario1/handle-master-host-event 2017-09-19 15:21:28.202643604 -0400 +@@ -13,7 +13,7 @@ echocmd="/bin/echo" + mailcmd="/bin/mail" + + # Location of the event handlers +-eventhandlerdir="/usr/local/nagios/libexec/eventhandlers" ++eventhandlerdir="/usr/lib64/nagios/plugins/eventhandlers" + + + # Only take action on hard host states... +diff -up ./contrib/eventhandlers/redundancy-scenario1/handle-master-proc-event.fix_plugin ./contrib/eventhandlers/redundancy-scenario1/handle-master-proc-event +--- ./contrib/eventhandlers/redundancy-scenario1/handle-master-proc-event.fix_plugin 2017-08-24 17:43:48.000000000 -0400 ++++ ./contrib/eventhandlers/redundancy-scenario1/handle-master-proc-event 2017-09-19 15:21:28.203643623 -0400 +@@ -13,7 +13,7 @@ echocmd="/bin/echo" + mailcmd="/bin/mail" + + # Location of the event handlers +-eventhandlerdir="/usr/local/nagios/libexec/eventhandlers" ++eventhandlerdir="/usr/lib64/nagios/plugins/eventhandlers" + + + # Only take action on hard service states... diff --git a/nagios-0014-fix-uidgid.patch b/nagios-0014-fix-uidgid.patch new file mode 100644 index 0000000000000000000000000000000000000000..d88b8808f5bcc4777414978d665bd8f6be7c20c1 --- /dev/null +++ b/nagios-0014-fix-uidgid.patch @@ -0,0 +1,12 @@ +diff -up ./startup/default-service.in.fix_uidgid ./startup/default-service.in +--- ./startup/default-service.in.fix_uidgid 2019-02-22 11:57:38.432525592 -0500 ++++ ./startup/default-service.in 2019-02-22 11:58:03.823003073 -0500 +@@ -5,6 +5,8 @@ After=network.target local-fs.target + + [Service] + Type=forking ++User=nagios ++Group=nagios + ExecStartPre=@bindir@/nagios -v @sysconfdir@/nagios.cfg + ExecStart=@bindir@/nagios -d @sysconfdir@/nagios.cfg + ExecStop=@BIN_KILL@ -s TERM ${MAINPID} diff --git a/nagios-4.4.3.tar.gz b/nagios-4.4.3.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..d7621686ac0bbc9de0b6052be2d27682598db44e Binary files /dev/null and b/nagios-4.4.3.tar.gz differ diff --git a/nagios-socket.te b/nagios-socket.te new file mode 100644 index 0000000000000000000000000000000000000000..d9ed56b932589c330af23eda4e6a5585f79d04a5 --- /dev/null +++ b/nagios-socket.te @@ -0,0 +1,16 @@ +module nagios-socket 1.1; + +require { + type nagios_t; + type nagios_spool_t; + class sock_file { write create unlink }; + class unix_stream_socket connectto; +} + + +#============= nagios_t ============== + +#!!!! This avc is allowed in the current policy +allow nagios_t nagios_spool_t:sock_file { write create unlink }; +#!!!! This avc can be allowed using the boolean 'daemons_enable_cluster_mode' +allow nagios_t self:unix_stream_socket connectto; diff --git a/nagios.README.SELinux.rst b/nagios.README.SELinux.rst new file mode 100644 index 0000000000000000000000000000000000000000..c6535145be6f2b20b2792e471676fb6c7b7d4c3c --- /dev/null +++ b/nagios.README.SELinux.rst @@ -0,0 +1,19 @@ +================ +Nagios and SELinux +================ + +While there is an Nagios policy in the default Selinux policies, it does +not meet the needs of the current Nagios software. In working with the +SELinux security group, there is now a need for non-core packages to +carry their own policy in a spec file. + +Following the steps in +https://fedoraproject.org/wiki/SELinux/IndependentPolicy we are adding +the needed subpackage and files. + +This policy DOES NOT REPLACE THE CORE POLICY in the selinux-policies +package. This is only a supplement that the nrpe package needs due to +changes from the older base policy. + +Please report bugs as needed and we will try to get them fixed as soon +as possible. diff --git a/nagios.htaccess b/nagios.htaccess new file mode 100644 index 0000000000000000000000000000000000000000..4d96298c6b438f3193f21c4597691631e901604e --- /dev/null +++ b/nagios.htaccess @@ -0,0 +1,50 @@ +ScriptAlias /nagios/cgi-bin/ /usr/lib/nagios/cgi-bin/ + + Options ExecCGI + order deny,allow + deny from all + allow from 127.0.0.1 + AuthType Basic + AuthUserFile /etc/nagios/passwd + AuthName "nagios" + require valid-user + + +Alias /nagios/ /usr/share/nagios/html/ + + Options None + order deny,allow + deny from all + allow from 127.0.0.1 + AuthType Basic + AuthUserFile /etc/nagios/passwd + AuthName "nagios" + require valid-user + + +# For SSL-servers +# +# Options ExecCGI +# SSLRequireSSL +# order deny,allow +# deny from all +# allow from 127.0.0.1 +# AuthType Basic +# AuthUserFile /etc/nagios/passwd +# AuthName "nagios" +# require valid-user +# +# +#Alias /nagios/ /usr/share/nagios/html/ +# +# Options None +# SSLRequireSSL +# order deny,allow +# deny from all +# allow from 127.0.0.1 +# AuthType Basic +# AuthUserFile /etc/nagios/passwd +# AuthName "nagios" +# require valid-user +# + diff --git a/nagios.htpasswd b/nagios.htpasswd new file mode 100644 index 0000000000000000000000000000000000000000..8fd2ef0e2994e83f3fa711c087a052fa8ba180fa --- /dev/null +++ b/nagios.htpasswd @@ -0,0 +1,2 @@ +nagiosadmin:RbdO4ou4PNyMg + diff --git a/nagios.internet.cfg b/nagios.internet.cfg new file mode 100644 index 0000000000000000000000000000000000000000..19e2dfd01c9c39e5fe823394caa17cde14e7eb8d --- /dev/null +++ b/nagios.internet.cfg @@ -0,0 +1,55 @@ +############################################################################## +# internet.cfg - sample config file for Fedoras Nagios +# +# 2008-07-03 created Robert M. Albrecht +# +# NOTES: This config file is a sample for monitoring some internet hosts. +# +############################################################################### + +define host{ + name template-internet-host + use generic-host + register 0 + max_check_attempts 5 + contacts nagiosadmin + parents localhost + +} + +define host{ + use template-internet-host + host_name Google + address www.google.com + notes Googles Website defined by sample config + notes_url http://www.google.com + action_url http://en.wikipedia.org/wiki/Google + } + +define hostgroup{ + hostgroup_name InternetHosts + alias Internet Hosts + members Google + } + +define service{ + use generic-service + hostgroup_name InternetHosts + service_description PING + check_command check_ping!200.0,20%!600.0,60% + } + +define service{ + use generic-service + hostgroup_name InternetHosts + service_description HTTP + check_command check_http + } + +define servicegroup{ + servicegroup_name WebSites + alias Internet Hosts + members Google,PING,Google,HTTP + } + + diff --git a/nagios.logrotate b/nagios.logrotate new file mode 100644 index 0000000000000000000000000000000000000000..0fa52c87fc5e13c2986cce260e04963dc1531735 --- /dev/null +++ b/nagios.logrotate @@ -0,0 +1,15 @@ +# Important! Nagios rotates its own logs. Only enable this logrotate if you +# know what you are doing! + +# For more information please see "log_rotate_method" in: +# /etc/nagios/nagios.cfg + +# ----- logrotate config ------------- +#/var/log/nagios/*.log { +# missingok +# weekly +# notifempty +# nocompress +# create 644 nagios nagios +#} + diff --git a/nagios.spec b/nagios.spec new file mode 100644 index 0000000000000000000000000000000000000000..9e360c5837013d1bae9b2098d1b9a415a46a761f --- /dev/null +++ b/nagios.spec @@ -0,0 +1,291 @@ +#%global _hardened_build 1 + +Name: nagios +Version: 4.4.3 +Release: 5 +Summary: Host/service/network monitoring program +License: GPLv2 +URL: https://www.nagios.org/projects/nagios-core/ +Source0: https://github.com/NagiosEnterprises/nagioscore/archive/nagios-%{version}.tar.gz +Source1: nagios.logrotate +Source2: nagios.htaccess +Source3: nagios.internet.cfg +Source4: nagios.htpasswd +Source5: nagios.upgrade_to_v4.ReadMe +Source6: nagios.upgrade_to_v4.sh +Source8: nagios.tmpfiles.conf +Source10: printer.png +Source11: router.png +Source12: switch.png +Source13: nagios.README.SELinux.rst +Source14: nagios_epel7.te +Source15: nagios_epel.fc +Patch0001: nagios-0001-default-init.patch +Patch0002: nagios-0002-Fix-installation-of-httpd-conf.d-config-file.patch +Patch0003: nagios-0003-Install-config-files-too.patch +Patch0004: nagios-0004-Fix-path-to-CGI-executables.patch +Patch0005: nagios-0005-Fixed-path-to-passwd-file-in-Apache-s-config-file.patch +Patch0006: nagios-0006-Added-several-images-to-the-sample-config-revb.patch +Patch0008: nagios-0008-Add-cfg_dir-etc-nagios-conf.d-to-the-main-nagios-con.patch +Patch0009: nagios-0009-fix-localstatedir-for-linux.patch +Patch0010: nagios-0010-remove-information-leak.patch +Patch0011: nagios-0011-remove-rpmbuild.patch +Patch0012: nagios-0012-fix-spool.patch +Patch0013: nagios-0013-fix-plugin.patch +Patch0014: nagios-0014-fix-uidgid.patch +BuildRequires: doxygen gcc gperf libjpeg-devel libpng-devel zlib-devel gd-devel > 1.8 +BuildRequires: perl-generators perl(CPAN) perl(ExtUtils::MakeMaker) perl(ExtUtils::Embed) +BuildRequires: perl(Test::Harness) perl(Test::More) perl(Test::Simple) +BuildRequires: checkpolicy, selinux-policy-devel libtool systemd +Requires: httpd php mailx nagios-common +Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) + +%description +Nagios is a program that will monitor hosts and services on your +network. It has the ability to send email or page alerts 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 https://github.com/nagios-plugins/nagios-plugins +This package provides the core program, web interface, and documentation +files for Nagios. Development files are built as a separate package. + +%package common +Summary: Provides common directories, uid and gid among nagios-related packages +Requires(pre): shadow-utils +Requires(post): shadow-utils +Provides: user(nagios) +Provides: group(nagios) + +%description common +Provides common directories, uid and gid among nagios-related packages. + +%package devel +Summary: Provides include files that Nagios-related applications may compile against +Requires: nagios = 4.4.3-%release + +%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. + +%package selinux +Summary: SELinux context for nagios +Requires: nagios = 4.4.3-%release +Requires(post): policycoreutils +Requires(postun): policycoreutils + + +%description selinux +SElinux context for nagios. + +%package contrib +Summary: Eventhandlers contributed to nagios +Requires: nagios = 4.4.3-%release + +%description contrib +Various contributed items used by plugins and other tools. + +%prep +%autosetup -n nagioscore-nagios-4.4.3 -p1 + +install -p -m 0644 %{SOURCE10} %{SOURCE11} %{SOURCE12} html/images/logos/ + +%build +%configure \ + --prefix=%{_datadir}/%{name} \ + --exec-prefix=%{_localstatedir}/lib/%{name} \ + --libdir=%{_libdir}/%{name} \ + --bindir=%{_sbindir} \ + --datadir=%{_datadir}/%{name}/html \ + --libexecdir=%{_libdir}/%{name}/plugins \ + --localstatedir=%{_localstatedir} \ + --with-checkresult-dir=%{_localstatedir}/spool/%{name}/checkresults \ + --with-cgibindir=%{_libdir}/nagios/cgi \ + --sysconfdir=%{_sysconfdir}/%{name} \ + --with-cgiurl=/%{name}/cgi-bin \ + --with-command-user=apache \ + --with-command-group=apache \ + --with-gd-lib=%{_libdir} \ + --with-gd-inc=%{_includedir} \ + --with-htmlurl=/%{name} \ + --with-lockfile=%{_localstatedir}/run/%{name}/%{name}.pid \ + --with-mail=/usr/bin/mail \ + --with-initdir=%{_unitdir} \ + --with-init-type=systemd \ + --with-nagios-user=nagios \ + --with-nagios-grp=nagios \ + --with-template-objects \ + --with-template-extinfo \ + --enable-event-broker \ + STRIP=/bin/true +make %{?_smp_mflags} all +%{__make} dox +%{__make} %{?_smp_mflags} -C contrib + +sed -e "s|/usr/lib/|%{_libdir}/|" %{SOURCE2} > %{name}.htaccess +cp -f %{SOURCE3} internet.cfg +cp -f %{SOURCE5} UpgradeToVersion4.ReadMe +cp -f %{SOURCE6} UpgradeToVersion4.sh +echo >> html/stylesheets/common.css + +mkdir selinux +install -pm 644 %{SOURCE13} README.SELinux.rst +cp -p %{SOURCE14} selinux/%{name}_epel.te +cp -p %{SOURCE15} selinux/%{name}_epel.fc +touch selinux/%{name}_epel.if +make -f %{_datadir}/selinux/devel/Makefile + +%install +rm -rf $RPM_BUILD_ROOT +make DESTDIR=%{buildroot} INIT_OPTS="" INSTALL_OPTS="" COMMAND_OPTS="" CGIDIR="%{_libdir}/%{name}/cgi-bin" CFGDIR="%{_sysconfdir}/%{name}" fullinstall +install -d -m 0755 %{buildroot}%{_bindir} +mv %{buildroot}%{_sbindir}/nagiostats %{buildroot}%{_bindir}/nagiostats +install -d -m 0755 %{buildroot}%{_sysconfdir}/%{name}/private +mv %{buildroot}%{_sysconfdir}/%{name}/resource.cfg %{buildroot}%{_sysconfdir}/%{name}/private/resource.cfg +install -D -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/%{name}/passwd +install -D -m 0644 include/locations.h %{buildroot}%{_includedir}/%{name}/locations.h +install -D -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} +install -d -m 0755 %{buildroot}%{_libdir}/%{name}/plugins/eventhandlers +install -d -m 0755 %{buildroot}%{_libdir}/%{name}/plugins/eventhandlers/distributed-monitoring/ +install -d -m 0755 %{buildroot}%{_libdir}/%{name}/plugins/eventhandlers/redundancy-scenario1/ +install -d -m 0775 %{buildroot}%{_localstatedir}/spool/%{name}/cmd +install -d -m 0775 %{buildroot}%{_localstatedir}/run/%{name} +install -d -m 0775 %{buildroot}%{_localstatedir}/run/%{name} +install -d -m 0775 %{buildroot}/%{_localstatedir}/log/ +install -d -m 0775 %{buildroot}/%{_localstatedir}/log/%{name}/ +install -d -m 0775 %{buildroot}/%{_localstatedir}/log/%{name}/archives +install -D -m 0644 -p %{SOURCE8} %{buildroot}%{_tmpfilesdir}/%{name}.conf +rm -f %{buildroot}%{_initrddir}/nagios + +chmod 755 %{buildroot}%{_sbindir}/nagios +install -d -m 0755 %{buildroot}%{_datadir}/nagios/html/docs +%{__cp} -a Documentation/html/* %{buildroot}%{_datadir}/nagios/html/docs + +install -p -m 644 -D %{name}_epel.pp $RPM_BUILD_ROOT%{_datadir}/selinux/packages/%{name}/%{name}_epel.pp + +make install -C contrib DESTDIR="%{buildroot}" INSTALL_OPTS="" +install -p -m 644 contrib/eventhandlers/disable_active_service_checks %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/ +install -p -m 644 contrib/eventhandlers/disable_notifications %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/ +install -p -m 644 contrib/eventhandlers/enable_active_service_checks %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/ +install -p -m 644 contrib/eventhandlers/enable_notifications %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/ +install -p -m 644 contrib/eventhandlers/submit_check_result %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/ + +install -p -m 644 contrib/eventhandlers/distributed-monitoring/obsessive_svc_handler %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/distributed-monitoring/ +install -p -m 644 contrib/eventhandlers/distributed-monitoring/submit_check_result_via_nsca %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/distributed-monitoring/ +install -p -m 644 contrib/eventhandlers/redundancy-scenario1/handle-master-host-event %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/redundancy-scenario1/ +install -p -m 644 contrib/eventhandlers/redundancy-scenario1/handle-master-proc-event %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/redundancy-scenario1/ + +%{__mv} contrib/README contrib/README.contrib + +%pre common +getent group nagios >/dev/null || groupadd -r nagios +getent passwd nagios >/dev/null || useradd -r -g nagios -d %{_localstatedir}/spool/%{name} -s /sbin/nologin nagios +exit 0 + +%post +%{_sbindir}/usermod -a -G %{name} apache || : + +%systemd_post %{name}.service > /dev/null 2>&1 || : +/usr/bin/systemctl condrestart httpd > /dev/null 2>&1 || : +if [ $1 -gt 1 ]; then + /usr/bin/systemctl reload nagios > /dev/null 2>&1 || : +fi + +%preun +%systemd_preun %{name}.service +if [ $1 -eq 0 ]; then + /sbin/service %{name} stop >/dev/null 2>&1 || : + /sbin/chkconfig --del %{name} || : +fi + +%postun +/usr/bin/systemctl condrestart httpd > /dev/null 2>&1 || : + +%post selinux +if [ "$1" -le "1" ]; then # First install + semodule -i %{_datadir}/selinux/packages/%{name}/%{name}_epel.pp 2>/dev/null || : + fixfiles -R %{name} restore || : + %systemd_postun_with_restart %{name}.service +fi + +%preun selinux +if [ "$1" -lt "1" ]; then # Final removal + semodule -r %{name}_epel 2>/dev/null || : + fixfiles -R %{name} restore || : + %systemd_postun_with_restart %{name}.service +fi + +%postun selinux +if [ "$1" -ge "1" ]; then # Upgrade + # Replaces the module if it is already loaded + semodule -i %{_datadir}/selinux/packages/%{name}/%{name}_epel.pp 2>/dev/null || : + # no need to restart the daemon +fi + +%files +%dir %{_libdir}/%{name}/cgi-bin +%dir %{_datadir}/%{name} +%dir %{_datadir}/%{name}/html +%doc %{_datadir}/%{name}/html/docs +%doc Changelog INSTALLING LICENSE README.md UPGRADING UpgradeToVersion4.ReadMe UpgradeToVersion4.sh +%doc internet.cfg +%{_datadir}/%{name}/html/[^cd]* +%{_datadir}/%{name}/html/contexthelp/ +%{_datadir}/%{name}/html/d3/ + +%{_sbindir}/* +%{_bindir}/* +%{_libdir}/%{name}/cgi-bin/*cgi +%if 0%{?el7} +%{_unitdir}/%{name}.service +%{_tmpfilesdir}/%{name}.conf +%else +%{_initrddir}/nagios +%endif +%config(noreplace) %{_sysconfdir}/httpd/conf.d/nagios.conf +%config(noreplace) %{_sysconfdir}/logrotate.d/%{name} +%config(noreplace) %{_sysconfdir}/%{name}/*cfg +%config(noreplace) %{_sysconfdir}/%{name}/objects/*cfg +%attr(0750,root,nagios) %dir %{_sysconfdir}/%{name}/private +%attr(0750,root,nagios) %dir %{_sysconfdir}/%{name}/objects + +%attr(0640,root,nagios) %config(noreplace) %{_sysconfdir}/%{name}/private/resource.cfg +%attr(0640,root,apache) %config(noreplace) %{_sysconfdir}/%{name}/passwd +%attr(0640,root,apache) %config(noreplace) %{_datadir}/%{name}/html/config.inc.php +%attr(2775,nagios,nagios) %dir %{_localstatedir}/spool/%{name}/cmd +%attr(0750,nagios,nagios) %dir %{_localstatedir}/run/%{name} +%attr(0750,nagios,nagios) %dir %{_localstatedir}/log/%{name} +%attr(0750,nagios,nagios) %dir %{_localstatedir}/log/%{name}/archives +%attr(0770,nagios,nagios) %dir %{_localstatedir}/spool/%{name}/checkresults + +%files common +%dir %{_sysconfdir}/%{name} +%dir %{_libdir}/%{name} +%attr(0755,root,root) %dir %{_libdir}/%{name}/plugins +%attr(0755,root,root) %dir %{_libdir}/%{name}/plugins/eventhandlers/ +%attr(0755,nagios,nagios) %dir %{_localstatedir}/spool/%{name} + +%files devel +%{_includedir}/%{name} +%attr(0644,root,root) %{_libdir}/%{name}/libnagios.a + +%files selinux +%doc README.SELinux.rst +%{_datadir}/selinux/packages/%{name}/nagios_epel.pp + +%files contrib +%doc contrib/README.contrib +%attr(0750,root,root) %{_libdir}/%{name}/plugins/eventhandlers/* +%{_libdir}/%{name}/cgi/ + +%changelog +* Thu Dec 9 2019 openEuler Buildteam - 4.4.3-5 +- Package init diff --git a/nagios.tmpfiles.conf b/nagios.tmpfiles.conf new file mode 100644 index 0000000000000000000000000000000000000000..0153653b7e622c541a3c3eae6c954f7a4886fd63 --- /dev/null +++ b/nagios.tmpfiles.conf @@ -0,0 +1 @@ +d /var/run/nagios 0755 nagios nagios - diff --git a/nagios.upgrade_to_v4.ReadMe b/nagios.upgrade_to_v4.ReadMe new file mode 100644 index 0000000000000000000000000000000000000000..4f44871bd6e53162d0311dc5effce3a60bce3448 --- /dev/null +++ b/nagios.upgrade_to_v4.ReadMe @@ -0,0 +1,22 @@ +Nagios v4 Upgrade Considerations +================================ + +This applies if you are upgrading from Nagios v2 or v3. + +The Nagios v2 or v3 nagios.cfg is will not pass a Nagios v4 syntax check without modification. Also note that Nagios Core v4 has more strict host/service definition requirements. +The following attributes from Nagios v2 or v3 are incompatible with Nagios v4 and will generate an error. + +use_embedded_perl_implicitly +sleep_time +p1_file +external_command_buffer_slots +enable_embedded_perl +command_check_interval + +In order to force a Nagios v2 or v3 nagios.cfg file to run with Nagios v4 simply commment out these nagios.cfg lines. + +The included script UpgradeToVersion4.sh will do this automatically for the file +/etc/nagios/nagios.cfg (the standard location for the nagios.cfg file) + +This is a work-around and you should consider implementing the new nagios.cfg file. + diff --git a/nagios.upgrade_to_v4.sh b/nagios.upgrade_to_v4.sh new file mode 100644 index 0000000000000000000000000000000000000000..d510f585bf3657574403d884c044beb01179cc14 --- /dev/null +++ b/nagios.upgrade_to_v4.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# this script checks the nagios.cfg file and comments out several lines in accordance with the README. +# You will want to migrate to the Nagios v4 nagios.cfg file as soon as possible to take advantage of new features. + + +# this is the nagios.cfg file we will modify +nagios_cfg=/etc/nagios/nagios.cfg + +tmp1=`mktemp /tmp/nagios.cfg.XXXXXXXX` +cat $nagios_cfg > $tmp1 + +# search for and replace the check_result_buffer_slots attribute into a temporary file +sed -i --regexp-extended -e "s/^(\s*check_result_buffer_slots\s*=\s*)/# Line Commented out for Nagios v4 Compatibility\n#\1/g" \ + -e 's/^(\s*use_embedded_perl_implicitly\s*=\s*)/# Line Commented out for Nagios v4 Compatibility\n#\1/g' \ + -e 's/^(\s*sleep_time\s*=\s*)/# Line Commented out for Nagios v4 Compatibility\n#\1/g' \ + -e 's/^(\s*p1_file\s*=\s*)/# Line Commented out for Nagios v4 Compatibility\n#\1/g' \ + -e 's/^(\s*external_command_buffer_slots\s*=\s*)/# Line Commented out for Nagios v4 Compatibility\n#\1/g' \ + -e 's/^(\s*enable_embedded_perl\s*=\s*)/# Line Commented out for Nagios v4 Compatibility\n#\1/g' \ + -e 's/^(\s*command_check_interval\s*=\s*)/# Line Commented out for Nagios v4 Compatibility\n#\1/g' \ + -e 's|^(\s*#?query_socket\s*=\s*/var/log/nagios/rw/nagios.qh)|query_socket=/var/spool/nagios/cmd/nagios.qh|' $tmp1 + +# add query_socket if none exist +grep -q -F 'query_socket' $tmp1 || echo 'query_socket=/var/spool/nagios/cmd/nagios.qh' >> $tmp1 + +# check the diff +diff_output=`diff -u $nagios_cfg $tmp1` +diff_exit=$? + +# Decide whether or not to replace the file +if [ "$diff_exit" = "0" ]; then + echo "No changes were made to the Nagios Config file: $nagios_cfg" +elif [ "$diff_exit" = "1" ]; then + echo "The following changes were made to the Nagios Config file: $nagios_cfg" + echo "previous config has been saved to $nagios_cfg.oldrpm" + echo "$diff_output" + + # since changes were made, move the temp file into place + cp $nagios_cfg $nagios_cfg.oldrpm + cat $tmp1 > $nagios_cfg +else + echo "ERROR: Unexpected exit code from diff. No changes made to file: $nagios_cfg" +fi + +rm -f $tmp1 + diff --git a/nagios_epel.fc b/nagios_epel.fc new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/nagios_epel7.te b/nagios_epel7.te new file mode 100644 index 0000000000000000000000000000000000000000..a325233659089ed0fab787abf6d9447d74176684 --- /dev/null +++ b/nagios_epel7.te @@ -0,0 +1,39 @@ +module nagios_epel 1.1; + +require { + type devlog_t; + type hostname_exec_t; + type kernel_t; + type ldconfig_exec_t; + type initrc_tmp_t; + type nagios_exec_t; + type nagios_script_t; + type nagios_services_plugin_t; + type nagios_spool_t; + type nagios_system_plugin_t; + type nagios_t; + class capability chown; + class file { execute execute_no_trans getattr open read }; + class sock_file { write create unlink }; + class unix_dgram_socket { connect create sendto }; + class unix_stream_socket connectto; +} + +#============= nagios_services_plugin_t ============== +allow nagios_services_plugin_t devlog_t:sock_file write; +allow nagios_services_plugin_t kernel_t:unix_dgram_socket sendto; +allow nagios_services_plugin_t self:unix_dgram_socket { connect create }; + +#============= nagios_t ============== +allow nagios_t hostname_exec_t:file { read getattr open execute execute_no_trans }; +allow nagios_t ldconfig_exec_t:file { execute execute_no_trans open read }; +allow nagios_t nagios_exec_t:file execute_no_trans; +allow nagios_t nagios_spool_t:sock_file { write create unlink }; +allow nagios_t self:capability chown; +allow nagios_t self:unix_stream_socket connectto; + +#============= nagios_script_t ============== +allow nagios_script_t nagios_spool_t:file { getattr open read }; + +#============= nagios_system_plugin_t ============== +allow nagios_system_plugin_t nagios_spool_t:file { getattr open read }; diff --git a/printer.png b/printer.png new file mode 100644 index 0000000000000000000000000000000000000000..e00c62f8f1d0526de71e7c91385908cfd72d3d8f Binary files /dev/null and b/printer.png differ diff --git a/router.png b/router.png new file mode 100644 index 0000000000000000000000000000000000000000..c3927445a4966373cbaf619ab625b606f70a7ba9 Binary files /dev/null and b/router.png differ diff --git a/switch.png b/switch.png new file mode 100644 index 0000000000000000000000000000000000000000..753bae98307adad3b6f67bfc54b22c03e3aa93df Binary files /dev/null and b/switch.png differ