LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-29-2010, 07:00 AM   #1
Xanios
Member
 
Registered: Jul 2010
Posts: 216

Rep: Reputation: 30
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
 
Old 07-29-2010, 08:47 AM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
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

Last edited by marozsas; 07-29-2010 at 08:51 AM.
 
Old 07-29-2010, 08:55 AM   #3
Xanios
Member
 
Registered: Jul 2010
Posts: 216

Original Poster
Rep: Reputation: 30
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
 
Old 07-29-2010, 09:29 AM   #4
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
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.
 
Old 07-29-2010, 09:35 AM   #5
Xanios
Member
 
Registered: Jul 2010
Posts: 216

Original Poster
Rep: Reputation: 30
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
        }
 
Old 07-29-2010, 09:39 AM   #6
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
Quote:
Originally Posted by Xanios View Post
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

Last edited by sem007; 07-29-2010 at 09:40 AM.
 
Old 07-29-2010, 09:45 AM   #7
Xanios
Member
 
Registered: Jul 2010
Posts: 216

Original Poster
Rep: Reputation: 30
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?
 
Old 07-29-2010, 10:03 AM   #8
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
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
 
Old 07-29-2010, 10:10 AM   #9
Xanios
Member
 
Registered: Jul 2010
Posts: 216

Original Poster
Rep: Reputation: 30
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]
        }
 
Old 07-29-2010, 10:14 AM   #10
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
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.
 
Old 07-29-2010, 10:24 AM   #11
babunix
Member
 
Registered: Jul 2010
Location: India
Distribution: RHEL, Ubuntu
Posts: 35

Rep: Reputation: Disabled
Quote:
Originally Posted by sem007 View Post
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.
 
Old 07-29-2010, 10:29 AM   #12
Xanios
Member
 
Registered: Jul 2010
Posts: 216

Original Poster
Rep: Reputation: 30
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.
 
Old 07-29-2010, 10:31 AM   #13
Xanios
Member
 
Registered: Jul 2010
Posts: 216

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by babunix View Post
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/
 
Old 07-29-2010, 10:54 AM   #14
babunix
Member
 
Registered: Jul 2010
Location: India
Distribution: RHEL, Ubuntu
Posts: 35

Rep: Reputation: Disabled
Hi Xanios,

Quote:
Originally Posted by Xanios View Post
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 ?
 
Old 07-29-2010, 10:58 AM   #15
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
Hi babunix,

Quote:
Originally Posted by babunix View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Nagios dependencies.cfg example file rutledgetome Linux - Software 2 03-17-2010 11:08 AM
[SOLVED] nagios.cfg errors. worm5252 Linux - Server 3 12-17-2009 08:39 PM
LXer: Using external commands in Nagios LXer Syndicated Linux News 0 11-21-2008 08:30 AM
nagios and contactgroups.cfg d2490n Linux - Software 3 03-20-2008 08:27 AM
LXer: Nagios 2.5 and Oreon 1.3 (Nagios web front end) installation with screenshots LXer Syndicated Linux News 0 08-11-2006 05:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration