Last active
March 27, 2020 12:47
-
-
Save bmangesh/8e188b1392256b1efb43 to your computer and use it in GitHub Desktop.
Automated Installation Of Nagios Client on Linux Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
#Author : MANGESHKUMAR B. BHARSAKLE | |
#Date : 26,27 JAN 2015 | |
# Install NRPE Plugin on Server Side | |
cd /tmp/ | |
wget http://garr.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz | |
tar -xzf nrpe-2.15.tar.gz | |
cd nrpe-2.15 | |
./configure | |
make all | |
make install-daemon | |
# Verify NRPE Daemon Remotely | |
echo " Verify NRPE Daemon Remotely " | |
read -p "Hey KING Please Enter Remote Linux Client IP: " ip_address | |
# /usr/local/nagios/libexec/check_nrpe -H $ip_address | |
# Adding Remote Linux Host to Nagios Monitoring Server | |
echo "*****Adding Remote Linux Host to Nagios Monitoring Server ****" | |
cd /usr/local/nagios/etc/ | |
touch hosts.cfg | |
touch services.cfg | |
# add these two files to main Nagios configuration file | |
echo "cfg_file=/usr/local/nagios/etc/hosts.cfg" >> /usr/local/nagios/etc/nagios.cfg | |
echo "cfg_file=/usr/local/nagios/etc/services.cfg" >> /usr/local/nagios/etc/nagios.cfg | |
read -p "Please Enter Remote Host IP Address : " remote_ip | |
echo " ## Default Linux Host Template ## | |
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 client_server ; The name we're giving to this server | |
alias CentOS 6 ; A longer name for the server | |
address $remote_ip ; IP address of Remote Linux host | |
} | |
" >> /usr/local/nagios/etc/hosts.cfg | |
#********************open services.cfg File ***************** | |
echo " define service{ | |
use generic-service | |
host_name client_server | |
service_description CPU Load | |
check_command check_nrpe!check_load | |
} | |
define service{ | |
use generic-service | |
host_name client_server | |
service_description Total Processes | |
check_command check_nrpe!check_total_procs | |
} | |
define service{ | |
use generic-service | |
host_name client_server | |
service_description Current Users | |
check_command check_nrpe!check_users | |
} | |
define service{ | |
use generic-service | |
host_name client_server | |
service_description SSH Monitoring | |
check_command check_nrpe!check_ssh | |
} | |
define service{ | |
use generic-service | |
host_name client_server | |
service_description FTP Monitoring | |
check_command check_nrpe!check_ftp | |
} | |
" >> /usr/local/nagios/etc/services.cfg | |
#**************NRPE command definition needs to be created in commands.cfg file. ********************** | |
echo " | |
# 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/etc/objects/commands.cfg | |
# ********************Finally, verify Nagios Configuration files for any errors. ********* | |
echo "Finally, verify Nagios Configuration files for any errors." | |
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg | |
#***************************************************************************************** | |
# Start Nagios Service | |
service nagios restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment