LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-23-2008, 08:39 AM   #1
andybrr
Member
 
Registered: Mar 2006
Posts: 54

Rep: Reputation: 15
Help with nagios configurations


Hello experts,

I installed nagios 3.0 on my centos 5.1 successfully. Now I am trying to configure nagios to monitor my linux server with basic configurations but no success. I want to monitor via ping only at the momment.

[root@fw-global etc]# pwd
/usr/local/nagios/etc
[root@fw-global etc]# ls
cgi.cfg htpasswd.users nagios.cfg objects resource.cfg
[root@fw-global etc]# cd objects/
[root@fw-global objects]# ls
commands.cfg contacts.cfg localhost.cfg localhost.cfg.backup printer.cfg switch.cfg templates.cfg timeperiods.cfg windows.cfg
[root@fw-global objects]#

I modified the localhost to make a test and it is :

[root@fw-global objects]# cat localhost.cfg
###############################################################################
# LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE
###############################################################################

###############################################################################
# HOST DEFINITION
###############################################################################
# Define a host for the local machine

define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name localhost
alias servidor
address 127.0.0.1
}

###############################################################################
# HOST GROUP DEFINITION
###############################################################################

define hostgroup{
hostgroup_name linux-servers ; The name of the hostgroup
alias Linux Servers ; Long name of the group
members localhost ; Comma separated list of hosts that belong to this group
}

###############################################################################
# SERVICE DEFINITIONS
###############################################################################

define service{
use local-service ; Name of service template to use
host_name localhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}

I want to monitor via ping exactly as localhost.cfg a linux server, windows server and cisco router. Their ip address: linux 192.168.1.1, windows 192.168.1.2 and cisco 192.168.1.3

If anyone could show me a link with tutorial, tip or how-to I apreciate.

Thanks,
 
Old 04-23-2008, 09:14 AM   #2
itsjustdave
LQ Newbie
 
Registered: Mar 2008
Posts: 11

Rep: Reputation: 0
I am also new working with Nagios but I may be able to help you.

If you want to monitor new hosts the best way would be first go into the nagios.cfg file and edit this line.


Code:
# You can also tell Nagios to process all config files (with a .cfg
# extension) in a particular directory by using the cfg_dir
# directive as shown below:

cfg_dir=/usr/local/nagios/etc/servers
#cfg_dir=/usr/local/nagios/etc/printers
#cfg_dir=/usr/local/nagios/etc/switches
#cfg_dir=/usr/local/nagios/etc/routers
This will tell nagios to look at the /usr/local/nagios/etc/servers directory for any files with .cfg.(create a file called servers if it not already there). Once you have that dir you can create either 1 file or multiple files for your servers/routers. If you only have 3 devices then one file should do.

Then you will need to define the 3 hosts and define the service that goes along with them and a hostgroup. Somthing like this would work.

Code:
define host{
        name                            network_device    ; The name of this host template
        use                             generic-host    ; This template inherits other values from the generic-host template
        check_period                    24x7            ; By default, Linux hosts are checked round the clock
        max_check_attempts              10              ; Check each Linux host 10 times (max)
        check_command                   check-host-alive ; Default command to check Linux hosts
        notification_period             24x7            ; aix admins hate to be woken up, so we only notify during the day
                                                        ; Note that the notification_period variable is being overridden from
                                                        ; the value that is inherited from the generic-host template!
        notification_interval           120             ; Resend notification every 2 hours
        notification_options            d,u,r           ; Only send notifications for specific host states
          contact_groups                  networkadmins          ; Notifications get sent to the admins by default
        register                        0               ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }
###############################################################################
# HOST DEFINITION
###############################################################################
define host{
        use             network_device
        host_name       windows
        alias           windows
        address         192.168.1.1
        }

define host{
        use                     network_device
        host_name               linux
        alias                   linux
        address                 192.168.1.2
        }

define host{
        use                     network_device
        host_name               cisco
        alias                   cisco
        address                 192.168.1.3
        }

###########################################################################
# Host Groups
###########################################################################

define hostgroup{
        hostgroup_name          MyDevices
        alias                   MyDevices
        members                 linux,windos,cisco
        }

###########################################################################
# Service
###########################################################################

define service{
        use                         local-service
        hostgroup_name              MyDevices
        service_description         PING
        contact_groups              networkadmins
        check_command               check_ping!500.0,20%!800.0,60%
        }
Save the config as anything.cfg and nagios will find it as long as it is the dir you defined in nagios.cfg. You can set up the configs however you want, this is just one way. Reload nagios and you should be good to go.

FYI: "use local-service" under the define service is a service template in templates.cfg. Hope this helps!
 
Old 04-23-2008, 10:42 AM   #3
andybrr
Member
 
Registered: Mar 2006
Posts: 54

Original Poster
Rep: Reputation: 15
Help with Nagios Configuration Basic

I did as you told me to but I run the command nagios -v nagios.cfg I get the error:

[root@fw-global bin]# ./nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios 3.0
Copyright (c) 1999-2008 Ethan Galstad (http://www.nagios.org)
Last Modified: 03-13-2008
License: GPL

Reading configuration data...

Warning: Duplicate definition found for host 'generic-host' (config file '/usr/local/nagios/etc/servers/templates.cfg', starting on line 52)
Error: Could not add object property in file '/usr/local/nagios/etc/servers/templates.cfg' on line 53.

***> 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.

[root@fw-global bin]#

Thanks,

Quote:
Originally Posted by itsjustdave View Post
I am also new working with Nagios but I may be able to help you.

If you want to monitor new hosts the best way would be first go into the nagios.cfg file and edit this line.


Code:
# You can also tell Nagios to process all config files (with a .cfg
# extension) in a particular directory by using the cfg_dir
# directive as shown below:

cfg_dir=/usr/local/nagios/etc/servers
#cfg_dir=/usr/local/nagios/etc/printers
#cfg_dir=/usr/local/nagios/etc/switches
#cfg_dir=/usr/local/nagios/etc/routers
This will tell nagios to look at the /usr/local/nagios/etc/servers directory for any files with .cfg.(create a file called servers if it not already there). Once you have that dir you can create either 1 file or multiple files for your servers/routers. If you only have 3 devices then one file should do.

Then you will need to define the 3 hosts and define the service that goes along with them and a hostgroup. Somthing like this would work.

Code:
define host{
        name                            network_device    ; The name of this host template
        use                             generic-host    ; This template inherits other values from the generic-host template
        check_period                    24x7            ; By default, Linux hosts are checked round the clock
        max_check_attempts              10              ; Check each Linux host 10 times (max)
        check_command                   check-host-alive ; Default command to check Linux hosts
        notification_period             24x7            ; aix admins hate to be woken up, so we only notify during the day
                                                        ; Note that the notification_period variable is being overridden from
                                                        ; the value that is inherited from the generic-host template!
        notification_interval           120             ; Resend notification every 2 hours
        notification_options            d,u,r           ; Only send notifications for specific host states
          contact_groups                  networkadmins          ; Notifications get sent to the admins by default
        register                        0               ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }
###############################################################################
# HOST DEFINITION
###############################################################################
define host{
        use             network_device
        host_name       windows
        alias           windows
        address         192.168.1.1
        }

define host{
        use                     network_device
        host_name               linux
        alias                   linux
        address                 192.168.1.2
        }

define host{
        use                     network_device
        host_name               cisco
        alias                   cisco
        address                 192.168.1.3
        }

###########################################################################
# Host Groups
###########################################################################

define hostgroup{
        hostgroup_name          MyDevices
        alias                   MyDevices
        members                 linux,windos,cisco
        }

###########################################################################
# Service
###########################################################################

define service{
        use                         local-service
        hostgroup_name              MyDevices
        service_description         PING
        contact_groups              networkadmins
        check_command               check_ping!500.0,20%!800.0,60%
        }
Save the config as anything.cfg and nagios will find it as long as it is the dir you defined in nagios.cfg. You can set up the configs however you want, this is just one way. Reload nagios and you should be good to go.

FYI: "use local-service" under the define service is a service template in templates.cfg. Hope this helps!
 
Old 04-23-2008, 11:06 AM   #4
itsjustdave
LQ Newbie
 
Registered: Mar 2008
Posts: 11

Rep: Reputation: 0
Quote:
Warning: Duplicate definition found for host 'generic-host' (config file '/usr/local/nagios/etc/servers/templates.cfg', starting on line 52)
Error: Could not add object property in file '/usr/local/nagios/etc/servers/templates.cfg' on line 53.

This means that 'generic-host' is definded twice. You only need to define it once, even if the 'generic-host' template is being used it many .cfg files. You need to find the duplicate and remove it.
 
Old 04-23-2008, 12:47 PM   #5
andybrr
Member
 
Registered: Mar 2006
Posts: 54

Original Poster
Rep: Reputation: 15
Exclamation Help with Nagios Configuration Basic

Hi,

I found this:

[root@fw-global servers]# fgrep generic-host *
hosts.cfg: name generic-host ; Generic template name
hosts.cfg: use generic-host
hosts.cfg: use generic-host
templates.cfg: name generic-host ; The name of this host template
templates.cfg: use generic-host ; This template inherits other values from the generic-host template
templates.cfg: ; the value that is inherited from the generic-host template!
templates.cfg: use generic-host ; Inherit default values from the generic-host template
templates.cfg: use generic-host ; Inherit default values from the generic-host template
templates.cfg: use generic-host ; Inherit default values from the generic-host template
[root@fw-global servers]#

hosts.cfg and templates.cfg

[root@fw-global servers]# cat hosts.cfg
# Generic host definitions
define host{
name generic-host ; Generic template name
notifications_enabled 1 ; Host notifications are enabled
event_handler_enabled 1 ; Host event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}

# This creates a generic template that any host can use.
# Notifies never, checks 15 times before showing critical on CGI interface,

define host{
name basic-host
use generic-host
check_command check-host-alive
max_check_attempts 15
notification_interval 0
notification_period none
notification_options n
register 0
}

# This creates a generic host that your routers can use
# monitors host(s) 24x7, notifies on down and recovery, checks 15 times before going critical,
# notifies the contact_group every 30 minutes

define host{
name your-routers-host
use generic-host
check_command check-host-alive
max_check_attempts 15
notification_interval 30
notification_period 24x7
notification_options d,r
register 0
}

define host{
use basic-host
host_name mymachine1
alias mymachine1
address 192.168.100.101
contact_groups einsteins
# notification_options d,r #overrides the basic-host option
}

define host{
use your-routers-host
host_name router1
alias router1
address 192.168.100.100
contact_groups einsteins
}
[root@fw-global servers]#

[root@fw-global servers]# cat templates.cfg
###############################################################################
# TEMPLATES.CFG - SAMPLE OBJECT TEMPLATES
#
# Last Modified: 10-03-2007
#
# NOTES: This config file provides you with some example object definition
# templates that are refered by other host, service, contact, etc.
# definitions in other config files.
#
# You don't need to keep these definitions in a separate file from your
# other object definitions. This has been done just to make things
# easier to understand.
#
###############################################################################



###############################################################################
###############################################################################
#
# CONTACT TEMPLATES
#
###############################################################################
###############################################################################

# Generic contact definition template - This is NOT a real contact, just a template!

define contact{
name generic-contact ; The name of this contact template
service_notification_period 24x7 ; service notifications can be sent anytime
host_notification_period 24x7 ; host notifications can be sent anytime
service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events
host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events
service_notification_commands notify-service-by-email ; send service notifications via email
host_notification_commands notify-host-by-email ; send host notifications via email
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
}




###############################################################################
###############################################################################
#
# HOST TEMPLATES
#
###############################################################################
###############################################################################

# Generic host definition template - This is NOT a real host, just a template!

define host{
name generic-host ; The name of this host template
notifications_enabled 1 ; Host notifications are enabled
event_handler_enabled 1 ; Host event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
notification_period 24x7 ; Send host notifications at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}


# Linux host definition template - This is NOT a real host, just a template!

define host{
name linux-server ; The name of this host template
use generic-host ; This template inherits other values from the generic-host template
check_period 24x7 ; By default, Linux hosts are checked round the clock
check_interval 5 ; Actively check the host every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each Linux host 10 times (max)
check_command check-host-alive ; Default command to check Linux hosts
notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
notification_interval 120 ; Resend notifications every 2 hours
notification_options d,u,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}



# Windows host definition template - This is NOT a real host, just a template!

define host{
name windows-server ; The name of this host template
use generic-host ; Inherit default values from the generic-host template
check_period 24x7 ; By default, Windows servers are monitored round the clock
check_interval 5 ; Actively check the server every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each server 10 times (max)
check_command check-host-alive ; Default command to check if servers are "alive"
notification_period 24x7 ; Send notification out at any time - day or night
notification_interval 30 ; Resend notifications every 30 minutes
notification_options d,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
hostgroups windows-servers ; Host groups that Windows servers should be a member of
register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE
}


# We define a generic printer template that can be used for most printers we monitor

define host{
name generic-printer ; The name of this host template
use generic-host ; Inherit default values from the generic-host template
check_period 24x7 ; By default, printers are monitored round the clock
check_interval 5 ; Actively check the printer every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each printer 10 times (max)
check_command check-host-alive ; Default command to check if printers are "alive"
notification_period workhours ; Printers are only used during the workday
notification_interval 30 ; Resend notifications every 30 minutes
notification_options d,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE
}


# Define a template for switches that we can reuse
define host{
name generic-switch ; The name of this host template
use generic-host ; Inherit default values from the generic-host template
check_period 24x7 ; By default, switches are monitored round the clock
check_interval 5 ; Switches are checked every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each switch 10 times (max)
check_command check-host-alive ; Default command to check if routers are "alive"
notification_period 24x7 ; Send notifications at any time
notification_interval 30 ; Resend notifications every 30 minutes
notification_options d,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE
}




###############################################################################
###############################################################################
#
# SERVICE TEMPLATES
#
###############################################################################
###############################################################################

# Generic service definition template - This is NOT a real service, just a template!

define service{
name generic-service ; The 'name' of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness'
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
is_volatile 0 ; The service is not volatile
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state
normal_check_interval 10 ; Check the service every 10 minutes under normal conditions
retry_check_interval 2 ; Re-check the service every two minutes until a hard state can be determined
contact_groups admins ; Notifications get sent out to everyone in the 'admins' group
notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}


# Local service definition template - This is NOT a real service, just a template!

define service{
name local-service ; The name of this service template
use generic-service ; Inherit default values from the generic-service definition
max_check_attempts 4 ; Re-check the service up to 4 times in order to determine its final (hard) state
normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until a hard state can be determined
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}

[root@fw-global servers]#

What, Where, From Do I have to remove generic-host?

Thanks.


Quote:
Originally Posted by itsjustdave View Post
This means that 'generic-host' is definded twice. You only need to define it once, even if the 'generic-host' template is being used it many .cfg files. You need to find the duplicate and remove it.
 
Old 04-23-2008, 01:09 PM   #6
itsjustdave
LQ Newbie
 
Registered: Mar 2008
Posts: 11

Rep: Reputation: 0
Code:
define host{
name generic-host ; Generic template name
notifications_enabled 1 ; Host notifications are enabled
event_handler_enabled 1 ; Host event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}
This entry is located in both host.cfg and template.cfg. Like I said before you only need generic-host to be defined in 1 .cfg file. You can remove either one of them and it should work. Just comment one out using a # for each line and then reload Nagios to verify that is the issue.
 
  


Reply



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
LXer: Nagios and Oreon (Nagios web front end) installation and Configuration LXer Syndicated Linux News 1 05-31-2016 07:26 AM
Nagios Daemon, PID not found but rc.nagios runs agentc0re Slackware 1 07-03-2007 02:47 PM
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
dhcpd configurations depam Linux - Software 2 10-07-2005 03:09 PM
speakers and configurations ronss Linux - Software 5 09-21-2003 02:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:44 PM.

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