How to build RPM out of Nagios Check files

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
linuxfreaker
Posts: 1
Joined: Fri Sep 07, 2012 12:54 pm

How to build RPM out of Nagios Check files

Post by linuxfreaker »

I have 3 nagios check files namely - check_idms.py, check_tomcat and check_soap.
I built cdnagioscheck-1.0.tar.gz.I copied that tar file udnder /home/rpmbuild/rpm/SOURCES.I took an old SPEC file format from /home/rpmbuild/rpm/SPECS.Now I need to create SPEC file out of those 3 spec file so that it can be integrated/installed during nagios server setup.

Here is the SPEC file I tried to create:

Code: Select all

Summary: cdnagios check
Name: cdnagios
Version: 1.0
Release: 0
License: BSD
Group: Applications/Internet
Source: cdnagioscheck-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
Requires: nagios
# The above perl libraries are for postgresql monitoring.

%description
Provides aclient specific checks for the mdnagios - check_tomcat, _check_idms,check_soap.

%prep
%setup -q

%install
mkdir -p $RPM_BUILD_ROOT/usr/lib64/nagios/plugins/


%clean
rm -rf $RPM_BUILD_ROOT

%post

/etc/init.d/postgresql reload
/etc/init.d/tomcat6 restart

%postun
/etc/init.d/tomcat6 stop
echo "Removing deployed cNIS files from Tomcat."
rm -Rf /var/lib/tomcat6/webapps/cma/
rm -Rf /var/lib/tomcat6/webapps/abs/
/etc/init.d/tomcat6 start
echo "Removing PostgreSQL user and database."
if ! ps ax | grep -v grep | grep postgres > /dev/null
then
    /sbin/service postgresql start
fi
su - postgres -c "psql -c \"drop database if exists cnis;\"" > /dev/null 2>&1
su - postgres -c "psql -c \"drop user cnis;\"" > /dev/null 2>&1
sed -i '/.*cnis.*/d' /var/lib/pgsql/data/pg_hba.conf

%files
%defattr(-,mdnagios,-)
/usr/lib64/nagios/plugins/check_tomcat
/usr/lib64/nagios/plugins/check_idms
/usr/lib64/nagios/plugins/check_soap


%changelog


I am not sure if that is the correct format (esp. install and files section).
But when I am trying to build RPM through the following command:

Code: Select all

[rpmbuild@gnmonitoring SPECS]$ rpmbuild -bb mdnagioscheck.spec
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.ADxnow
+ umask 022
+ cd /home/rpmbuild/rpm/BUILD
+ '[' /home/rpmbuild/rpm/BUILDROOT/mdnagioscheck-1.0-0.x86_64 '!=' / ']'
+ rm -rf /home/rpmbuild/rpm/BUILDROOT/mdnagioscheck-1.0-0.x86_64
++ dirname /home/rpmbuild/rpm/BUILDROOT/mdnagioscheck-1.0-0.x86_64
+ mkdir -p /home/rpmbuild/rpm/BUILDROOT
+ mkdir /home/rpmbuild/rpm/BUILDROOT/mdnagioscheck-1.0-0.x86_64
+ LANG=C
+ export LANG
+ unset DISPLAY
+ mkdir temp
mkdir: cannot create directory `temp': File exists
error: Bad exit status from /var/tmp/rpm-tmp.ADxnow (%install)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.ADxnow (%install)
[rpmbuild@gnmonitoring SPECS]$

Any idea how shall I fix this issue?
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: How to build RPM out of Nagios Check files

Post by agriffin »

This question should probably be asked in a more relevant place. Knowledge about Nagios doesn't really enable anyone to answer it.
Locked