Localhost error

Engage with the community of users including those using the open source solutions.
Includes Nagios Core, Plugins, and NCPA

Localhost error

Postby Pr3tender » Tue Sep 28, 2021 2:34 pm

Hi,
I'm new to Nagios CentOs,any help will be much appreciated. Reading and watching some videos I manage to get the server running. When I try to add a switch I'm getting this error:

Error: Template 'linux-servers' specified in host definition could not be not found (config file '/usr/local/nagios/etc/objects/localhost.cfg', starting on line 21)
Error: Invalid max_check_attempts value for host 'localhost'
Error: Could not register host (config file '/usr/local/nagios/etc/objects/localhost.cfg', starting on line 21)
Error processing object config files!

I didnt change the localhost file, it was not show on the YouTube video I was referencing

here is my config file:

##############################################################################
# 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 s01 ; The name we're giving to this switch
alias Core Switch ; A longer name associated with the switch
address 192.168.1.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 s01 ; 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
check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_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 s01
service_description Uptime
check_command check_snmp!-C CCARO -o sysUpTime.0
}



# Monitor Port 1 status via SNMP

define service{
use generic-service ; Inherit values from a template
host_name s01
service_description Port 1 Link Status
check_command check_snmp!-C CCARO -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 s01
service_description Port 1 Bandwidth Usage
check_command check_local_mrtgtraf!/var/lib/mrtg/192.168.1.2_1.log!AVG!1000000,1000000!5000000,5000000!10
}

Thank you,
Pr3tender
 
Posts: 6
Joined: Tue Sep 28, 2021 2:23 pm

Re: Localhost error

Postby pbroste » Tue Sep 28, 2021 5:02 pm

Hello @Pr3tender

Thanks for reaching out, the suggestion to move the config that you created out of .../nagios/etc/... for the time being and run a pre-flight check to see what is failing:

  • Code: Select all
    /usr/local/nagios/bin/nagios -vvv /usr/local/nagios/etc/nagios.cfg

Make any changes necessary.

Thanks,
Perry
User avatar
pbroste
 
Posts: 680
Joined: Tue Jun 01, 2021 1:27 pm

Re: Localhost error

Postby Pr3tender » Wed Sep 29, 2021 10:21 am

Hi Perry,

I move the file to a temp folder run the command and I get the same error, something with localhost.cfg do I need to do changes to that configuration? I have not made any notifications to that file. I got an example from youtube that only change the switch confing file.

Thanks


Nagios Core 4.4.6
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2020-04-28
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/switch.cfg'...
Error: Cannot open config file '/usr/local/nagios/etc/objects/switch.cfg' for reading: No such file or directory
Error: Invalid max_check_attempts value for host 'localhost'
Error: Could not register host (config file '/usr/local/nagios/etc/objects/localhost.cfg', starting on line 21)
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 definitions. 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.
Pr3tender
 
Posts: 6
Joined: Tue Sep 28, 2021 2:23 pm

Re: Localhost error

Postby Pr3tender » Wed Sep 29, 2021 11:35 am

I'm not sure if this is a duplicate:

I move the file to a tmp folder. run the command and I received the same error. I have not modified the localhost.cfg file when I watch the video on youtube didn't mention that I need to modify the localhost.cfg. I only modify the switch.cfg
The localhost.cfg it has the original settings.

after running the command:

Nagios Core 4.4.6
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2020-04-28
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/switch.cfg'...
Error: Cannot open config file '/usr/local/nagios/etc/objects/switch.cfg' for reading: No such file or directory
Error: Invalid max_check_attempts value for host 'localhost'
Error: Could not register host (config file '/usr/local/nagios/etc/objects/localhost.cfg', starting on line 21)
Error processing object config files!

Thanks!!
Pr3tender
 
Posts: 6
Joined: Tue Sep 28, 2021 2:23 pm

Re: Localhost error

Postby Pr3tender » Thu Sep 30, 2021 1:07 pm

I found the error. On the nagios.cfg I remove the # from the line for localhost. when I put the # everything started working.
Pr3tender
 
Posts: 6
Joined: Tue Sep 28, 2021 2:23 pm

Re: Localhost error

Postby benjaminsmith » Thu Sep 30, 2021 3:23 pm

I found the error. On the nagios.cfg I remove the # from the line for localhost. when I put the # everything started working.

Excellent! Good to hear.

We'll go ahead and close this post, but feel free to open another if you have any new questions.

--Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
benjaminsmith
 
Posts: 5206
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul


Return to Community Support

Who is online

Users browsing this forum: akaspar and 15 guests