Page 1 of 2
How can I add a remote host o my Nagios Server?
Posted: Mon Jul 25, 2016 1:32 am
by hack3rcon
Hello.
I installed Nagios on my Fedora server and it can show my local services. I installed NRPE on a CentOS 7 server and configure my Nagios server via below link :
http://www.tecmint.com/how-to-add-linux ... ng-server/
But, My Nagios Server can't see my CentOS 7 host. I did below command on my Nagios server and as you see my Nagios server can see my remote CentOS :
Code: Select all
[root@localhost nagios]# /root/nagios/nrpe-3.0/src/check_nrpe -H Remote-IP
NRPE vnrpe-3.0
But I can't see my host on Nagios hosts section!!!!
How can I solve it?
Thank you.
Re: How can I add a remote host o my Nagios Server?
Posted: Mon Jul 25, 2016 1:48 am
by Box293
On your Nagios server please show us your nagios.cfg file and also the cfg file you created for your new host that you created.
Re: How can I add a remote host o my Nagios Server?
Posted: Mon Jul 25, 2016 2:04 am
by hack3rcon
Box293 wrote:On your Nagios server please show us your nagios.cfg file and also the cfg file you created for your new host that you created.
My "nagios.cfg" :
Code: Select all
##############################################################################
#
# NAGIOS.CFG - Sample Main Config File for Nagios 4.0.1
#
# Read the documentation for more information on this configuration
# file. I've provided some comments here, but things may not be so
# clear without further explanation.
#
#
##############################################################################
# LOG FILE
# This is the main log file where service and host events are logged
# for historical purposes. This should be the first option specified
# in the config file!!!
log_file=/usr/local/nagios/var/nagios.log
# OBJECT CONFIGURATION FILE(S)
# These are the object configuration files in which you define hosts,
# host groups, contacts, contact groups, services, etc.
# You can split your object definitions across several config files
# if you wish (as shown below), or keep them all in a single config file.
# You can specify individual object config files as shown below:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
# Definitions for monitoring the local (Linux) host
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
# Definitions for monitoring a Windows machine
#cfg_file=/usr/local/nagios/etc/objects/windows.cfg
# Definitions for monitoring a router/switch
#cfg_file=/usr/local/nagios/etc/objects/switch.cfg
# Definitions for monitoring a network printer
#cfg_file=/usr/local/nagios/etc/objects/printer.cfg
# 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
# OBJECT CACHE FILE
# This option determines where object definitions are cached when
# Nagios starts/restarts. The CGIs read object definitions from
# this cache file (rather than looking at the object config files
# directly) in order to prevent inconsistencies that can occur
# when the config files are modified after Nagios starts.
object_cache_file=/usr/local/nagios/var/objects.cache
# PRE-CACHED OBJECT FILE
# This options determines the location of the precached object file.
# If you run Nagios with the -p command line option, it will preprocess
# your object configuration file(s) and write the cached config to this
# file. You can then start Nagios with the -u option to have it read
# object definitions from this precached file, rather than the standard
# object configuration files (see the cfg_file and cfg_dir options above).
# Using a precached object file can speed up the time needed to (re)start
# the Nagios process if you've got a large and/or complex configuration.
# Read the documentation section on optimizing Nagios to find our more
# about how this feature works.
precached_object_file=/usr/local/nagios/var/objects.precache
# RESOURCE FILE
# This is an optional resource file that contains $USERx$ macro
# definitions. Multiple resource files can be specified by using
# multiple resource_file definitions. The CGIs will not attempt to
# read the contents of resource files, so information that is
# considered to be sensitive (usernames, passwords, etc) can be
# defined as macros in this file and restrictive permissions (600)
# can be placed on this file.
resource_file=/usr/local/nagios/etc/resource.cfg
# STATUS FILE
# This is where the current status of all monitored services and
# hosts is stored. Its contents are read and processed by the CGIs.
# The contents of the status file are deleted every time Nagios
# restarts.
status_file=/usr/local/nagios/var/status.dat
# STATUS FILE UPDATE INTERVAL
# This option determines the frequency (in seconds) that
# Nagios will periodically dump program, host, and
# service status data.
status_update_interval=10
# NAGIOS USER
# This determines the effective user that Nagios should run as.
# You can either supply a username or a UID.
nagios_user=nagios
# NAGIOS GROUP
# This determines the effective group that Nagios should run as.
# You can either supply a group name or a GID.
nagios_group=nagios
# EXTERNAL COMMAND OPTION
# This option allows you to specify whether or not Nagios should check
# for external commands (in the command file defined below). By default
# Nagios will *not* check for external commands, just to be on the
# cautious side. If you want to be able to use the CGI command interface
# you will have to enable this.
# Values: 0 = disable commands, 1 = enable commands
check_external_commands=1
# EXTERNAL COMMAND FILE
# This is the file that Nagios checks for external command requests.
# It is also where the command CGI will write commands that are submitted
# by users, so it must be writeable by the user that the web server
# is running as (usually 'nobody'). Permissions should be set at the
# directory level instead of on the file, as the file is deleted every
# time its contents are processed.
command_file=/usr/local/nagios/var/rw/nagios.cmd
# QUERY HANDLER INTERFACE
# This is the socket that is created for the Query Handler interface
#query_socket=/usr/local/nagios/var/rw/nagios.qh
# LOCK FILE
# This is the lockfile that Nagios will use to store its PID number
# in when it is running in daemon mode.
lock_file=/usr/local/nagios/var/nagios.lock
# TEMP FILE
# This is a temporary file that is used as scratch space when Nagios
# updates the status log, cleans the comment file, etc. This file
# is created, used, and deleted throughout the time that Nagios is
# running.
temp_file=/usr/local/nagios/var/nagios.tmp
# TEMP PATH
# This is path where Nagios can create temp files for service and
# host check results, etc.
temp_path=/tmp
# EVENT BROKER OPTIONS
# Controls what (if any) data gets sent to the event broker.
# Values: 0 = Broker nothing
# -1 = Broker everything
# <other> = See documentation
event_broker_options=-1
# EVENT BROKER MODULE(S)
# This directive is used to specify an event broker module that should
# by loaded by Nagios at startup. Use multiple directives if you want
# to load more than one module. Arguments that should be passed to
# the module at startup are seperated from the module path by a space.
#
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
# Do NOT overwrite modules while they are being used by Nagios or Nagios
# will crash in a fiery display of SEGFAULT glory. This is a bug/limitation
# either in dlopen(), the kernel, and/or the filesystem. And maybe Nagios...
#
# The correct/safe way of updating a module is by using one of these methods:
# 1. Shutdown Nagios, replace the module file, restart Nagios
# 2. Delete the original module file, move the new module file into place, re
start Nagios
#
# Example:
#
# broker_module=<modulepath> [moduleargs]
#broker_module=/somewhere/module1.o
#broker_module=/somewhere/module2.o arg1 arg2=3 debug=0
# LOG ROTATION METHOD
# This is the log rotation method that Nagios should use to rotate
# the main log file. Values are as follows..
# n = None - don't rotate the log
# h = Hourly rotation (top of the hour)
# d = Daily rotation (midnight every day)
# w = Weekly rotation (midnight on Saturday evening)
# m = Monthly rotation (midnight last day of month)
log_rotation_method=d
# LOG ARCHIVE PATH
# This is the directory where archived (rotated) log files should be
# placed (assuming you've chosen to do log rotation).
log_archive_path=/usr/local/nagios/var/archives
# LOGGING OPTIONS
# If you want messages logged to the syslog facility, as well as the
# Nagios log file set this option to 1. If not, set it to 0.
use_syslog=1
# NOTIFICATION LOGGING OPTION
# If you don't want notifications to be logged, set this value to 0.
# If notifications should be logged, set the value to 1.
log_notifications=1
# SERVICE RETRY LOGGING OPTION
# If you don't want service check retries to be logged, set this value
# to 0. If retries should be logged, set the value to 1.
log_service_retries=1
# HOST RETRY LOGGING OPTION
# If you don't want host check retries to be logged, set this value to
# 0. If retries should be logged, set the value to 1.
log_host_retries=1
# EVENT HANDLER LOGGING OPTION
# If you don't want host and service event handlers to be logged, set
# this value to 0. If event handlers should be logged, set the value
# to 1.
log_event_handlers=1
# INITIAL STATES LOGGING OPTION
# If you want Nagios to log all initial host and service states to
# the main log file (the first time the service or host is checked)
# you can enable this option by setting this value to 1. If you
# are not using an external application that does long term state
# statistics reporting, you do not need to enable this option. In
# this case, set the value to 0.
log_initial_states=0
# CURRENT STATES LOGGING OPTION
# If you don't want Nagios to log all current host and service states
# after log has been rotated to the main log file, you can disable this
# option by setting this value to 0. Default value is 1.
log_current_states=1
# EXTERNAL COMMANDS LOGGING OPTION
# If you don't want Nagios to log external commands, set this value
# to 0. If external commands should be logged, set this value to 1.
# Note: This option does not include logging of passive service
# checks - see the option below for controlling whether or not
# passive checks are logged.
log_external_commands=1
# PASSIVE CHECKS LOGGING OPTION
# If you don't want Nagios to log passive host and service checks, set
# this value to 0. If passive checks should be logged, set
# this value to 1.
log_passive_checks=1
# GLOBAL HOST AND SERVICE EVENT HANDLERS
# These options allow you to specify a host and service event handler
# command that is to be run for every host or service state change.
# The global event handler is executed immediately prior to the event
# handler that you have optionally specified in each host or
# service definition. The command argument is the short name of a
# command definition that you define in your host configuration file.
# Read the HTML docs for more information.
#global_host_event_handler=somecommand
#global_service_event_handler=somecommand
.
.
.
.
# the query handler. Please note that this is an experimental feature
# and not meant for production use. Used incorrectly it can induce
# enormous latency.
# #core loadctl
# jobs_max - The maximum amount of jobs to run at one time
# jobs_min - The minimum amount of jobs to run at one time
# jobs_limit - The maximum amount of jobs the current load lets us run
# backoff_limit - The minimum backoff_change
# backoff_change - # of jobs to remove from jobs_limit when backing off
# rampup_limit - Minimum rampup_change
# rampup_change - # of jobs to add to jobs_limit when ramping up
# NOTE: The backoff_limit and rampup_limit are NOT used by anything currently,
# so if your system is under load nothing will actively modify the jobs
# even if you have these options enabled, they are for external
# connector information only. However, if you change the jobs_max or
# jobs_min manually here or through the query handler interface that
# WILL affect your system
#loadctl_options=jobs_max=100;backoff_limit=10;rampup_change=5
cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
And my host file is :
Code: Select all
define host{
name linux-box ; Name of this template
use generic-host ; Inherit default values
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
register 0 ; DONT REGISTER THIS - ITS A TEMPLATE
}
## Default
define host{
use linux-box ; Inherit default values from a template
host_name tecmint ; The name we're giving to this server
alias CentOS 7 ; A longer name for the server
address Remote IP ; IP address of Remote Linux host
}
Re: How can I add a remote host o my Nagios Server?
Posted: Mon Jul 25, 2016 2:22 am
by Box293
Those config files look OK.
I assume your hosts file is /usr/local/nagios/etc/hosts.cfg
Did you restart the nagios service after updating the config files?
If you look in this file:
/usr/local/nagios/var/objects.cache
Do you see your new host in this file?
Re: How can I add a remote host o my Nagios Server?
Posted: Mon Jul 25, 2016 2:31 am
by hack3rcon
Box293 wrote:Those config files look OK.
I assume your hosts file is /usr/local/nagios/etc/hosts.cfg
Did you restart the nagios service after updating the config files?
If you look in this file:
/usr/local/nagios/var/objects.cache
Do you see your new host in this file?
Excuse me, My remote host is not joined to any domain and it is "localhost.localdomain", I selected a name for it in my config file and yes I can see it in "objects.cache" file.
Re: How can I add a remote host o my Nagios Server?
Posted: Mon Jul 25, 2016 2:58 am
by Box293
It sounds like the host object does exist in Nagios.
In the Nagios Core interface, under "Current Status" click Hosts.
Is your host appearing in this list?
If not, search for it. On the left pane there is a "Quick Search" field. Does a search find it.
If that doesn't help, show us some screenshots that demonstrate what your problem is.
Re: How can I add a remote host o my Nagios Server?
Posted: Mon Jul 25, 2016 4:41 am
by hack3rcon
I just see "localhost" and search can't find anything

I attached a photo.
Re: How can I add a remote host o my Nagios Server?
Posted: Mon Jul 25, 2016 3:23 pm
by tgriep
It looks like the configuration file for your centos7 host needs to be added to the nagios.cfg file.
For example, if you called the config file centos7host.cfg, you would add that entry in the nagios.cfg like below.
Code: Select all
cfg_file=/usr/local/nagios/etc/objects/centos7host.cfg
Then run the following to restart the nagios process and that should fix it for you.
Also, take a look at this link to configure your remote host to be monitored with the NRPE Agent.
https://assets.nagios.com/downloads/nag ... e/NRPE.pdf
Re: How can I add a remote host o my Nagios Server?
Posted: Tue Jul 26, 2016 12:36 am
by hack3rcon
As you see, I added my "host.cfg" to my "nagios.cfg" and problem not solved.
Re: How can I add a remote host o my Nagios Server?
Posted: Tue Jul 26, 2016 1:43 am
by Box293
hack3rcon wrote:yes I can see it in "objects.cache" file.
If the host is in the
objects.cache file then Nagios has recognized it.
Can you force a refresh of your web page when viewing Nagios or perhaps try a different browser?
I'm going to ask a really obvious question but something is not adding up. Is the Nagios server you are looking at in the web page the same Nagios server you created the config files on?
Can you run the following command on your Nagios server:
This will show the IP address of the Nagios server. Can you please make sure this is the web page you are looking at.