rpmbuild使用---创建nrpe,nagios-plugins软件包
nagios客户端一般需要nagios-plugins,nrpe,为了方便与puppet结合,所以最好把源码打包成软件包
spec文件内容如下:nrpe.spec:%definenamenrpe%defineversion2.13%definerelease10%definensusrnagios%definensgrpnagios%definensport5666#Reserveoptiontooverrideportsettingwith:#rpm-ba|--rebuild--define'nsport5666'%{?port:%definensport%{port}}#Macrothatprintmesagestosyslogatpackage(un)installtime%definennmmsglogger-t%{name}/rpmSummary:Host/service/networkmonitoringagentforNagiosURL:http://www.nagios.orgName:%{name}Version:%{version}Release:%{release}License:GPLGroup:Application/SystemSource0:%{name}-%{version}.tar.gzBuildRoot:%{_tmppath}/%{name}-buildrootPrefix:%{_prefix}Prefix:/usr/local/nagiosRequires:bash,grep,nagios-plugins,xinetdPreReq:/usr/bin/logger,chkconfig,sh-utils,shadow-utils,sed,initscripts,fileutils,mktemp%descriptionNrpeisasystemdaemonthatwillexecutevariousNagiospluginslocallyonbehalfofaremote(monitoring)hostthatusesthecheck_nrpeplugin.Variouspluginsthatcanbeexecutedbythedaemonareavailableat:%prep%setup-q%preif[$?-eq2];then/usr/sbin/groupadd%{nsgrp}||%nnmmsgUnexpectederroraddinggroup"%{nyysgrp}".Abortinginstallprocess.fi#Create`nagios'useronthesystemifnecessaryif[$?-eq2];then/usr/sbin/useradd-d%{nsgrp}-s/bin/nologin-c"%{nsusr}"-g%{nsgrp}%{nsusr}||\%nnmmsgUnexpectederroraddinguser"%{nsusr}".Abortinginstallprocess.fi%postif["$1"=1];thenchown-R"%{nsusr}":"%{nsgrp}"%{_prefix}chkconfig--addxinetdchkconfigxinetdonecho"nrpe5666/tcp#nrpe">>/etc/services/sbin/servicexinetdrestart>/dev/null2>&1fi%preunif["$1"=0];then/bin/rm/etc/xinetd.d/nrpe-fsed-i'/^nrpe.*/d'/etc/servicesfi%postunif["$1"=0];then/sbin/servicexinetdrestart>/dev/null2>&1||:fi%buildexportPATH=$PATH:/usr/sbinCFLAGS="$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-argsmakeall%install["$RPM_BUILD_ROOT"!="/"]&&rm-rf$RPM_BUILD_ROOTinstall-d-m0755${RPM_BUILD_ROOT}/etc/xinetd.dinstall-c-m0755-d${RPM_BUILD_ROOT}/usr/local/nagios/libexecinstall-c-m0755src/check_nrpe${RPM_BUILD_ROOT}/usr/local/nagios/libexecinstall-c-m0755-d${RPM_BUILD_ROOT}/usr/local/nagios/bininstall-c-m0755src/nrpe${RPM_BUILD_ROOT}/usr/local/nagios/bininstall-c-m0755-d${RPM_BUILD_ROOT}/usr/local/nagios/etcinstall-c-m0755sample-config/nrpe.cfg${RPM_BUILD_ROOT}/usr/local/nagios/etc/nrpe.cfginstall-c-m0644sample-config/nrpe.xinetd${RPM_BUILD_ROOT}/etc/xinetd.d/nrpesed-i's#server_args.*#server_args=-c%{_prefix}/etc/nrpe.cfg--inetd#'${RPM_BUILD_ROOT}/etc/xinetd.d/nrpe%cleanrm-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})%docChangelogLEGALREADME%doc%{_prefix}/libexec%changelog*WedApr32013xxxbuild-2.13-10<xxx@xxx.com>-fixednrpe.cfgrelocationtosample-confignagios-plugins.spec
#Macros%defineisaix%(test"`uname-s`"="AIX"&&echo"1"||echo"0")%defineislinux%(test"`uname-s`"="Linux"&&echo"1"||echo"0")%defineisredhatfamily%(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%definenpusrnagios%definenphome/home/nagios%definenpgrpnagiosName:nagios-pluginsVersion:1.4.16Release:10Summary:Host/service/networkmonitoringprogrampluginsforNagiosGroup:Applications/SystemLicense:GPLURL:http://nagiosplug.sourceforge.net/Source0:http://dl.sf.net/sourceforge/nagiosplug/%{name}-%{version}.tar.gzBuildRoot:%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u}-n)%definenpdir%{_builddir}/%{name}-%{version}%if%{isaix}Prefix:%{_prefix}%elsePrefix:%{_prefix}/lib/nagios/plugins%endifPackager:KarlDeBisschop<kdebisschop@users.sourceforge.net>Vendor:NagiosPluginDevelopmentGroupProvides:nagios-plugins%{!?custom:%globalcustom0}Obsoletes:nagios-plugins-customnagios-plugins-extras#Requires%if%{isaix}Requires:fpingRequires:gawkRequires:net-snmpRequires:net-snmp-perlRequires:net-snmp-utilsRequires:openldapRequires:opensslRequires:perlRequires:pythonRequires:opensslBuildRequires:fpingBuildRequires:gawkBuildRequires:net-snmpBuildRequires:net-snmp-perlBuildRequires:net-snmp-utilsBuildRequires:openldap-devel%endif%if%{isredhatfamily}Requires:bind-utilsRequires:coreutilsRequires:fpingRequires:gawkRequires:grepRequires:iputilsRequires:mysqlRequires:net-snmp-utilsRequires:ntpRequires:openldapRequires:opensslRequires:openssh-clientsRequires:perlRequires:postgresql-libsRequires:procpsRequires:pythonRequires:samba-clientRequires:shadow-utilsRequires:tracerouteRequires:/usr/bin/mailqBuildRequires:bind-utilsBuildRequires:coreutilsBuildRequires:iputilsBuildRequires:mysql-develBuildRequires:net-snmp-utilsBuildRequires:net-toolsBuildRequires:ntpBuildRequires:openldap-develBuildRequires:openssh-clientsBuildRequires:openssl-develBuildRequires:postgresql-develBuildRequires:procpsBuildRequires:samba-clientBuildRequires:/usr/bin/mailq%endif%descriptionNagiosisaprogramthatwillmonitorhostsandservicesonyournetwork,andtoemailorpageyouwhenaproblemarisesorisresolved.Nagiosrunsonaunixserverasabackgroundordaemonprocess,intermittentlyrunningchecksonvariousservicesthatyouspecify.Theactualservicechecksareperformedbyseparate"plugin"programswhichreturnthestatusofthecheckstoNagios.Thispackagecontainsthoseplugins.%prep%setup-q%build%{?isaix:MAKE=gmake}./configure\--prefix=%{_prefix}\--exec-prefix=%{_exec_prefix}\--libexecdir=%{_libexecdir}\--sysconfdir=%{_sysconfdir}\--datadir=%{_datadir}\#--with-cgiurl=/nagios/cgi-binls-1%{npdir}/plugins>%{npdir}/ls-plugins-beforels-1%{npdir}/plugins-root>%{npdir}/ls-plugins-root-beforels-1%{npdir}/plugins-scripts>%{npdir}/ls-plugins-scripts-beforemake%{?_smp_mflags}ls-1%{npdir}/plugins>%{npdir}/ls-plugins-afterls-1%{npdir}/plugins-root>%{npdir}/ls-plugins-root-afterls-1%{npdir}/plugins-scripts>%{npdir}/ls-plugins-scripts-after%pre#Create`nagios'grouponthesystemifnecessary%if%{isaix}lsgroup%{npgrp}>/dev/null2>/dev/nullif[$?-eq2];thenmkgroup%{npgrp}||%nnmmsgUnexpectederroraddinggroup"%{npgrp}".Abortinginstallprocess.fi%endif%if%{islinux}getentgroup%{npgrp}>/dev/null2>/dev/nullif[$?-ne0];thengroupadd%{npgrp}||%nnmmsgUnexpectederroraddinggroup"%{npgrp}".Abortinginstallprocess.fi%endif#Create`nagios'useronthesystemifnecessary%if%{isaix}lsuser%{npusr}>/dev/null2>/dev/nullif[$?-eq2];thenuseradd-d%{nphome}-s/bin/nologin-c"%{npusr}"-g%{npgrp}%{npusr}||\%nnmmsgUnexpectederroraddinguser"%{npusr}".Abortinginstallprocess.fi%endif%if%{islinux}getentpasswd%{npusr}>/dev/null2>/dev/nullif[$?-ne0];thenuseradd-r-d%{nphome}-s/bin/nologin-c"%{npusr}"-g%{npgrp}%{npusr}||\%nnmmsgUnexpectederroraddinguser"%{npusr}".Abortinginstallprocess.fi%endif%postchown-R"%{npusr}":"%{npgrp}"%{_prefix}%installrm-rf$RPM_BUILD_ROOTmakeAM_INSTALL_PROGRAM_FLAGS=""DESTDIR=${RPM_BUILD_ROOT}installbuild-aux/install-sh-c-d${RPM_BUILD_ROOT}%{_sysconfdir}build-aux/install-sh-c-m664command.cfg${RPM_BUILD_ROOT}%{_sysconfdir}%find_lang%{name}echo"%defattr(755,%{npusr},%{npgrp})">>%{name}.langcomm-13%{npdir}/ls-plugins-before%{npdir}/ls-plugins-after|egrep-v"\.o$|^\."|gawk-vlibexecdir=%{_libexecdir}'{printf("%s/%s\n",libexecdir,$0);}'>>%{name}.langecho"%defattr(755,root,root)">>%{name}.langcomm-13%{npdir}/ls-plugins-root-before%{npdir}/ls-plugins-root-after|egrep-v"\.o$|^\."|gawk-vlibexecdir=%{_libexecdir}'{printf("%s/%s\n",libexecdir,$0);}'>>%{name}.langecho"%defattr(755,%{npusr},%{npgrp})">>%{name}.langcomm-13%{npdir}/ls-plugins-scripts-before%{npdir}/ls-plugins-scripts-after|egrep-v"\.o$|^\."|gawk-vlibexecdir=%{_libexecdir}'{printf("%s/%s\n",libexecdir,$0);}'>>%{name}.langecho"%{_libexecdir}/utils.pm">>%{name}.langecho"%{_libexecdir}/utils.sh">>%{name}.lang%cleanrm-rf$RPM_BUILD_ROOT%files-f%{name}.lang%docCODINGCOPYINGFAQINSTALLLEGALREADMEREQUIREMENTSSUPPORTTHANKS%docChangeLog%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*WedApr32013xxxbuild-1.4.16-10<xxx@xxx.com>-InitialPackage
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。