LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   commands.cfg [nagios] (https://www.linuxquestions.org/questions/linux-newbie-8/commands-cfg-%5Bnagios%5D-822839/)

Xanios 07-29-2010 07:00 AM

commands.cfg [nagios]
 
hello.

you know in commands.cfg, we would have to add in the commands to monitor a service (eg. http, ssh etc) I wonder if all the commands for the different services are the same? As in they have the same way of writing the command, except changing the service name:

eg,

for smtp:
Code:

! # 'check_smtp' command definition
define command{
! command_name check_smtp
! command_line $USER1$/check_smtp -H $HOSTADDRESS$
! }

for telnet

Code:

! # 'check_telnet' command definition
define command{
! command_name check_telnet
! command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p 23
! }

So, lets say if i want to write a command to check for a service called 'mysql', i write:

Code:

! # 'check_mysql' command definition
define command{
! command_name check_mysql
! command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p 3306
! }

??
And in the service.cfg.. i just write check_ssh and SSH respectively?

Thanks

marozsas 07-29-2010 08:47 AM

Nagios comes with a set of pre-installed check commands. They are installed at /usr/libexec/nagios or /usr/local/nagios/libexec (anyway, the $USER1$ is expanded to the right place)

At that folder you can find several check_whatever commands, most of them are binary files, some are shell or perl scripts.
If there is not a suitable check program to a special service in your site you can write one and drop it at that folder. After that just add a definition to it, just like above.

And yes, nagios already comes with a check_ssh program:
Code:

[root@spy objects]# ../../libexec/check_ssh
check_ssh: Could not parse arguments
Usage:check_ssh [-46] [-t <timeout>] [-r <remote version>] [-p <port>] <host>
[root@spy objects]# ../../libexec/check_ssh  192.168.160.253
SSH OK - OpenSSH_4.3 (protocol 2.0)
[root@spy objects]#

So, the definition for this command is something like this:
Code:

# 'check_ssh' command definition
define command{
command_name check_ssh
command_line $USER1$/check_ssh $HOSTADDRESS$
}

and use it as:
Code:


define service{
        use                            your_basic_template_here
        host_name                      myhost,anotherhost,mainserver,auxserver
        service_description            SSH
        check_command                        check_ssh
        }

to check the availability of ssh on hosts myhost, anotherhost, mainserver and auxserver

Xanios 07-29-2010 08:55 AM

hello.

sorry, i made a typo for the last question, regarding check_ssh. i want to ask for check_sql for sql service instead of check_ssh.

thanks

sem007 07-29-2010 09:29 AM

Quote:

So, lets say if i want to write a command to check for a service called 'mysql', i write:
there is nagios plugin check_mysql to check mysql connection.

Xanios 07-29-2010 09:35 AM

So, in services.cfg i write this:

Code:

define service{
        use                            your_basic_template_here
        host_name                      myhost,anotherhost,mainserver,auxserver
        service_description            MYSQL
        check_command                        check_mysql
        }


sem007 07-29-2010 09:39 AM

Quote:

Originally Posted by Xanios (Post 4049141)
So, in services.cfg i write this:

Code:

define service{
        use                            your_basic_template_here
        host_name                      myhost,anotherhost,mainserver,auxserver
        service_description            MYSQL
        check_command                        check_mysql
        }


yes you are right.

for command option you can use --help option.

/usr/local/nagios/libexec/check_mysql --help

Xanios 07-29-2010 09:45 AM

Hmm okay.

I tried that command: "/usr/local/nagios/libexec/check_mysql --help"

but it gave me:

Code:

xanios@ubuntu:~$ /usr/local/nagios/libexec/check_mysql --help
bash: /usr/local/nagios/libexec/check_mysql: No such file or directory

is it because i didn't have mysql plugins installed?
i thought by default when i installed the plugins, it is already installed?

sem007 07-29-2010 10:03 AM

Code:

is it because i didn't have mysql plugins installed?
i thought by default when i installed the plugins, it is already installed?

yes when you compile nagios-plugin it will automatically install check_mysql but if you doesn't install mysql-client package before nagios-plugin it will not install.

HTH

Xanios 07-29-2010 10:10 AM

Oh okay :)

Hmm, one last question:
there are a lot of ports out there, so if i want to monitor other services besides the above mentioned my_sql, i just change the service description and check_command for services.cfg and command_name and command_line in commands.cfg?

something like:

Code:

define command{
command_name [check_another-service-name-here]
command_line $USER1$/[check_another-service-name-here] $HOSTADDRESS$
}

and

Code:

define service{
        use                            your_basic_template_here
        host_name                      myhost,anotherhost,mainserver,auxserver
        service_description            [service-name]
        check_command                        [check_another-service-name-here]
        }


marozsas 07-29-2010 10:14 AM

How do you had installed nagios plugins ? By compiling the source and installing it in /usr/local or by installed a deb package by apt-get ?

In the first case, search for check_mysql using "find /usr/local -iname "check_mysql".
In the last case, use "dpkg -S package_name"; in ubuntu Lucid, there are 4 packages with plugins, you have to test all you have installed: nagios-plugins, nagios-plugins-basic, nagios-plugins-standard and nagios-plugins-extra.

babunix 07-29-2010 10:24 AM

Quote:

Originally Posted by sem007 (Post 4049185)
Code:

is it because i didn't have mysql plugins installed?
i thought by default when i installed the plugins, it is already installed?

yes when you compile nagios-plugin it will automatically install check_mysql but if you doesn't install mysql-client package before nagios-plugin it will not install.

HTH

thanks sem007,
I am also looking same kind of solution.
I have one question. if check_mysql doesn't exists and i want to install it. how can i do this? want i compile nagios-plugin again and install it? i just want one plugin.

Thanks in advance.

Xanios 07-29-2010 10:29 AM

I used apt-get.

for "find /usr/local -iname "check_mysql", there is no output after i typed the command. what does it mean?

for "dpkg -S package_name", you asked me to check for the 4 packages, is it like this: dpkg -S nagios-plugins and so on.

Xanios 07-29-2010 10:31 AM

Quote:

Originally Posted by babunix (Post 4049206)
thanks sem007,
I am also looking same kind of solution.
I have one question. if check_mysql doesn't exists and i want to install it. how can i do this? want i compile nagios-plugin again and install it? i just want one plugin.

Thanks in advance.

to install mysql:

sudo apt-get install mysql-server mysql-client

i think you can refer to this : http://ariejan.net/2007/12/12/how-to...-ubuntudebian/

babunix 07-29-2010 10:54 AM

Hi Xanios,

Quote:

Originally Posted by Xanios (Post 4049210)
to install mysql:

sudo apt-get install mysql-server mysql-client

i think you can refer to this : http://ariejan.net/2007/12/12/how-to...-ubuntudebian/

I know how to install package. My question is if i haven't check_mysql and i want that for that.So i want to compile nagios-plugin again ?

sem007 07-29-2010 10:58 AM

Hi babunix,

Quote:

Originally Posted by babunix (Post 4049206)
thanks sem007,
I am also looking same kind of solution.
I have one question. if check_mysql doesn't exists and i want to install it. how can i do this? want i compile nagios-plugin again and install it? i just want one plugin.

Thanks in advance.

yes you want to compile nagios-plugin.
Install mysql-client and musql devel package
compile nagios plugin (run ./configure with option, run make, make install doesn't require)

copy check_mysql from <nagios-plugin-source>/plugins directory to your libexec dir.

HTH


All times are GMT -5. The time now is 06:35 AM.