nagios客户端一般需要nagios-plugins,nrpe,为了方便与puppet结合,所以最好把源码打包成软件包
- %define name nrpe
- %define version 2.13
- %define release 10
- %define nsusr nagios
- %define nsgrp nagios
- %define nsport 5666
- # Reserve option to override port setting with:
- # rpm -ba|--rebuild --define 'nsport 5666'
- %{?port:%define nsport %{port}}
- # Macro that print mesages to syslog at package (un)install time
- %define nnmmsg logger -t %{name}/rpm
- Summary: Host/service/network monitoring agent for Nagios
- URL: http://www.nagios.org
- Name: %{name}
- Version: %{version}
- Release: %{release}
- License: GPL
- Group: Application/System
- Source0: %{name}-%{version}.tar.gz
- BuildRoot: %{_tmppath}/%{name}-buildroot
- Prefix: %{_prefix}
- Prefix: /usr/local/nagios
- Requires: bash, grep, nagios-plugins,xinetd
- PreReq: /usr/bin/logger, chkconfig, sh-utils, shadow-utils, sed, initscripts, fileutils, mktemp
- %description
- Nrpe is a system daemon that will execute various Nagios plugins
- locally on behalf of a remote (monitoring) host that uses the
- check_nrpe plugin. Various plugins that can be executed by the
- daemon are available at:
- %prep
- %setup -q
- %pre
- if [ $? -eq 2 ] ; then
- /usr/sbin/groupadd %{nsgrp} || %nnmmsg Unexpected error adding group "%{nyysgrp}". Aborting install process.
- fi
- # Create `nagios' user on the system if necessary
- if [ $? -eq 2 ] ; then
- /usr/sbin/useradd -d %{nsgrp} -s /bin/nologin -c "%{nsusr}" -g %{nsgrp} %{nsusr} || \
- %nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process.
- fi
- %post
- if [ "$1" = 1 ]; then
- chown -R "%{nsusr}":"%{nsgrp}" %{_prefix}
- chkconfig --add xinetd
- chkconfig xinetd on
- echo "nrpe 5666/tcp #nrpe" >> /etc/services
- /sbin/service xinetd restart > /dev/null 2>&1
- fi
- %preun
- if [ "$1" = 0 ]; then
- /bin/rm /etc/xinetd.d/nrpe -f
- sed -i '/^nrpe.*/d' /etc/services
- fi
- %postun
- if [ "$1" = 0 ]; then
- /sbin/service xinetd restart >/dev/null 2>&1 || :
- fi
- %build
- export PATH=$PATH:/usr/sbin
- CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \
- ./configure \
- --with-init-dir=/etc/init.d \
- --with-nrpe-port=%{nsport} \
- --with-nrpe-user=%{nsusr} \
- --with-nrpe-group=%{nsgrp} \
- --prefix=%{_prefix} \
- --exec-prefix=%{_prefix}/bin \
- --bindir=%{_prefix}/bin \
- --sbindir=%{_prefix}/lib/nagios/cgi \
- --libexecdir=%{_prefix}/libexec \
- --datadir=%{_prefix}/share \
- --sysconfdir=/etc/nagios \
- --localstatedir=/var/log/nagios \
- --enable-command-args
- make all
- %install
- [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
- install -d -m 0755 ${RPM_BUILD_ROOT}/etc/xinetd.d
- install -c -m 0755 -d ${RPM_BUILD_ROOT}/usr/local/nagios/libexec
- install -c -m 0755 src/check_nrpe ${RPM_BUILD_ROOT}/usr/local/nagios/libexec
- install -c -m 0755 -d ${RPM_BUILD_ROOT}/usr/local/nagios/bin
- install -c -m 0755 src/nrpe ${RPM_BUILD_ROOT}/usr/local/nagios/bin
- install -c -m 0755 -d ${RPM_BUILD_ROOT}/usr/local/nagios/etc
- install -c -m 0755 sample-config/nrpe.cfg ${RPM_BUILD_ROOT}/usr/local/nagios/etc/nrpe.cfg
- install -c -m 0644 sample-config/nrpe.xinetd ${RPM_BUILD_ROOT}/etc/xinetd.d/nrpe
- sed -i 's#server_args.*#server_args = -c %{_prefix}/etc/nrpe.cfg --inetd#' ${RPM_BUILD_ROOT}/etc/xinetd.d/nrpe
- %clean
- rm -rf $RPM_BUILD_ROOT
- %files
- %defattr(755,root,root)
- %{_prefix}/bin/nrpe
- %defattr(644,root,root)
- %config(noreplace) /usr/local/nagios/etc/*.cfg
- %config(noreplace) /etc/xinetd.d/nrpe
- %defattr(755,%{nsusr},%{nsgrp})
- %doc Changelog LEGAL README
- %doc %{_prefix}/libexec
- %changelog
- * Wed Apr 3 2013 xxx build - 2.13-10 <xxx@xxx.com>
- - fixed nrpe.cfg relocation to sample-config
- # Macros
- %define isaix %(test "`uname -s`" = "AIX" && echo "1" || echo "0")
- %define islinux %(test "`uname -s`" = "Linux" && echo "1" || echo "0")
- %define isredhatfamily %(test -f /etc/redhat-release && echo "1" || echo "0")
- %if %{isaix}
- %define _prefix /usr/local/nagios
- # %define _defaultdocdir %{_datadir}/doc
- %else
- %define _libexecdir %{_exec_prefix}/libexec
- %endif
- %define _sysconfdir /usr/local/nagios/etc
- %define npusr nagios
- %define nphome /home/nagios
- %define npgrp nagios
- Name: nagios-plugins
- Version: 1.4.16
- Release: 10
- Summary: Host/service/network monitoring program plugins for Nagios
- Group: Applications/System
- License: GPL
- URL: http://nagiosplug.sourceforge.net/
- Source0: http://dl.sf.net/sourceforge/nagiosplug/%{name}-%{version}.tar.gz
- BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
- %define npdir %{_builddir}/%{name}-%{version}
- %if %{isaix}
- Prefix: %{_prefix}
- %else
- Prefix: %{_prefix}/lib/nagios/plugins
- %endif
- Packager: Karl DeBisschop <kdebisschop@users.sourceforge.net>
- Vendor: Nagios Plugin Development Group
- Provides: nagios-plugins
- %{!?custom:%global custom 0}
- Obsoletes: nagios-plugins-custom nagios-plugins-extras
- # Requires
- %if %{isaix}
- Requires: fping
- Requires: gawk
- Requires: net-snmp
- Requires: net-snmp-perl
- Requires: net-snmp-utils
- Requires: openldap
- Requires: openssl
- Requires: perl
- Requires: python
- Requires: openssl
- BuildRequires: fping
- BuildRequires: gawk
- BuildRequires: net-snmp
- BuildRequires: net-snmp-perl
- BuildRequires: net-snmp-utils
- BuildRequires: openldap-devel
- %endif
- %if %{isredhatfamily}
- Requires: bind-utils
- Requires: coreutils
- Requires: fping
- Requires: gawk
- Requires: grep
- Requires: iputils
- Requires: mysql
- Requires: net-snmp-utils
- Requires: ntp
- Requires: openldap
- Requires: openssl
- Requires: openssh-clients
- Requires: perl
- Requires: postgresql-libs
- Requires: procps
- Requires: python
- Requires: samba-client
- Requires: shadow-utils
- Requires: traceroute
- Requires: /usr/bin/mailq
- BuildRequires: bind-utils
- BuildRequires: coreutils
- BuildRequires: iputils
- BuildRequires: mysql-devel
- BuildRequires: net-snmp-utils
- BuildRequires: net-tools
- BuildRequires: ntp
- BuildRequires: openldap-devel
- BuildRequires: openssh-clients
- BuildRequires: openssl-devel
- BuildRequires: postgresql-devel
- BuildRequires: procps
- BuildRequires: samba-client
- BuildRequires: /usr/bin/mailq
- %endif
- %description
- Nagios is a program that will monitor hosts and services on your
- network, and to email or page you when a problem arises or is
- resolved. Nagios runs on a unix server as a background or daemon
- 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
- contains those plugins.
- %prep
- %setup -q
- %build
- %{?isaix: MAKE=gmake} ./configure \
- --prefix=%{_prefix} \
- --exec-prefix=%{_exec_prefix} \
- --libexecdir=%{_libexecdir} \
- --sysconfdir=%{_sysconfdir} \
- --datadir=%{_datadir} \
- #--with-cgiurl=/nagios/cgi-bin
- ls -1 %{npdir}/plugins > %{npdir}/ls-plugins-before
- ls -1 %{npdir}/plugins-root > %{npdir}/ls-plugins-root-before
- ls -1 %{npdir}/plugins-scripts > %{npdir}/ls-plugins-scripts-before
- make %{?_smp_mflags}
- ls -1 %{npdir}/plugins > %{npdir}/ls-plugins-after
- ls -1 %{npdir}/plugins-root > %{npdir}/ls-plugins-root-after
- ls -1 %{npdir}/plugins-scripts > %{npdir}/ls-plugins-scripts-after
- %pre
- # Create `nagios' group on the system if necessary
- %if %{isaix}
- lsgroup %{npgrp} > /dev/null 2> /dev/null
- if [ $? -eq 2 ] ; then
- mkgroup %{npgrp} || %nnmmsg Unexpected error adding group "%{npgrp}". Aborting install process.
- fi
- %endif
- %if %{islinux}
- getent group %{npgrp} > /dev/null 2> /dev/null
- if [ $? -ne 0 ] ; then
- groupadd %{npgrp} || %nnmmsg Unexpected error adding group "%{npgrp}". Aborting install process.
- fi
- %endif
- # Create `nagios' user on the system if necessary
- %if %{isaix}
- lsuser %{npusr} > /dev/null 2> /dev/null
- if [ $? -eq 2 ] ; then
- useradd -d %{nphome} -s /bin/nologin -c "%{npusr}" -g %{npgrp} %{npusr} || \
- %nnmmsg Unexpected error adding user "%{npusr}". Aborting install process.
- fi
- %endif
- %if %{islinux}
- getent passwd %{npusr} > /dev/null 2> /dev/null
- if [ $? -ne 0 ] ; then
- useradd -r -d %{nphome} -s /bin/nologin -c "%{npusr}" -g %{npgrp} %{npusr} || \
- %nnmmsg Unexpected error adding user "%{npusr}". Aborting install process.
- fi
- %endif
- %post
- chown -R "%{npusr}":"%{npgrp}" %{_prefix}
- %install
- rm -rf $RPM_BUILD_ROOT
- make AM_INSTALL_PROGRAM_FLAGS="" DESTDIR=${RPM_BUILD_ROOT} install
- build-aux/install-sh -c -d ${RPM_BUILD_ROOT}%{_sysconfdir}
- build-aux/install-sh -c -m 664 command.cfg ${RPM_BUILD_ROOT}%{_sysconfdir}
- %find_lang %{name}
- echo "%defattr(755,%{npusr},%{npgrp})" >> %{name}.lang
- comm -13 %{npdir}/ls-plugins-before %{npdir}/ls-plugins-after | egrep -v "\.o$|^\." | gawk -v libexecdir=%{_libexecdir} '{printf( "%s/%s\n", libexecdir, $0);}' >> %{name}.lang
- echo "%defattr(755,root,root)" >> %{name}.lang
- comm -13 %{npdir}/ls-plugins-root-before %{npdir}/ls-plugins-root-after | egrep -v "\.o$|^\." | gawk -v libexecdir=%{_libexecdir} '{printf( "%s/%s\n", libexecdir, $0);}' >> %{name}.lang
- echo "%defattr(755,%{npusr},%{npgrp})" >> %{name}.lang
- comm -13 %{npdir}/ls-plugins-scripts-before %{npdir}/ls-plugins-scripts-after | egrep -v "\.o$|^\." | gawk -v libexecdir=%{_libexecdir} '{printf( "%s/%s\n", libexecdir, $0);}' >> %{name}.lang
- echo "%{_libexecdir}/utils.pm" >> %{name}.lang
- echo "%{_libexecdir}/utils.sh" >> %{name}.lang
- %clean
- rm -rf $RPM_BUILD_ROOT
- %files -f %{name}.lang
- %doc CODING COPYING FAQ INSTALL LEGAL README REQUIREMENTS SUPPORT THANKS
- %doc ChangeLog
- %if ! %{isaix}
- %{_datadir}/locale/de/LC_MESSAGES/nagios-plugins.mo
- %{_datadir}/locale/fr/LC_MESSAGES/nagios-plugins.mo
- /usr/local/nagios/libexec/check_ldaps
- /usr/local/nagios/etc/command.cfg
- %endif
- %changelog
- * Wed Apr 3 2013 xxx build - 1.4.16-10 <xxx@xxx.com>
- - Initial Package
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。