Popular Posts

Showing posts with label Nagios. Show all posts
Showing posts with label Nagios. Show all posts

Saturday, 2 September 2017

Preparing Linux Server for Nagios monitoring tool

In this article we are going to discuss about the best practice to install an Linux server for nagios monitoring tool. As like regular installation will also work but we will face an issue later an while configuring the nagios alerts, integrating with nagvis and pnp4nagios. Preparing Linux Server for Nagios Monitoring tool
Just remember to follow the below steps to prepare an Linux server for nagios monitoring tool.

Preparing Linux server for Nagios monitoring tool

We have consider below steps to make best nagios monitoring tool implementation
  1. Do not install all packages all are not required
  2. Install Linux server with minimal installation
  3. Do remember to install php, perl, shell, basic tools, snmp, httpd, ssh, tar, wget, python and crond
  4. While installing make a separate partition for /usr/ using LVM (As a default installation location if you considered. if you want to change you also do that )
  5. Create all separate partition for Nagios archive Logs
  6. One important thing is to check version compatibility
  7. Use always stable versions to build production servers.

Nagios core Installation in RHEL7 / Centos 7 Step by Step Guide

Nagios Core 4 Installation Step by step guide in RHEL 7 / Centos 7. Nagios Core Installation is simple and easy process but when your doing for the first time you will little bit confused, Installation of Nagios core is plays major role because while installing we have to run configure as nagcmd group or else all the file permissions and configuration files we have to change later.

What is Nagios core..?? How to do Nagios Core Installation

Nagios core is an most popular and enterprise open source monitoring tool. Using this monitoring tool you can monitor any device in this world even UPS / Battery status. This tool will support almost all the scripting languages.
Prepare your Linux server to install Nagios monitoring tool
Nagios Version:  4.1.1

Prerequisites:

  • Nagios code is written in C language so you required an gcc++ compiler packages to compile and install Nagios.
  • Required wget package to download the nagios tool directly from web to server
  • To untar  the package required Rar / Zip RPM’s
  • Web / Apache / Httpd service to host the Nagios
  • Install php and perl packages to run Nagios plugins

Step1:> Installing prerequisites

~]# yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp perl perl-devel openssl
by using above command it will install all the required prerequisites

Step2:> Download the Nagios Core Package from web

~]#wget http://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.1.1/nagios-4.1.1.tar.gz
using above command you can download the NagiosCore 4.1.1 package

Step3:> Create Nagios User and Nagcmd group

~]#useradd nagios                ##Creating Nagios User
~]#groupadd nagcmd               ##Creating Nagcmd Group
~]#usermod -a -G nagcmd nagios   ##Adding nagios user to nagcmd group

Step4:> Untar the Package

~]#tar -xzvf nagios-4.1.1.tar.gz
above command will untar the tar file

Step5:> Compiling Nagios code

cd nagios-4.1.1
./configure --with-command-group=nagcmd
make all                                    ##To Make the package
make install                      ##To install the complied package 
make install-init        ##To install init script in /etc/rc.d/init.d
make install-config                    ##To Generate the config files
make install-commandmode        ##To install the command mode enable
make install-webconf                ##To Generate the Web config file
using all above commands in sequence will installation  nagios

Step6:> Copy the Event handler directory and change its ownership

~]#cp -rvf contrib/eventhandlers/ /usr/local/nagios/libexec/
Change ownership of copied directory using below command
~]#chown -R nagios:nagcmd /usr/local/nagios/libexec/eventhandlers

Step7:> Create nagiosadmin user and Generate the password to Web Login

create nagiosadmin user and generate password of nagiosadmin using htpasswd command. nagiosadmin we will use to login the web console.
~]#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Step8:> Start the httpd and nagios services

use below given command to start the httpd and nagios services
~]#systemctl start httpd.service 
~]#systemctl start nagios.service
Check the services status
~]#systemctl status httpd.service 
~]#systemctl status nagios.service

Step9:> Allow 80 port to access the Nagios using remote machine

in RHEL7 / Centos 7 instead of iptables firewalld is introduced use firewalld to allow 80 port
~]#firewall-cmd --zone=public --add-port=80/tcp -permanent 
~]#firewall-cmd --reload

Step10:> Access the Nagios using web browser

open the browser and type http://IPADDRESS/nagios
Nagios credentials - Tech tutorials
nagios screen - Tech Tutorials
in above screen you can able to see the Nagios dashboard is showing errors, because we did not yet installed the nagios plugins. After Nagios Core Installation We must install plugins are else we will get above error.
Lets install nagios plugins..!!

Install Nagios plugins on Nagios Server

Nagios plugins will play main role to monitor the service. Its very easy to install the nagios plugins.
nagios plugins are locate yet /usr/local/nagios/libexec/
Download the plugins bundle
~]# wget http://www.nagios-plugins.org/download/nagios-2.0.3.tar.gz
extract the package
~]# tar -xzvf nagios-plugins-2.0.3.tar.gz
Change to directory to install plugins
cd nagios-plugins-2.0.3 
./configure --with-nagios-user=nagios --with-nagios-group=nagcmd 
make 
make install
After installing an nagios plugins just wait for five minutes and open the nagios web console and see.
Nagios Webconsole - Tech Tutorials
That’s it…!! your Nagios Core monitoring tool is installed successfully. Nagios Core Installation is Successfully Now you can Monitor Servers / Devices using Nagios Core.
Please provide your valuable comments..!!
referred from ARKIT.CO.IN

Linux Server Monitoring using SNMP (Simple Network Management Protocol) Nagios

If you would like to monitor servers agent less ultimately the best solution is SNMP (Simple Network Management Protocol). Agent less server monitoring using Nagios. In this Article we are going to see how to Linux server Monitoring Using SNMP Nagios.
Why you would like to go with an Agent less monitoring? because when your server is already in production but you don’t want to modify / Install extra packages in them. In this case simple method is enabling SNMP in client which send traps to Nagios server.

Linux Server Monitoring Using SNMP Nagios

Open SNMP communication from Linux client and monitor using Nagios. Let’s see what are steps we have to follow in order to configure.
Complete Step by step guide for SNMP Installation and configuration
[root@Arkit-Serv~]# vi /etc/snmp/snmpd.conf

rocommunity commstring NAGIOS-SERVER-IP

:wq
Just check from Nagios server that SNMP is responding properly, if you get output like below then its working fine.
./check_snmp -H 192.168.1.23 -o .1.3.6.1.2.1.1.3.0 -C commstring
SNMP OK - Timeticks: (60558317) 7 days, 0:13:03.17 |

Define Commands

define command {
 command_name check_service_snmp
 command_line $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
}
Now Define your Host and Service Definitions
###############################################################
# #
# ::: Host Defination ::: #
###############################################################

define host {
 host_name LinuxServer.arkit.co.in
 use generic_host
 address 192.168.1.2
 hostgroups linux-servers
 max_check_attempts 5
 check_interval 5
 retry_interval 1
 check_period 24x7
 contacts Linuxadmin
 contact_groups LinuxGroup
 notification_interval 0
 notification_period 24x7
 notifications_enabled 1
 }

###############################################################
# #
# ::: Service Defination ::: #
###############################################################
define service {
 host_name LinuxServer.arkit.co.in
 service_description / Disk Usage
 use Linuxsnmp_storage
 check_command check_service_snmp! -C commstring --v2c -m "^/$" -w 90 -c 95 -f
 max_check_attempts 5
 check_interval 10
 retry_interval 1
 check_period 24x7
 notification_interval 0
 notification_period 24x7
 contacts Linuxadmin
 contact_groups LinuxGroup
 }

define service {
 host_name LinuxServer.arkit.co.in
 service_description CPU Usage
 use linuxsnmp_load
 check_command check_service_snmp! -C commstring --v2c -w 90 -c 95 -f
 max_check_attempts 5
 check_interval 10
 retry_interval 1
 check_period 24x7
 notification_interval 0
 notification_period 24x7
 contacts Linuxadmin
 contact_groups LinuxGroup

}

define service {
 host_name LinuxServer.arkit.co.in
 service_description Memory Usage
 use Linuxsnmp_storage
 check_command check_service_snmp! -C commstring --v2c -m Physical -w 90 -c 95 -f
 max_check_attempts 5
 check_interval 10
 retry_interval 1
 check_period 24x7
 notification_interval 0
 notification_period 24x7
 contacts Linuxadmin
 contact_groups LinuxGroup

}

define service {
 host_name LinuxServer.arkit.co.in
 service_description Ping
 use genericnetdevice_ping_service
 check_command check-host-alive
 max_check_attempts 5
 check_interval 10
 retry_interval 1
 check_period 24x7
 notification_interval 0
 notification_period 24x7
 notifications_enabled 1
 contacts Linuxadmin
 contact_groups LinuxGroup

}

define service {
 host_name LinuxServer.arkit.co.in
 service_description Swap Usage
 use Linuxsnmp_storage
 check_command check_service_snmp! -C commstring --v2c -m 'Swap' -w 90 -c 95 -f
 max_check_attempts 5
 check_interval 10
 retry_interval 1
 check_period 24x7
 notification_interval 0
 notification_period 24x7
 contacts Linuxadmin
 contact_groups LinuxGroup

}
 That’s it Go and see in your Nagios web console you can see all specified service status.
Nagios Linux
Nagios Linux

Conclusion:

If you have Network latency / Network slowness then you will so many false positive alarms from Monitoring tool. If you use NRPE client which reduce little bit of false positive alerts. Nagios Server resource utilization will go high when you use SNMP. Linux server monitoring using snmp