Has anyone ever made an RPM for their custom plugin?

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
pamplifier
Posts: 21
Joined: Wed May 13, 2015 7:31 am

Has anyone ever made an RPM for their custom plugin?

Post by pamplifier »

I'm building an RPM to install my plugin into the Nagios plugin directory (i.e. /libexec) and also append the appropriate lines into commands.cfg and localhost.cfg to 'activate' it. So far, it works great for the former, but not the latter.

What I have so far is a script in %post that essentially does this:

Code: Select all

%post
if [ $1 -eq 1];
then
    if [ -w /path/to/commands.cfg];
    then
        echo "define command {
        #<etc etc, insert command definition stuff here>
        }" >> commands.cfg
    else
        echo "failure to add command defintion"
    fi
fi
And it's similar to that for the appropriate lines for localhost.cfg as well. However, when I install the rpm, the plugin is there in /libexec, but nothing happens with regards to the .cfg files.

Has anyone tried something like this before?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Has anyone ever made an RPM for their custom plugin?

Post by tmcdonald »

I can ask the devs for their input, but this sounds like it might be better asked on a development forum. We need to keep questions here related to Nagios, and this issue could be raised for just about any script/program out there.
Former Nagios employee
pamplifier
Posts: 21
Joined: Wed May 13, 2015 7:31 am

Re: Has anyone ever made an RPM for their custom plugin?

Post by pamplifier »

Ah, I figured this fell in with Plugin Development, since it's an RPM for a custom plugin. The base question was basically if anyone here had ever made an RPM for their own custom plugin before. According to my search results, people mostly package their custom plugins in a tarball with a README detailing what to add to the config files when they distribute. I was hoping to automate the process.

But if you think it'd be better posed elsewhere, I guess this can get deleted?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Has anyone ever made an RPM for their custom plugin?

Post by jdalrymple »

RPM - RedHat Package Manager - is mostly intended for packaging, not configuration (devops). It's a tool in the devops toolbox but never was it intended to be a configuration manager. I would recommend using RPM to do your plugin deployment but all the configuration stuff would be better suited for something like Chef or Puppet.

With those thoughts out of the way we'll leave the thread open for awhile, everyone is allowed their differing opinions and I'd be eager to here what others have to say on the topic.
doke
Posts: 2
Joined: Tue Dec 29, 2015 4:58 pm

Re: Has anyone ever made an RPM for their custom plugin?

Post by doke »

I've only done it for remote, client installations, using nrpe. So it only had to append lines to the nrpe.cfg. Even then, I found it tedious to debug the post script. So I moved it out to a script that gets installed, and can be run on it's own. Your code looks ok, but I would suggest making it grep to see if the block you're adding already exists.

Code: Select all

%post
/usr/local/nagios/bin/setup_nagios
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Has anyone ever made an RPM for their custom plugin?

Post by rkennedy »

Thanks for the addition to this @doke!

@pamplifier do you have any more questions about this?
Former Nagios Employee
pamplifier
Posts: 21
Joined: Wed May 13, 2015 7:31 am

Re: Has anyone ever made an RPM for their custom plugin?

Post by pamplifier »

Thanks for the help. I've put the project on the back-burner for now, ended up just detailing the lines to add in a README. I will try @doke's suggestion of installing a separate script to add the lines later :D
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Has anyone ever made an RPM for their custom plugin?

Post by hsmith »

Let us know if there's anything we can possibly help with later on.
Former Nagios Employee.
me.
Locked