Re: Plugins and command clarification on 3.2.1 [Solved]

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
bsfez
Posts: 23
Joined: Tue May 08, 2012 8:41 am

Re: Plugins and command clarification on 3.2.1 [Solved]

Post by bsfez »

Hello,

I tried and followed to many tutorials and advices between Nagios 3.2.1 and Nagios 3.4.1 (not to add shiken :)
I want to stick with Nagios 3.2.1 for the moment but i'm totally confused on how plugins and command work now. :?


Nagios 3.2.1 LOCALHOST

1/ Plugins should be installed on my nagios monitoring server in /usr/lib/nagios/plugins

2/ Commands should be set somewhere... but where ?
My /etc/nagios3/commands.cfg is quite empty.

On the other hand if i look at my Nagios frontend i have several commands working fine (Current Load, Current Users, Disk Space, HTTP, SSH, Total Processes) and -> configuration -> commands show plenty of commands. They work for localhost and remote host. (? remote host need them here ?)

Now let's check it out.
I can see a "check_swap" plugins in "/usr/lib/nagios/plugins/check_swap"
But in my "configuration -> commands" i don't see it and setting it gives an error on "service nagios3 reload".

However i don't have a "/usr/lib/nagios/plugins/check_swap_statd_level" but i have it in "configuration -> commands" and it work just fine if i set it (see below).


3/ Define the service in /etc/nagios3/conf.d/localhost.cfg

Code: Select all

define service{
        use                             generic-service
        host_name                  localhost
        service_description     Current Swap
        check_command         check_swap_statd_level!20!10 
}
?? What am i missing ?


Nagios 3.2.1 REMOTE SERVER

1/ Plugins should be installed on my nagios monitoring server in "/usr/lib/nagios/plugins"

2/ "/etc/nagios/nrpe.cfg" is the only file i have to edit on my remote server.
I have to set the "allowed_hosts".
And at the bottom of the files, the commands.

I have successfully set hardcoded commands (they were uncommented by default i use them naturally)

Code: Select all

command[check_swap]=/usr/lib/nagios/plugins/check_swap -w 20 -c 10
etc...

3/ Define the service back on my nagios monitoring server in /etc/nagios3/conf.d/remote_server.cfg

Code: Select all

define service{
        use                     generic-service
        host_name               remote_server
        service_description     Swap Memory
        check_command           check_nrpe_1arg!check_swap    
}
And it work.

How does it sound ?
Last edited by bsfez on Thu May 24, 2012 7:23 am, edited 1 time in total.
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Plugins and command clarification on 3.2.1

Post by agriffin »

After adding a plugin to your plugins directory, you need to define your commands in your config before you can use them. For example:

Code: Select all

define command{
    command_name        check_local_swap
    command_line        $USER1$/check_swap -w $ARG1$ -c $ARG2$
    }
Then in the service, you can use it like this:

Code: Select all

define service{
    use                 local-service
    host_name           localhost
    service_description Swap Usage
    check_command       check_local_swap!20!10
    }
bsfez
Posts: 23
Joined: Tue May 08, 2012 8:41 am

Re: Plugins and command clarification on 3.2.1

Post by bsfez »

agriffin wrote:After adding a plugin to your plugins directory, you need to define your commands in your config before you can use them.
Hi agriffin, tks to keep being around. :)

I just can't find in which file i neeed to define my commands before i can use it with nagios3.2.1
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Plugins and command clarification on 3.2.1

Post by agriffin »

Any of your Nagios config files should do. Nagios' configuration is only spread across different files to keep things more manageable and organized, but you can put anything in any of the files. That said, you probably have a file called commands.cfg, which is where I would put it.
bsfez
Posts: 23
Joined: Tue May 08, 2012 8:41 am

Re: Plugins and command clarification on 3.2.1

Post by bsfez »

Sure.

That's my problem.

/etc/nagios3/nagios.cfg show:

Code: Select all

# Commands definitions
cfg_file=/etc/nagios3/commands.cfg
and my /etc/nagios3/commands.cfg is quite empty
http://pastebin.com/MdCUbJ0f

I tried to open every .cfg file i found related to nagios... nothing more.

However http://hostname.com/cgi-bin/nagios3/con ... e=commands
Show me a bunch of usable commands:
Command Name Command Line
check-fast-alive /usr/lib/nagios/plugins/check_fping -H '$HOSTADDRESS$'
check-host-alive /usr/lib/nagios/plugins/check_ping -H '$HOSTADDRESS$' -w 5000,100% -c 5000,100% -p 1
check-host-alive_4 /usr/lib/nagios/plugins/check_ping -H '$HOSTADDRESS$' -w 5000,100% -c 5000,100% -p 1 -4
check-nfs /usr/lib/nagios/plugins/check_rpc -H '$HOSTADDRESS$' -C nfs -c2,3
check-printer-alive /usr/lib/nagios/plugins/check_ping -H '$HOSTADDRESS$' -w 5000,100% -c 5000,100% -p 1
If to add a new plugin i need to edit the commands list i should be able too... :)
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Plugins and command clarification on 3.2.1

Post by agriffin »

Well I'm not sure how your Nagios installation is currently set up, but if you just put the command definition in one of your config files it will work. I don't understand what the problem is here or why you're so reluctant to just add it.
bsfez
Posts: 23
Joined: Tue May 08, 2012 8:41 am

Re: Plugins and command clarification on 3.2.1 [Solved]

Post by bsfez »

agriffin wrote:Well I'm not sure how your Nagios installation is currently set up, but if you just put the command definition in one of your config files it will work. I don't understand what the problem is here or why you're so reluctant to just add it.
... Well ok, i added commands to my /etc/nagios3/commands.cfg
First command was fine i added another one and on reload i got an error about duplicate command.
Then i found out that that some commands are here too : /etc/nagios-plugins/config/

Anyway i can live with a double check each time i add a command

Again thanks for your time.

Summary to add a plugin for 3.2.1:

1/ Add the plugin to the plugin directory (default: /usr/lib/nagios/plugins)
2/ Define the commands in one of the cfg (default /etc/nagios3/commands.cfg but can be in other .cfg)
3/ Define the service for your host config file
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Plugins and command clarification on 3.2.1 [Solved]

Post by agriffin »

Glad to see you got everything working! Sorry if my last response was a bit abrasive.
Locked