LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 04-20-2009, 08:19 PM   #1
deibertine
Member
 
Registered: Mar 2009
Posts: 222

Rep: Reputation: 30
Unhappy Assistance on Setup HostGroups in Nagios 2.x


Hi all,
I am new to setting up Nagios and finally had all my hosts setup and communicating to the monitoring server. Now I wanted to move all of them by category (windows servers, linux servers etc...). I came to see setting up host groups and followed the basic details here: http://nagios.sourceforge.net/docs/2...atetricks.html
However, not getting the hostgroups to display in the admin page.
I was wondering if there's a guide out there to properly setup a hostgroups in Nagios?
Looking at the admin page, there's one setup called "test servers" which has all of my servers - perhaps I can just rename this and be done with it - however still need to setup a new one for the linux boxes and moving them to their appropriate hostgroup categories.

Any help is appreciated!

Regards,
Dei B.

Last edited by deibertine; 04-20-2009 at 08:20 PM. Reason: added words
 
Old 04-20-2009, 10:16 PM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,393
Blog Entries: 1

Rep: Reputation: 64
The link you point has all information you need to setup a hostgroup. What is the problem exactly ?
Code:
define hostgroup{
		hostgroup_name		Windows
		members			machine1,machine2,machine3
		}
Of course this directive must be in the main nagios.cfg file or it is included from some other file (hostgroups.cfg); and, of course, you need to restart nagios after any changes in any configuration file
 
Old 04-21-2009, 03:41 PM   #3
deibertine
Member
 
Registered: Mar 2009
Posts: 222

Original Poster
Rep: Reputation: 30
Thanks for the reply Marozsas!
I guess the main question is where in nagios.cfg do I place this code into to?
Right now my directives are inputted within the "templates" file.
Can I place the code above to templates?
Otherwise if you were going to start this over on your own, what's the easy way and how would you do this?

Last edited by deibertine; 04-21-2009 at 03:43 PM. Reason: added sentence
 
Old 04-21-2009, 04:47 PM   #4
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,393
Blog Entries: 1

Rep: Reputation: 64
Yes, you can, but it is better to do this in a more organized way.

There are several setups for nagios depending of the version and the distro.
As general thumb of role, in nagios.cfg you have includes directives where you specify files which has host directives, services directives, commands, etc. You can have a single file for all linux servers and other for windows machines, and other for printers.
You can have also a directory where nagios will look for any cfg file to read at start up.

I like to have a single file to declare all hostgroups and servicegroups I want to use.
In nagios.cfg file use a include directive to, uhh, include this file:
Code:
cfg_file=/usr/local/nagios/etc/objects/groups.cfg
In this file declare the hostgroups and servicegroups. It looks like:
Code:
define hostgroup{
        hostgroup_name  linux-server ; The name of the hostgroup
        alias           Linux Server ; Long name of the group
        }
define hostgroup{
        hostgroup_name  core-server  ; The name of the hostgroup
        alias           Core Server  ; Long name of the group
        }
define hostgroup{
        hostgroup_name  name-server ; The name of the hostgroup
        alias           Domain Name Server ; Long name of the group
        }

... cut ....

define servicegroup {
	servicegroup_name	dns
	alias			Domain name service
}

define servicegroup {
	servicegroup_name	mail
	alias			E-Mail related services
}

define servicegroup {
	servicegroup_name	http
	alias			Web related services
}
I like to declare who is in which group not here in this file (you can if you want. Just add inside each definition a statement like "members hostname1,hostname2" or "members service1,service2").

In my setup, the servers definitions are in a folder. In this folder I have a file.cfg for each server I want to monitor in nagios.
For this setup I use in nagios.cfg:
Code:
cfg_dir=/usr/local/nagios/etc/objects/servers
In each file.cfg in "servers" dir above, I put both the host definition, and the services definitions for that host.

In this file I use the "hostgroup" statement to add the host to one or more hostgroups and in the service definition I use the statement "servicegroups" to add the service to one or more servicegroups.

I have a file named webmail.cfg with definitions to monitoring my webmail server. It is in the hostgroup "linux-server" and in the hostgroup "core-server". It has one service; the webmail. It is in the servicegroup "mail" and in the servicegroup "http", as it is a webmail, of course.


Code:
define host{
        use                     linux-server,host-pnp        
        host_name               webmail
        alias                   Webmail, virtual host
        address                 webmail
        hostgroup               linux-server, core-server
        }

define service{
        use                             local-service,srv-pnp    
        host_name                       webmail
        service_description             Apice internal webmail 
	servicegroups			mail,http
	check_command			check_http!-u /src/login.php
        }

Configuring nagios is a matter of deal with several configuration files, but the primary file is nagios.cfg. You really need to take a close look to it to understand which are the other files and what are its function.
There are no syntactic rule to warn you if you put a service definition in a host.cfg file or even in a template file, as you mentioned.
 
Old 04-21-2009, 05:08 PM   #5
deibertine
Member
 
Registered: Mar 2009
Posts: 222

Original Poster
Rep: Reputation: 30
Ok I did this:
I enabled hostgroups.cfg in nagios.cfg
I created the file hostgroups.cfg
In each hosts, I added the line: "hostgroup_name win-server"
I ran verify and came up with this error:
Reading configuration data...

Error: Invalid hostgroup object directive '*'.
Error: Could not add object property in file '/usr/local/nagios/etc/hostgroups.cfg' on line 2.

***> One or more problems was encountered while processing the config files...

Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.

Anything else I am missing?
 
Old 04-23-2009, 04:59 PM   #6
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,393
Blog Entries: 1

Rep: Reputation: 64
Sorry, I was out of the town.
Looks like there is a "*" somewhere in /usr/local/nagios/etc/hostgroups.cfg.

The '*' means all hosts. Are you sure is this what you want ?

Last edited by marozsas; 04-24-2009 at 01:23 PM.
 
  


Reply

Tags
nagios


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
Nagios Email Notification Assistance deibertine Linux - Newbie 7 10-05-2012 01:19 PM
Nagios setup investmentbnker75 Linux - General 1 08-10-2008 05:22 AM
Need sendmail setup assistance for wordpress philwynk Linux - Software 7 01-22-2008 02:07 PM
Need assistance with wireless network setup... thekid Linux - Wireless Networking 2 12-10-2007 05:22 PM
Nagios v.2.9 - hosts/hostgroups not recognized??? arktik Linux - Networking 2 05-25-2007 08:45 PM


All times are GMT -5. The time now is 10:19 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration