Newbie - using localhost.cfg for all of my hosts ...

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
jdworske
Posts: 10
Joined: Tue Jun 24, 2014 3:47 pm

Newbie - using localhost.cfg for all of my hosts ...

Post by jdworske »

Nagios Community,

I recently set up Nagios on VM running CentOS 6.5.

I have basically set up all monitoring via the localhost.cfg file and it seems to be working.

Is this correct ? Can I use the locahost.cfg file for monitoring all of my machines ?

I am using the specific config file for Printers and switches and those are obvious.

But my concern is that using the Locahost.cfg file is not the correct config.

I am thinking that I need to use the templates to create a 'hosts.cfg' and configure the main nagios.cfg file with the directive to use a hosts.cfg file?

My question is:

Is it ok to use that locahost.cfg for monitoring of all my servers?

Thank you,
John DWorske
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Newbie - using localhost.cfg for all of my hosts ...

Post by slansing »

Your configuration files are typically the names of your hosts/services/etc, you will want to create new .cfg files for each remote system, and then attach additional service configurations to them. You can use the How To Monitor sections here as an example:

http://nagios.sourceforge.net/docs/3_0/ ... tions.html

Ask if you have any questions!
jdworske
Posts: 10
Joined: Tue Jun 24, 2014 3:47 pm

Re: Newbie - using localhost.cfg for all of my hosts ...

Post by jdworske »

Slansing,

Thank you very much for your reply.

So I have gone ahead as you suggested created a new config file for each one of my hosts.

For example this is in my main nagios.cfg file:

# Definitions for monitoring the all other (Linux) hosts
cfg_file=/usr/local/nagios/etc/objects/devsamba.cfg
cfg_file=/usr/local/nagios/etc/objects/hq-devjms-02.cfg
cfg_file=/usr/local/nagios/etc/objects/hq-schd-01.cfg
cfg_file=/usr/local/nagios/etc/objects/hq-ui-01.cfg
cfg_file=/usr/local/nagios/etc/objects/hq-db-02.cfg
cfg_file=/usr/local/nagios/etc/objects/hq-db-01.cfg
cfg_file=/usr/local/nagios/etc/objects/hq-db-10g.cfg
cfg_file=/usr/local/nagios/etc/objects/hq-devftp-01.cfg
cfg_file=/usr/local/nagios/etc/objects/hq-devstar-01.cfg
cfg_file=/usr/local/nagios/etc/objects/hq-devstar1.cfg
cfg_file=/usr/local/nagios/etc/objects/hq-ids-01.cfg
cfg_file=/usr/local/nagios/etc/objects/hq-jenkins-01.cfg


Below is my remote machine 'devsamba' cfg file..

As you can see I was using the 'check-local-xx' commands that were int the locahost.cfg file to try and get some things monitored, however, I believe that all the 'local' commands are actually being run on the locahost (my nagios server) and not actually running those commands on the remote machines.

Where do I find the syntax for 'check_commands' that can be run on remote machines.

For instance I want to check the 'load'/'root partition'/'users' and possibly other disk space on devsamba. How would I do that ?

It seems that this is not going to work:

define service{
host_name devsamba
service_description Current Load
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}





[root@hq-nagios-02 objects]# cat devsamba.cfg
#########################################################################################################################################
#########################################################################################################################################
#Below is the Linux hosts configuration file that will contain all Linux hosts being monitored in MyVest HQ.
#########################################################################################################################################
#########################################################################################################################################

define host{
host_name devsamba
alias devsamba
#display_name devsamba
address 192.168.0.17
hostgroups linux-servers
check_command check-host-alive
initial_state o
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
retain_status_information 0
retain_nonstatus_information 0
contacts nagiosadmin
contact_groups admins
notification_interval 30
#first_notification_delay #
notification_period 24x7
notification_options d,u,r
notifications_enabled 1
}

#########################################################################################################################################
#########################################################################################################################################


define service{
use generic-service ; Inherit default values from a template
host_name devsamba
service_description SSH
check_command check_ssh
notifications_enabled 1
}

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


#define service{
# host_name devsamba
# service_description Current Load
# check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
# }

#define service{
# use local-service ; Name of service template to use
# host_name devsamba
# service_description Current Users
# check_command check_local_users!20!50
# }
#
#define service{
# use local-service ; Name of service template to use
# host_name devsamba
# service_description Root Partition
# check_command check_local_disk!20%!10%!/
# }
#
#define service{
# use local-service ; Name of service template to use
# host_name devsamba
# service_description Swap Usage
# check_command check_local_swap!20!10
# }
#
#define service{
# use local-service ; Name of service template to use
# host_name devsamba
# service_description Total Processes
# check_command check_local_procs!250!400!RSZDT
# }
#


Thank you,
John Dworske
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Newbie - using localhost.cfg for all of my hosts ...

Post by tmcdonald »

You are correct here: "local" commands are going to check local resources. It would be an incredible security risk if you could just randomly check the CPU load, memory, disk space, etc. of any machine, which is why the plugins can't check them directly. For that you need an agent running on the remote machine that will accept requests for checks, execute them, and send back the results.

That remote agent is usually NRPE: http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf
Former Nagios employee
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Newbie - using localhost.cfg for all of my hosts ...

Post by eloyd »

You can also install the plugins on the remote host and use the check_by_ssh wrapper to first SSH to the remote box (set up RSA keys without passphrases to make this work) and then run the check that way. Sometimes checking by SSH is easier than going through the motions of installing an agent and configuring xinetd and so forth, since you're really just executing a single command on the remote host through SSH and grabbing its output.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
jdworske
Posts: 10
Joined: Tue Jun 24, 2014 3:47 pm

Re: Newbie - using localhost.cfg for all of my hosts ...

Post by jdworske »

Thanks for the replies fellas!!!

Nagios is up and running nicely for me using NRPE.

Quick question.

is check_snmp plugin available anywhere ?

I don't seem to see that plugin in:

/usr/local/nagios/libexec

Thanks in advance for any assistance.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Newbie - using localhost.cfg for all of my hosts ...

Post by Box293 »

I was just reading this in another post today:

check_snmp is part of the nagios-plugins but it won't compile it if you don't have net-snmp, as indicated in the REQUIREMENTS file included with nagios-plugins...

[root@localhost nagios-plugins-1.4.11]# cat REQUIREMENTS

Nagios Plugin Requirements
--------------------------

Some plugins require that you have additional programs and/or
libraries installed on your system before they can be used. Plugins
that are dependent on other programs/libraries that are missing are
usually not compiled. Requirements for various plugins are listed
below...
...
check_snmp:
- Requires the NET-SNMP package available from
http://net-snmp.sourceforge.net/
...
.

Install net-snmp and recompile the plugins, then you should have check_snmp.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked