Having to install any software and then configuring it so that it fits into your environment can be a pain in the butt. Especially if you have to roll it out to hundreds of servers. One such software is nagios’ nrpe client. After every install, I had to modify the nrpe.conf file to allow access from my master server along with a few nrpe checks on the client side (i.e. disk space utilization and cpu usage threshold). I could’ve used puppet to modify the file but hey let’s play with SPEC files and rpmbuild.
The example below rebuilds nrpe, substitute the filename with the package you want to work with. Note, if you’re rebuilding a 64 bit package, you need a 64bit machine (with 64bit OS obviously).
1 – Download the RPM source file
Usually in the following format “nrpe-2.12-14.el5.src.rpm” (notice the “src” within the file name).
2 – Install the source file
[php]rpm -ivh nrpe-2.12-14.el5.src.rpm[/php]
You’ll see a bunch of files scattered within /usr/src/redhat. Depending on what you’re looking to modify, you’ll have to dig through the folders (mainly SOURCES). There should be a tar.gz file under /usr/src/redhat/SOURCES. I’m interested in modifying a couple of lines within nrpe.conf (the main conf file used by nrpe). I uncompressed the tar.gz file, then proceeded to modify nrpe.conf and re-tar it back up (overwrite original file). Make sure you delete the uncompress folder prior to rebuilding. Once that’s done, I rebuild and create a “new” rpm file with the modified nrpe.conf.
3 – Rebuild RPM package
rpmbuild -ba nrpe.spec
This should create an RPM file under /usr/src/redhat/RPMS