make RPM packages from source

My boss give me a project with nagios and ActiveMQ and MySQL, the nagios should monitoring the message queue in ActiveMQ and for MysQL i should know the replication delay.
Okay then the adventure is begin.
After searching in google, i found very interesting plugins at, the issue is those packages are build in source not in RPM packet. hmm then i should build it into a RPM.
the solution is rebuild the source into a rpm.
let's start.

I try this with Fedora 13 and Centos 5.5

1. download and install.
note : you should use ordinary user account for build the package not using root.

you can use this package rpmdev-setup for auto configuration, so you no need to build the folder again
yum install rpmdev-setup

2. create folders for build the rpm package and create hidden files named rpmmacros at your home directory.
    in centos
mkdir -p ~/rpm/{SOURCES,BUILD,SPEC,SRPMS,RPMS,tmp}
touch ~/.rpmmacros
%packager check_logfiles
%_topdir /home/fazries/rpm           
%_tmppath /home/fazries/rpm/tmp

    if you using Fedora you don't need to create those directory, its automatic create when you install the  depedency packet.

   in fedora the directory structure will become like this:


3. for example i will rebuild the check_mysql_health (need to be complie) and check_jmx (binary already) plugins

download the source.

cd ~/rpm/SOURCES/
wget -c
4. next create a spec file, inside this file is a configuration for making a RPM packet.

cd ~/rpm/SPEC/touch check_mysql_health.spec
     copy and paste this config into check_mysql_health.spec:

Summary: Mysql check plugin for nagios
Name: check_mysql_health
Version: 2.1.5
Release: 1%{?dist}
License: GPL 
Group: Applications/System
Packager: Dag Wieers 
Vendor: Dag Apt Repository,
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

check_logfiles is a plugin for Nagios which searches for patterns in mysql It is capable of scanning multiple    logfiles and their rotated ancestors in a single run.


%setup -n %{name}-%{version}


%configure  --libexecdir=%_libdir/nagios/plugins

%{__rm} -rf %{buildroot}
%{__make} install DESTDIR="%{buildroot}"

%{__rm} -rf %{buildroot}

%defattr(-, root, root, 0755)

* Thu Sep 16 2010 Christoph Maser - 3.4.2-1 - 9115/yury- Update to version 3.4.2.
* Thu Jan 10 2008 Christoph Maser - Initial package.

5. build the packet
rpmbuild -ba check_mysql_health.spec
6. the your rpm packet will create an stored at ~/rpm/RPMS/check_mysql_health-2.1.5-1.x86_64.rpm

and for the check_jmx you can download it at:
put it into SOURCES folder
install the unzip , cause the source is compressed by zip

# yum install unzip

repeat,start from step 4. and create the .spec file for check_jmx

touch check_jmx.spec

copy and paste this config:
Name: check_jmx
License:APL 2.0

jmx plugins for nagios

rm -rf %{buildroot}
rm -rf $RPM_BUILD_ROOT/*

cd %{_sourcedir}unzip -e

cd %{_sourcedir}
cd jmxquery/nagios/plugin
mkdir -p $RPM_BUILD_ROOT/usr/lib64/nagios/plugin
scp * $RPM_BUILD_ROOT/usr/lib64/nagios/plugins


* Tue Jan 15 2011 Vash27- recreated
* Tue Jan 10 2011 Vash27- Created initial spec file for check_jmx

great tutorial,you can download it at:

next i will explain how to use those plugins with nagios


  1. Thanks for the pointers. I'm building the check_jmx package and it looks fine. A couple of comments though:
    - The license in your SPEC file says GPL, though the JMX query library (from ) is licensed as APL 2.0.
    - Do you know how I can get in touch with the owner of the check_jmx II package in Nagios Exchange, because it seems that it distributes modified sources of the JMX query source code (from the project listed above) without referencing the original project.

    Thanks in advance.

  2. Hai Guss77, thank for your visit,
    - yes your correct, after i check the license is APL 2.0 for jmxquery. i will fix that.
    - i'm sory i don't know, i got the package directly from


Post a Comment

Popular posts from this blog

authentication failure using SSH pam_unix(sshd:auth): authentication failure;

Howto configure SPLUNK Universal Forwarder

openvpn howto make OCSP server using OpenSSL [Part2]