Creating Nrpe,nagios-plugins Packages using Rpmbuild

Source: Internet
Author: User
Tags config rpmbuild

Nagios clients generally need to Nagios-plugins,nrpe, in order to facilitate and puppet combination, so it is best to package the source code as a package

The spec file reads as follows:

Nrpe.spec:

%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 would execute various Nagios plugins
Locally on behalf to a remote (monitoring) host that uses the
Check_nrpe plugin. Various plugins that can is 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]; 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 ["$" = 0]; Then
/bin/rm/etc/xinetd.d/nrpe-f
Sed-i '/^nrpe.*/d '/etc/services
Fi
%postun
If ["$" = 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.