NagiosPlugins
HOWTO pack the nagios plugins into an RPM
Building the RPM
- The plugins are gathered in an RPM for easy distribution over all nagios monitored hosts.
- The RPM is build on egon.
- A script can create the rpm
- Execute as follows
cd /root/nagiosPlugins/ version=1.10 ./makeRPM.sh $version
- It will make $version rpm of the directory nagios-plugins-dedicated
- therefore, all the executables you need to distribute, also need to be place into /root/nagiosPlugins/nagios-plugins-dedicated
- all will be distributed to /usr/lib64/nagios/plugins/
- Copy the file to ccq3, via ccq:
scp /root/rpmbuild/RPMS/noarch/nagios-plugins-dedicated-$version-1.noarch.rpm ccq:/root/Joris
- Here are the commands to be executed to make the rpm w/o the script
- First a tar ball is made containing all the scripts
cd /root/nagiosPlugins tar -cjf nagios-plugins-dedicated-A.B.tar.gz nagios-plugins-dedicated-A.B/
- The building of the RPM happens as follows
cd /root/rpmbuild cp ../nagiosPlugins/nagios-plugins-dedicated-A.B.tar.gz SOURCES/ rpmbuild -ba SPECS/nagios-plugins-dedicated.spec
- IMPORTANT: don't forget to adapt the spec file to rpm-ize the correct version A.B
Uploading the RPM to the BEgrid repo
- As a final step you have to upload the rpm to the begrid repo like this
- the directory for uploading on ccq3:
/opt/CB5/tmp/src/begrid/cb-client/cb-client-swrep/rpm-nagios scp ccq:/root/Joris/nagios-plugins-dedicated-A.B-1.noarch.rpm .
- The command executed to upload to the repo:
./swrep.py --debug --mode=up --plat x86_64_sl5_5X,/sl5/sl54/updates --dir=/opt/CB5/tmp/src/begrid/cb-client/cb-client-swrep/rpm-nagios/
- Don't forget to add the correct line to the repo template file and include somewhere this rpm so that it gets installed on the machine
Links to info and tutorials
- Following links contain some information on how to build your own RPM files:
- http://fedoraproject.org/wiki/How_to_create_an_RPM_package
- http://tldp.org/HOWTO/RPM-HOWTO/build.html
- http://www.rpm.org/max-rpm/s1-rpm-build-creating-spec-file.html
- http://narrabilis.com/mybook/appendices/packages
- http://stackoverflow.com/questions/1879734/rpm-build-error or http://spot.fedorapeople.org/Summit2008/2008-RPM-Spec-examples.pdf
Tutorial to build an rpm
- The aim of this section is to provide a minimal working example to build your own RPM
- It is a mixture of the tutorials listed in the links section. Please have a closer look there on the meaning of the section (with a %) in the file as well on the directory structure of the rpm package.
- For this example I have put the directory tree in a specific directory and added a line in .rpmmacros to point to it.
/root/rpmbuild/ cat ~/.rpmmacros %_topdir /root/rpmbuild/
- It should be noted that RPMs should not be built with root privileges.
- Example spec file located in the SPEC directory:
Summary: a test for helloworld
Name: testhello
License: GPL
Version: 1.1
Source: test.tar.gz
Release: 1
Group: Applications
#BuildRoot: /tmp/rpm-buildroot-%{name}-%{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildArch: noarch"
%description
This is a description for the testhello
%prep
echo "1." $PWD
ls -l
%setup
echo "2." $PWD
ls -l
%build
echo "3." $PWD
ls -l
gcc -o test test.c
echo "rm -rf %{buildroot}"
rm -rf %{buildroot}
echo "mkdir -p %{buildroot}%{_bindir}"
mkdir -p %{buildroot}%{_bindir}
echo "cp test.c %{buildroot}%{_bindir}/test.c"
cp test.c %{buildroot}%{_bindir}/test.c
%clean
rm -rf %{buildroot}
##or alternatively
##make test
#echo "%{buildroot}"
#ls -l /var/tmp
#ls -l %{buildroot}
#echo %{_bindir}
%files
%defattr(-,root,root,-)
%{_bindir}/test.c
%changelog
*Thu Apr 7 2011 Joris Maes <jmmaes@cern.ch> 1.1-1
- initial package for testing
- Be careful to create a tar ball with a top directory. I.e. the test.c is put in a directory called testhello-1.1 which then tarred
tar cvf test.tar.gz testhello-1.1/
- To finally build the rpm execute the following line:
rpmbuild -ba testhello.spec