Page 1 of 1

Has anyone ever made an RPM for their custom plugin?

Posted: Tue Aug 25, 2015 1:48 pm
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?

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

Posted: Tue Aug 25, 2015 1:50 pm
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.

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

Posted: Tue Aug 25, 2015 1:59 pm
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?

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

Posted: Tue Aug 25, 2015 2:06 pm
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.

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

Posted: Sun Jan 03, 2016 4:20 pm
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

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

Posted: Mon Jan 04, 2016 10:23 am
by rkennedy
Thanks for the addition to this @doke!

@pamplifier do you have any more questions about this?

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

Posted: Thu Jan 07, 2016 2:32 pm
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

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

Posted: Thu Jan 07, 2016 2:38 pm
by hsmith
Let us know if there's anything we can possibly help with later on.