소스 검색

add/improve fsl support; fix typos; use openlog(2); inhibit use of plain log file

Thomas Lotterer 23 년 전
부모
커밋
9c3fcf9cb2
4개의 변경된 파일65개의 추가작업 그리고 11개의 파일을 삭제
  1. 2 2
      nagios/fsl.nagios
  2. 23 0
      nagios/nagios.patch
  3. 25 9
      nagios/nagios.spec
  4. 15 0
      nagios/rc.nagios

+ 2 - 2
nagios/fsl.nagios

@@ -2,13 +2,13 @@
 ##  fsl.nagios -- OSSP fsl configuration for Nagios
 ##
 
-ident (nagio)/.+ q{
+ident (nagios)/.+ q{
     prefix(
         prefix="%b %d %H:%M:%S %N <%L> $1[%P]: "
     ) 
     -> {
         debug: file(
-            path="@l_prefix@/var/nagio/nagios.log",
+            path="@l_prefix@/var/nagios/nagios.log",
             append=1, perm=0644
         )
     }

+ 23 - 0
nagios/nagios.patch

@@ -0,0 +1,23 @@
+--- base/logging.c.orig	Tue Feb 26 05:03:28 2002
++++ base/logging.c	Wed Jun 25 14:02:52 2003
+@@ -130,6 +130,7 @@
+ 
+ /* write something to the syslog facility */
+ int write_to_syslog(char *buffer, unsigned long data_type){
++    static logopen = 0;
+ 
+ #ifdef DEBUG0
+ 	printf("write_to_syslog() start\n");
+@@ -142,6 +143,12 @@
+ 	/* make sure we should log this type of entry */
+ 	if(!(data_type & syslog_options))
+ 		return OK;
++
++	/* fsl identification */
++    if (!logopen) {
++        openlog("nagios", LOG_NDELAY, LOG_USER);
++        logopen = 1;
++    }
+ 
+ 	/* write the buffer to the syslog facility */
+ 	syslog(LOG_USER|LOG_INFO,"%s",buffer);

+ 25 - 9
nagios/nagios.spec

@@ -33,18 +33,26 @@ Distribution: OpenPKG [EVAL]
 Group:        Network
 License:      GNU
 Version:      1.1
-Release:      20030603
+Release:      20030625
+
+#   package options
+%option       with_fsl  yes
 
 #   list of sources
 Source0:      http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-%{version}.tar.gz
 Source1:      rc.nagios
-Patch0:       fsl.nagios
+Source2:      fsl.nagios
+Patch0:       nagios.patch
 
 #   build information
 Prefix:       %{l_prefix}
 BuildRoot:    %{l_buildroot}
-BuildPreReq:  OpenPKG, openpkg >= 20030310, gd, jpeg, png, zlib, traceroute
-PreReq:       OpenPKG, openpkg >= 20030310, apache, traceroute
+BuildPreReq:  OpenPKG, openpkg >= 20030415, gd, jpeg, png, zlib, traceroute
+PreReq:       OpenPKG, openpkg >= 20030415, apache, traceroute
+%if "%{with_fsl}" == "yes"
+BuildPreReq:  fsl
+PreReq:       fsl
+%endif
 AutoReq:      no
 AutoReqProv:  no
 
@@ -55,6 +63,7 @@ AutoReqProv:  no
 
 %prep
     %setup -q
+    %patch
 
 %build
     %{l_shtool} subst \
@@ -63,10 +72,14 @@ AutoReqProv:  no
         -e 's;sysconfdir=.\${prefix}/etc.;sysconfdir="'%{l_prefix}'/etc/nagios";g' \
         -e 's;libexecdir=.\${prefix}/libexec.;libexecdir="'%{l_prefix}'/libexec/nagios";g' \
         configure
+    %{l_shtool} subst \
+        -e 's;log_file=.*;log_file=/dev/null;' \
+        sample-config/nagios.cfg.in
     echo "ac_cv_path_PATH_TO_TRACEROUTE=%{l_prefix}/sbin/traceroute}" >config.cache
     CC="%{l_cc}" \
     CFLAGS="%{l_cflags -O}" \
-    LDFLAGS="%{l_ldflags}" \
+    LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}" \
+    PERLLIBS="%{l_fsl_libs}" \
     ./configure \
         --prefix=%{l_prefix} \
         --with-cgiurl=%{l_prefix}/cgi/nagios \
@@ -90,7 +103,6 @@ AutoReqProv:  no
     %{l_shtool} mkdir -f -p -m 755 \
         $RPM_BUILD_ROOT%{l_prefix}/etc/nagios \
         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
-        $RPM_BUILD_ROOT%{l_prefix}/etc/fsl \
         $RPM_BUILD_ROOT%{l_prefix}/sbin \
         $RPM_BUILD_ROOT%{l_prefix}/var/nagios/rw \
         $RPM_BUILD_ROOT%{l_prefix}/libexec/nagios \
@@ -165,14 +177,18 @@ AutoReqProv:  no
         -e 's;@l_susr@;%{l_susr};g' \
         %{SOURCE rc.nagios} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
 
-    #   install fsl
+    #   OSSP fake syslog library
+    %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
     %{l_shtool} install -c -m 644 \
         -e 's;@l_prefix@;%{l_prefix};g' \
-        %{SOURCE fsl.nagios} $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
+        %{SOURCE fsl.%{name}} \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
 
+    #   determine installation files
     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
         %{l_files_std} \
-        '%not %dir %{l_prefix}/etc/fsl'
+        '%not %dir %{l_prefix}/etc/fsl' \
+        '%config %{l_prefix}/etc/fsl/fsl.%{name}'
 
 %files -f files
 

+ 15 - 0
nagios/rc.nagios

@@ -6,6 +6,11 @@
 %config
     nagios_enable="yes"
     nagios_cfg="nagios.cfg"
+    nagios_log_prolog="true"
+    nagios_log_epilog="true"
+    nagios_log_numfiles="10"
+    nagios_log_minsize="1M"
+    nagios_log_complevel="9"
 
 %start -p 200
     opServiceEnabled nagios || exit 0
@@ -31,3 +36,13 @@
         kill -HUP `cat @l_prefix@/var/nagios/nagios.lock`
     fi
 
+%daily -u @l_susr@
+    opServiceEnabled nagios || exit 0
+
+    #   rotate logfile
+    shtool rotate -f \
+        -n${nagios_log_numfiles} -s${nagios_log_minsize} -d \
+        -z${nagios_log_complevel} -o@l_rusr@ -g@l_rgrp@ -m644 \
+        -P "${nagios_log_prolog}" \
+        -E "${nagios_log_epilog}" \
+        @l_prefix@/var/nagios/nagios.log