↑ Top
Kaai24
dev studios
| Sign in | DE EN

Add Linux Host to Nagios Server


On Linux Host

apt install nagios-plugins nagios-nrpe-server

nano /etc/nagios/nrpe.cfg

Search these lines and change them to your needs

allowed_hosts=127.0.0.1, NAGIOS-SERVER-IP

command[check_root]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /

On Nagios Server

Be aware that every "nano" command means you need to open this new file and save the old one. Change everything to your needs.

cd /usr/local/nagios/etc/
touch hosts.cfg
touch services.cfg

nano /usr/local/nagios/etc/nagios.cfg

# You can specify individual object config files as shown below:
cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg

nano /usr/local/nagios/etc/hosts.cfg

## Default Linux Host Template ##
define host{
name                            linux-host              ; 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-host              ; Inherit default values from a template
host_name                       HOSTNAME	        ; The name we're giving to this server
alias                           CUSTOMNAME              ; A longer name for the server
address                         10.0.0.1                ; IP address of Remote Linux host
}

nano /usr/local/nagios/etc/services.cfg

define service{
use                     generic-service
host_name               HOSTNAME
service_description     CPU Load
check_command           check_nrpe!check_load
}
define service{
use                     generic-service
host_name               HOSTNAME
service_description     Total Processes
check_command           check_nrpe!check_total_procs
}
define service{
use                     generic-service
host_name               HOSTNAME
service_description     Current Users
check_command           check_nrpe!check_users
}
define service{
use                     generic-service
host_name               HOSTNAME
service_description     SSH Monitoring
check_command           check_nrpe!check_ssh
}
define service{
use                     generic-service
host_name               HOSTNAME
service_description     FTP Monitoring
check_command           check_nrpe!check_ftp
}

nano /usr/local/nagios/etc/objects/commands.cfg

###############################################################################
# NRPE CHECK COMMAND
#
# Command to use NRPE to check remote host systems
###############################################################################
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

service nagios restart

(Edited 10-06-19)

Comments

Kaai
Just updated