Community ideas

by Andreas Ericsson Email

Once again, I'm awestruck with the power of the thinktank of the world. Last weekend (3-4 Oct) I was at Opensource Days in Copenhagen, Denmark. I was giving a presentation about Nagios (which was quite well received), and included a brief demonstration of some of the addons we've done and ship with our products.

As I was demoing the network map thingie we have and excusing myself for the pretty poor maps we're using (due to copyright issues while shipping such maps with a commercially supported product), a member of the audience named Einar Petersen asked me why we just didn't pull stuff from the Open Streetmaps project. I was so amazed that there was a site like this that I didn't know what to answer.

Once again, the community has outsmarted the corporation :)

Thoughts on external commands

by Andreas Ericsson Email

Yesterday I had the opportunity to take a look at how external commands are implemented, as I need some way to let merlin decide if commands submitted to the pipe should be applied to the Nagios daemon that receives it as well as the ones we're supposed to propagate it to.

First I started taking a look at how to undo the action of each of the external commands, but there are 100+ of the damn buggers so I quickly gave this up.

I noticed that I can pass "custom" external commands that get sent to neb-modules only that Nagios has no idea about, if I prepend an underscore to the command as written to the pipe. While this is all fine and well, I think I have a better idea.

Imagine the extcmd api working something like this instead:


    struct extcmd {
        int command_id;
        char *command_name;
        int command_args;
        int (*handler)(struct extcmd *, char **, int);
    };

    /* set an external command handler */
    int set_extcmd_handler(struct extcmd *cmd, int overwrite);

When a command is read, it gets looked up in a hash table, its arguments are parsed into an argument vector with at least "command_args" entries (giving the additional bonus that Nagios can now log a warning if the argument doesn't have at least the minimum number of arguments, which it couldn't do before) and the handler is run for that command. A handler could be defined like this:


    int extcmd_handler(struct extcmd *cmd, char **argv, int argc);

If that was the case, all I'd have to do in my NEB-modules would be to register a new handler for the commands I don't want Nagios to handle by itself and it would get called instead of the default handler. Nifty, eh? :)

<< 1 2 3