Montoring help with multiple Devices

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
Gh0stRyd3r
Posts: 7
Joined: Tue Jan 03, 2017 3:35 pm

Montoring help with multiple Devices

Post by Gh0stRyd3r »

I am trying to understand how to monitor more than one type of device in the root categories of switches and servers. I see there are two methods for the .cfg either the switch.cfg and edit it or the directory that looks at multiple .cfg. I am not sure if my Googleness is failing me but I keep finding the post on how to edit for the first device and then it has a quick blurb that you will just magically somehow pick the other devices up in the same host catagory?

I tried making multiple .cfg's for switches and gett errors

Code: Select all

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
Warning: Duplicate definition found for hostgroup 'switches' (config file '/usr/local/nagios/etc/switches/grn-mdf.cfg', starting on line 44)
Error: Could not add object property in file '/usr/local/nagios/etc/switches/grn-mdf.cfg' on line 45.
Error: Invalid max_check_attempts value for host 'Closet1_Switch1'
Error: Could not register host (config file '/usr/local/nagios/etc/switches/Closet1_Switch1.cfg', starting on line 23)
Error processing object config files!


***> 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.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Montoring help with multiple Devices

Post by rkennedy »

Can you please post these files for us to look at?

Code: Select all

/usr/local/nagios/etc/switches/grn-mdf.cfg
/usr/local/nagios/etc/switches/Closet1_Switch1.cfg
Additionally, this file may help you - https://assets.nagios.com/downloads/nag ... uters.html

The specific error makes me think you may have two identical definitions, for example -

Code: Select all

define host {
    use         generic-switch          ; Inherit default values from a template
    host_name   linksys-srw224p         ; The name we're giving to this switch
    alias       Linksys SRW224P Switch  ; A longer name associated with the switch
    address     192.168.1.253           ; IP address of the switch
    hostgroups  allhosts,switches       ; Host groups this switch is associated with
}
define host {
    use         generic-switch          ; Inherit default values from a template
    host_name   linksys-srw224p         ; The name we're giving to this switch
    alias       Linksys SRW224P Switch  ; A longer name associated with the switch
    address     192.168.1.253           ; IP address of the switch
    hostgroups  allhosts,switches       ; Host groups this switch is associated with
}
This will not work, because the host_name is not unique.
Former Nagios Employee
Gh0stRyd3r
Posts: 7
Joined: Tue Jan 03, 2017 3:35 pm

Re: Montoring help with multiple Devices

Post by Gh0stRyd3r »

So I understand the Host names are different and alias but the HostGroup I assumed was supposed to be the same so they all show under the same area Switches>Network Swtiches.

Code: Select all

###############################################################################
# SWITCH.CFG - SAMPLE CONFIG FILE FOR MONITORING A SWITCH
#
#
# NOTES: This config file assumes that you are using the sample configuration
#        files that get installed with the Nagios quickstart guide.
#
###############################################################################




###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################

# Define the switch that we'll be monitoring

define host{
        use               generic-switch          ; Inherit default values from a template
        host_name       Closet1_Switch1         ; The name we're giving to this switch
        alias           Cisco 3750              ; A longer name associated with the switch
        address         172.19.182.20           ; IP address of the switch
        hostgroups      switches                ; Host groups this switch is associated with
        }




###############################################################################
###############################################################################
#
# HOST GROUP DEFINITIONS
#
###############################################################################
###############################################################################

# Create a new hostgroup for switches

define hostgroup{
        hostgroup_name  switches                ; The name of the hostgroup
        alias           Network Switches        ; Long name of the group
        }




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

# Create a service to PING to switch

define service{
        use                     generic-service ; Inherit values from a template
        host_name               Closet1_Switch1 ; The name of the host the service is associated with
        service_description     PING            ; The service description
        check_command           check_ping!200.0,20%!600.0,60%  ; The command used to monitor the service
        normal_check_interval   5               ; Check the service every 5 minutes under normal conditions
        retry_check_interval    1               ; Re-check the service every minute until its final/hard state is determined
        }


# Monitor uptime via SNMP

define service{
        use                     generic-service ; Inherit values from a template
        host_name               Closet1_Switch1
        service_description     Uptime
        check_command           check_snmp!-C public -o sysUpTime.0
        }



# Monitor Port 1 status via SNMP

define service{
        use                     generic-service ; Inherit values from a template
        host_name               Closet1_Switch1
        service_description     Port 1 Link Status
        check_command           check_snmp!-C proceed -o ifOperStatus.1 -r 1 -m RFC1213-MIB
        }



# Monitor bandwidth via MRTG logs

define service{
        use                     generic-service ; Inherit values from a template
        host_name               Closet1_Switch1
        service_description     Port 1 Bandwidth Usage
        check_command           check_local_mrtgtraf!/var/lib/mrtg/172.19.182.20_1.log!AVG!1000000,1000000!5000000,5000000!10
        }

Code: Select all

###############################################################################
# SWITCH.CFG - SAMPLE CONFIG FILE FOR MONITORING A SWITCH
#
#
# NOTES: This config file assumes that you are using the sample configuration
#        files that get installed with the Nagios quickstart guide.
#
###############################################################################




###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################

# Define the switch that we'll be monitoring

define host{
        use             core-switch             ; Inherit default values from a template
        host_name       grn-mdf                 ; The name we're giving to this switch
        alias           Cisco 6509-E Chasis     ; A longer name associated with the switch
        address         172.19.182.2            ; IP address of the switch
        hostgroups      switches                ; Host groups this switch is associated with
        }




###############################################################################
###############################################################################
#
# HOST GROUP DEFINITIONS
#
###############################################################################
###############################################################################

# Create a new hostgroup for switches

define hostgroup{
        hostgroup_name  switches                ; The name of the hostgroup
        alias           Network Switches        ; Long name of the group
        }




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

# Create a service to PING to switch

define service{
        use                     generic-service ; Inherit values from a template
        host_name               grn-mdf         ; The name of the host the service is associated with
        service_description     PING            ; The service description
        check_command           check_ping!200.0,20%!600.0,60%  ; The command used to monitor the service
        normal_check_interval   5               ; Check the service every 5 minutes under normal conditions
        retry_check_interval    1               ; Re-check the service every minute until its final/hard state is determined
        }


# Monitor uptime via SNMP

define service{
        use                     generic-service ; Inherit values from a template
        host_name               grn-mdf
        service_description     Uptime
        check_command           check_snmp!-C public -o sysUpTime.0
        }



# Monitor Port 1 status via SNMP

define service{
        use                     generic-service ; Inherit values from a template
        host_name               grn-mdf
        service_description     Port 1 Link Status
        check_command           check_snmp!-C proceed -o ifOperStatus.1 -r 1 -m RFC1213-MIB
        }



# Monitor bandwidth via MRTG logs

define service{
        use                     generic-service ; Inherit values from a template
        host_name               grn-mdf
        service_description     Port 1 Bandwidth Usage
        check_command           check_local_mrtgtraf!/var/lib/mrtg/172.19.182.2_1.log!AVG!1000000,1000000!5000000,5000000!10
        }
Gh0stRyd3r
Posts: 7
Joined: Tue Jan 03, 2017 3:35 pm

Re: Montoring help with multiple Devices

Post by Gh0stRyd3r »

Well I feel completely dumb had to remove the Default Host part read it 100 times and finally sunk in that it was only to make a new Host Group not to add it to the existing one.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Montoring help with multiple Devices

Post by rkennedy »

Aha! We just got back in the office a little bit ago. To help further explain, take a look at this link - https://assets.nagios.com/downloads/nag ... #hostgroup

Code: Select all

define hostgroup{
        hostgroup_name  switches                ; The name of the hostgroup
        alias           Network Switches        ; Long name of the group
        }
You can define the members here, or at the host level. Either way will work, but yes, you'll only want to create the hostgroup once.
Former Nagios Employee
Locked