Installing and Configuiring Nagio’s
Installing and Configuiring Nagio’s for Network and Server Monitoring
I am very impressed with the power Nagios displays in network monitoring. It may not be easy to set it up perfectly but I have not run across any limitations with it so far. so I am willing to share my setup and config files to save someone else a lot of time in finding a good way to organize and configure there layout.
Centos 64 bit,
Lets first create or set a 2gb swap file:
dd if=/dev/zero of=/swap bs=1024 count=2097152 mkswap /swap && chown root. /swap && chmod 0600 /swap && swapon /swap echo /swap swap swap defaults 0 0 >>
/etc/fstab echo vm.swappiness = 0 >> /etc/sysctl.conf && sysctl -p
Install Nagios
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpmrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpmyum -y install nagios nagios-plugins-all nagios-plugins-nrpe nrpe php httpdchkconfig httpd on ; chkconfig nagios on
No lets setup a nagios Password for the Control Panel:
htpasswd -c /etc/nagios/passwd nagiosadmin# keep the username “nagiosadmin” the same to avoid any further issues
Install NRPE on Clients
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm yum -y install nagios nagios-plugins-all nrpe chkconfig nrpe on
Edit NRPE
nano /etc/nagios/nrpe.cfg
log_facility=daemon pid_file=/var/run/nrpe/nrpe.pid server_port=5666 nrpe_user=nrpe nrpe_group=nrpe allowed_hosts=198.211.117.251 dont_blame_nrpe=1 debug=0 command_timeout=60 connection_timeout=300 include_dir=/etc/nrpe.d/ command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10 command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/vda command[check_zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -s Z command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w 150 -c 200 command[check_procs]=/usr/lib64/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
Configuire IP Tables to accept traffic from all Monitoring Servers and nothing else:
iptables -N NRPE iptables -I INPUT -s 0/0 -p tcp --dport 5666 -j NRPE iptables -I NRPE -s 198.211.117.251 -j ACCEPT iptables -A NRPE -s 0/0 -j DROP /etc/init.d/iptables save
Start NRPE
service nrpe start
Configuiring the Monitoring server (Nagios)
I wish to first say that in my defualt config on centos 6 all my config files are in /etc/nagios. In my setup i have left those in there but added the real ones in /var/local/nagios and included the location in the real files ( you do not need to do this)
First edit the main /etc/nagios . Then comment out the original folders and main files defualt location and add the folders where you want the configs to be.
nano /etc/nagioscfg_file=/etc/nagios/objects/commands.cfg
#cfg_file=/etc/nagios/objects/contacts.cfg
cfg_file=/etc/nagios/objects/timeperiods.cfg
#cfg_file=/etc/nagios/objects/templates.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=/etc/nagios/objects/localhost.cfg
#cfg_dir=/etc/nagios/servers
#cfg_dir=/etc/nagios/printers
#cfg_dir=/etc/nagios/switches
#cfg_dir=/etc/nagios/routers
cfg_dir=/usr/local/nagios/etc/objects/CyfordTech/Windows
cfg_dir=/usr/local/nagios/etc/objects/CyfordTech/Router
cfg_dir=/usr/local/nagios/etc/objects/CyfordTech/Switch
cfg_dir=/usr/local/nagios/etc/objects/CyfordTech/Printer
cfg_dir=/usr/local/nagios/etc/objects/CyfordTech/Linux
cfg_dir=/usr/local/nagios/etc/objects/CyfordTech/External
cfg_dir=/etc/nagios/conf.d
Config files i believe is alot of work to really post on one website. So instead i have created a virtual network for testing and i will give you access to my files.
You can view and download my sample configs from
https://www.cyfordtechnologies.com/Downloads/objects
Published on: Mar 03, 2021
No Comments yet! Be the first one to write.