Setting up
icinga monitoring server on centos 6.4 (2014-May-13)
#yum
install screen
1. Install
core pacakges needed by icinga
[root@zabbix
~]# yum install -y rsync vim wget curl git zip unzip mlocate make
#yum install httpd gcc glibc glibc-common gd gd-devel -y
#yum install libjpeg libjpeg-devel libpng libpng-devel -y
#yum install net-snmp net-snmp-devel net-snmp-utils -y
2.
Build a
download folder and get all the software from Icinga we will need.
[root@zabbix
~]# mkdir /opt/installs
[root@zabbix
~]# cd /opt/installs
This is the core package
This is web front end
Grab the nagios plugins
Get latest NRPE modules
[root@zabbix
installs]# ls
icinga-1.10.1.tar.gz nagios-plugins-2.0.1.tar.gz
icinga-web-1.10.0.tar.gz nrpe-2.15.tar.gz
Create user
named = icinga
[root@zabbix
installs]# passwd icinga
Changing
password for user icinga.
New
password: password123
Retype new
password: password123
passwd:
all authentication tokens updated successfully.
Check if
icinga group and icinga user are there by command # groups icinga
If not create icinga group and add icinga user to
that group
For sending commands to classic interface you will
need to :=
[root@zabbix
installs]# groupadd icinga-cmd
[root@zabbix
installs]# usermod -a -G icinga-cmd icinga
[root@zabbix
installs]# usermod -a -G icinga-cmd apache
Compile and install icinga
# tar xvf
icinga-1.10.1.tar.gz
# cd
icinga-1.10.1
#\ Run the configure script and make the install
# ./configure --with-command-group=icinga-cmd --disable-idoutils
#make all
#make fullinstall
# make install-config
Run again.
# make install-config
Customizing configuration
[root@zabbix objects]# cat /usr/local/icinga/etc/objects/contacts.cfg
# template which is defined elsewhere. define contact{ contact_name icingaadmin2 ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Sarose(Admin) ; Full name of user ; email icinga@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** ;added by urgen 5-13-2014 12:14pm email alerts@urgens.com ; <=put your email here } # CONTACT GROUPS # define contactgroup{ contactgroup_name admins alias Icinga Administrators members icingaadmin2 }
-------------------------------------------------------------------------------
Configure the classic web interface:
[root@zabbix icinga-1.10.1]# pwd
/opt/installs/icinga-1.10.1
#make cgis
# make install-cgis
# make install-html
Install
the Apache config:
Install
the Icinga Classic web config file in the Apache
conf.d directory (conf-available starting with Apache 2.4).
# make install-webconf
Create an icingaadmin account for logging into the Icinga classic web interface. If you want to change it later, use the same command. Remember the password you assign to this account - you'll need it later.
[root@zabbix icinga-1.10.1]# htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin
New password: ********
Re-type new password: ********
Adding password for user icingaadmin
If you want to change it later or add another user:
htpasswd
/usr/local/icinga/etc/htpasswd.users <USERNAME>
Now add apache to startup and restart apache
#chkconfig httpd on
#service httpd restart
Extract and configure nagios plugins
cd /opt/installs/
# tar -xvf nagios-plugins-2.0.1.tar.gz
# ./configure \
--prefix=/usr/local/icinga --with-cgiurl=/icinga/cgi-bin \
--with-nagios-user=icinga --with-nagios-group=icinga
#make
#make install
Configure NRPE plugin
#cd /opt/installs
#tar -xvf nrpe-2.15.tar.gz
#cd nrpe-2.15
# ./configure --with-ssl --with-nrpe-user=icinga
--with-nrpe-group=icinga --with-nagios-user=icinga --with-nagios-group=icinga
--libexecdir=/usr/local/icinga/libexec/ --bindir=/usr/local/icinga/bin/
#make all && make install
Add icinga core to start up
#chkconfig --add icinga
#chkconfig icinga on
Veryfy the config file
#/usr/local/icinga/bin/icinga -v
/usr/local/icinga/etc/icinga.cfg
Output should look like
Checking
for circular paths between hosts...
Checking
for circular host and service dependencies...
Checking
global event handlers...
Checking
obsessive compulsive processor commands...
Checking
misc settings...
Total Warnings: 0
Total Errors:
0
Things
look okay - No serious problems were detected during the pre-flight check
--OR---
[root@zabbix
nrpe-2.15]# /etc/init.d/icinga show-errors
Running
configuration check...OK
Adjusting the SELinux settings
RHEL and derived distributions like Fedora and CentOS are shipped with activated SELinux (Security Enhanced Linux) running in "enforcing" mode. This may lead to "Internal Server Error" messages when you try to invoke the Icinga-CGIs.Check if SELinux runs in enforcing mode
#> getenforce
Set SELinux in
"permissive" mode #> setenforce 0
To make this change
permanent you have to adjust this setting in /etc/selinux/config
and restart the system.Instead of deactivating SELinux or setting it into permissive mode you can use the following commands to run the CGIs in enforcing/targeted mode. The semanage command will automatically add entries to
/etc/selinux/targeted/contexts/files/file_contexts.local.semanage fcontext -a -t httpd_sys_script_exec_t '/usr/local/icinga/sbin(/.*)?' semanage fcontext -a -t httpd_sys_content_t '/usr/local/icinga/share(/.*)?' semanage fcontext -a -t httpd_sys_rw_content_t '/usr/local/icinga/var(/.*)?'Once you have defined the necessary contexts you have to apply the settings:
# restorecon -R /usr/local/icinga/sbin
# restorecon -R /usr/local/icinga/share
# restorecon -R /usr/local/icinga/var
Start ICINGA
[root@zabbix init.d]# /etc/init.d/icinga start
Running configuration check...OK
Starting icinga: Starting icinga done.
Login to classic web interface
# Open a browser
You are done with the Icinga-Core and Classic Web Interface,
** we are still at icinga server **
Adding hosts
In your main configuration file
which is usually /usr/local/icinga/etc/icinga.cfg you should add a line with
no spaces at the beginning:
cfg_file=/usr/local/icinga/etc/conf.d/hosts.cfg
|
Now,
[root@zabbix objects]# pwd
/usr/local/icinga/etc/objects
#vim /usr/local/icinga/etc/objects/hosts.cfg
# HOST DEFINITION ###################################
# HOST DEFINITION
# Define a host for the local machine
define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server-client host template definition.
host_name sonybiz
alias sonybiz
address 5.9.19.37
contact_groups admins
}
define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server-client host template definition.
host_name Edxorg
alias Edxorg
address 5.9.119.34
contact_groups admins
}
# HOST GROUP DEFINITION
# Define an optional hostgroup for Linux machines
define hostgroup{
hostgroup_name linux-server-clients ; The name of the hostgroup
alias linux-server-clients ; Long name of the group
members sonybiz,Edxorg ; Comma separated list of hosts that belong to this group
}
# SERVICE DEFINITIONS
# Define a service to "ping" the local machine
define service{
use generic-service ; Name of service template to use
; host_name sonybiz < =uncomment it if you have host without group
hostgroup_name linux-server-clients
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
#This means that a warning is sent if the latency(RTA) is >100ms or 20% packet loss. An error will be sent if latency is >500ms of 60% packet loss.you could increase the latency (RTA) warning to 150ms to get less messages.
# Define a service to check the disk space of the root partition
# on the local machine. Warning if < 20% free, critical if
# < 10% free space on partition.
define service{
use generic-service ; Name of service template to use
; host_name Mantraideas <=use this if you have host without group
hostgroup_name linux-server-clients
service_description Root Partition
check_command check_local_disk!20%!10%!/
}
# Define a service to check the number of currently logged in
# users on the local machine. Warning if > 20 users, critical
# if > 50 users.
# Define a service to check the load on the local machine.
define service{
use generic-service ; Name of service template to use
; host_name machine12
hostgroup_name linux-server-clients
service_description Current Load
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}
# Define a service to check the swap usage the local machine.
# Critical if less than 10% of swap is free, warning if less than 20% is free
define service{
use generic-service ; Name of service template to use
; host_name localhost
hostgroup_name linux-server-clients
service_description Swap Usage
check_command check_local_swap!20!10
}
# Define a service to check HTTP on the local machine.
# Disable notifications for this service by default, as not all users may have HTTP enabled.
define service{
use generic-service ; Name of service template to use
; host_name localhost
hostgroup_name linux-server-clients
service_description HTTP
check_command check_http
notifications_enabled 1
}
###Check your config file if it is correct or not ####
/usr/local/icinga/bin/icinga -v /usr/local/icinga/etc/icinga.cfg
At Client Side
Do
install below packages necessary:-
nagios-plugins-mailq
nagios-plugins-disk
nagios-plugins-load
nagios-plugins-procs
nagios-plugins-nrpe #for check_nrpe on localside
For Ubuntu
$ sudo apt-get install nagios-nrpe-server nagios-plugins
/etc/init.d/nagios-nrpe-server restart
edit /etc/nagios/nrpe.cfg and make changes like
allowed_hosts=127.0.0.1, 192.168.1.100
command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10 command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1 command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200
command[check_mailq]=/usr/lib/nagios/plugins/check_mailq -w 300 -c 600
/etc/init.d/nagios-nrpe-server restart
For Centos
#yum install nagios-nrpe -y
# vim /etc/nagios/nrpe.cfg
;;add below line
allowed_hosts=199.50.155.195 <=this is your icinga server ip
dont_blame_nrpe=0 ;;check this
save-exit
#service nrpe start
#chkconfig nrpe on
Allow port 5666
# iptables -I INPUT -p tcp -m tcp --dport 5666 -j ACCEPT
# service iptables save
ICINGA HTTP WARNING: HTTP/1.1 403 Forbidden ERROR
#touch /var/www/html/index.php
#/etc/init.d/icinga restart
That’s it !!
alias icistat='/usr/local/icinga/bin/icinga -v /usr/local/icinga/etc/icinga.cfg'
========================================================================
check mailq EXIM
========================================================================
At client side:-
#rpm -qf utils.pm //tofind the package name of file
#yum install nagios-plugins-perl
do this if you face the"utils.sh not found error". make dir's as needed
#ln -s /usr/lib64/nagios/plugins/utils.sh /usr/local/nagios/libexec/utils.sh
OR
make changes in exim mailq script , change the line
. /usr/local/nagios/libexec/utils.sh to ->
/usr/lib64/nagios/plugins/utils.sh
OR
make changes in exim mailq script , change the line
. /usr/local/nagios/libexec/utils.sh to ->
/usr/lib64/nagios/plugins/utils.sh
#visudo
Comment out
#Defaults requiretty <<<++= =
#add nrpe user like below line
root ALL=(ALL) ALL
nrpe ALL=NOPASSWD:/usr/sbin/exim
Save/exit
***************************************
copybelow script in file name "check_eximmailqueue"
#ls -l /usr/lib64/nagios/plugins/check_eximmailqueue
-rwxr-xr-x 1 root root 3285 Jul 27 06:25 check_eximmailqueue*
-rwxr-xr-x 1 root root 172880 Oct 17 2013 check_http*
-rwxr-xr-x 1 root root 40944 Oct 17 2013 check_load*
-rwxr-xr-x 1 root root 22256 Apr 30 21:28 check_nrpe*
-rwxr-xr-x 1 root root 36080 Oct 17 2013 check_users*
-rwxr-xr-x 1 root root 38696 Oct 17 2013 negate*
-rwxr-xr-x 1 root root 36104 Oct 17 2013 urlize*
-rw-r--r-- 1 root root 2091 Oct 17 2013 utils.pm
-rwxr-xr-x 1 root root 2728 Oct 17 2013 utils.sh*
-rwxr-xr-x 1 root root 172880 Oct 17 2013 check_http*
-rwxr-xr-x 1 root root 40944 Oct 17 2013 check_load*
-rwxr-xr-x 1 root root 22256 Apr 30 21:28 check_nrpe*
-rwxr-xr-x 1 root root 36080 Oct 17 2013 check_users*
-rwxr-xr-x 1 root root 38696 Oct 17 2013 negate*
-rwxr-xr-x 1 root root 36104 Oct 17 2013 urlize*
-rw-r--r-- 1 root root 2091 Oct 17 2013 utils.pm
-rwxr-xr-x 1 root root 2728 Oct 17 2013 utils.sh*
cat /usr/lib64/nagios/plugins/check_eximmailqueue
#!/bin/sh
################################################
# Nagios script to check Exim mail queue status
#
# Copyright 2007, 2008 Ian Yates
#
# NOTE: Depending on your config, the nagios user will probably be
# needed to be added to the exim group for this script to function correctly
#
# See usage for command line switches
#
. /usr/local/nagios/libexec/utils.sh
VERSION="1.3"
EXIM=$(which exim)
SUDO=/usr/bin/sudo
FLAG_VERBOSE=FALSE
LEVEL_WARN=""
LEVEL_CRIT=""
RESULT=""
EXIT_STATUS=$STATE_OK
###############################################
#
## FUNCTIONS
#
## Print usage
usage() {
echo " check_eximailqueue $VERSION - Nagios Exim mail queue check script"
echo ""
echo " Usage: check_eximailqueue -w <warning queue size> -c <critical queue size> [ -v ] [ -h ]"
echo ""
echo " -w Queue size at which a warning is triggered"
echo " -c Queue size at which a critical is triggered"
echo " -v Verbose output (ignored for now)"
echo " -h Show this page"
echo ""
}
## Process command line options
doopts() {
if ( `test 0 -lt $#` )
then
while getopts w:c:vh myarg "$@"
do
case $myarg in
h|\?)
usage
exit;;
w)
LEVEL_WARN=$OPTARG;;
c)
LEVEL_CRIT=$OPTARG;;
v)
FLAG_VERBOSE=TRUE;;
*) # Default
usage
exit;;
esac
done
else
usage
exit
fi
}
# Write output and return result
theend() {
echo $RESULT
exit $EXIT_STATUS
}
#
## END FUNCTIONS
#
#############################################
#
## MAIN
#
# Handle command line options
doopts $@
# Do the do
OUTPUT=`$SUDO -u root $EXIM -bpc`
if test -z "$OUTPUT" ; then
RESULT="Mailqueue WARNING - query returned no output!"
EXIT_STATUS=$STATE_WARNING
else
if test "$OUTPUT" -lt "$LEVEL_WARN" ; then
RESULT="Mailqueue OK - $OUTPUT messages on queue"
EXIT_STATUS=$STATE_OK
else
if test "$OUTPUT" -ge "$LEVEL_CRIT" ; then
RESULT="Mailqueue CRITICAL - $OUTPUT messages on queue"
EXIT_STATUS=$STATE_CRITICAL
else
if test "$OUTPUT" -ge "$LEVEL_WARN" ; then
RESULT="Mailqueue WARNING - $OUTPUT messages on queue"
EXIT_STATUS=$STATE_WARNING
fi
fi
fi
fi
# Quit and return information and exit status
theend
vim /etc/nagios/nrpe.cfg
#add below command
command[check_eximmailqueue]=/usr/lib64/nagios/plugins/check_eximmailqueue -w 200 -c 300
@@@@@@@@@@@@@@@
Server side check
[root@zabbix libexec]# ./check_nrpe -H nepalhpf.org.np -c check_eximmailqueue
Mailqueue OK - 2 messages on queue [root@zabbix ~]# cd /usr/local/icinga/etc/objects/
#vim commands.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
#vim nrpe-clients.cfg
define service{
use generic-service
#host_name weblink3
hostgroup_name mailq
service_description Check Mail Queue
check_command check_nrpe!check_eximmailqueue
}
restart icinga..
========================================================
ZOMBIE Processess check
= = = = = = = = = = = = = = = = =
#client side
yum install nagios-plugins-procscheck/add the below line in /etc/nagios/nrpe.cfg
command[check_zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -s Z
#monitoring server side
[root@zabbix ~]# cd /usr/local/icinga/etc/objects/
#vim commands.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
# vim nrpe-clients.cfg
define host{
use linux-server
host_name nepalhpf
alias nepalhpf.org.np
address nepalhpf.org.np
}
define service{
use generic-service
host_name nepalhpf
service_description Zombieprocs
check_command check_nrpe!check_zombie_procs
}
LSYNCD process check with icinga
= = = = = = = = = = = = = = = = = = = = = = = = = =
@Client
#yum install -y nagios-plugins-procs vim /etc/nagios/nrpe.cfg
add ..
command[check_lsyncd]=/usr/lib64/nagios/plugins/check_procs -c 1:5 -C lsyncd
root@ns14 [/etc/nagios]# ls -l /usr/lib64/nagios/plugins/
total 204
drwxrwxr-x. 2 root root 4096 Jul 10 19:16 ./
drwxr-xr-x. 3 root root 4096 Jul 4 21:53 ../
-rwxr-xr-x. 1 root root 118736 Oct 17 2013 check_procs* This file should exist or yum install nagios-plugins (add epel repository)
-rwxr-xr-x. 1 root root 38696 Oct 17 2013 negate*
-rwxr-xr-x. 1 root root 36104 Oct 17 2013 urlize*
-rwxr-xr-x. 1 root root 2728 Oct 17 2013 utils.sh*
# /usr/lib64/nagios/plugins/check_procs -c 1:5 -C lsyncd #testing locally
PROCS OK: 1 process with command name 'lsyncd'
@Icinga Server
vim /usr/local/icinga/etc/objects/nrpe-client-objects.cfg
define hostgroup{
hostgroup_name lsyncserver; The name of the hostgroup
alias Lsyncd_Check
members web01,ns14
}
define service{
use generic-service
hostgroup_name lsyncserver
service_description Lsyncd Process Check
check_command check_nrpe!check_lsyncd
}
==== = = = = == = = == =
@client
/usr/local/nagios/libexec/check_procs -c 1:30 -C nginx
wherein:
-c 1:30 <– refers to the Critical range for number of
Nginx processes. If there process count is below 1 and above 30 this
will send me a Critical notice. If you wan to add a Warning level you
can use " -w 1:25 " - adjust the number of processes for you needs.
-C nginx <– this will check for the command name (nginx)another example : -
check_procs -c 1:1 -a /usr/local/bin/mysecurebackupserver
http://linuxsysadminblog.com/2009/02/nagios-how-to-check-if-remote-process-is-running/
@server
define service {
use generic-service ; Name of service template to use
host_name HOST/IPADDRESS
service_description CHECK_NGINX
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 3
contact_groups Admins
notification_interval 480
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_nginx
notifications_enabled 1
}
= = = = = = = = = = = = = = = = =
checking from command line on server
./check_http -H 5.9.240.236 -c check_load
http://198.50.155.195/icinga/
icingaadmin
1Lumbini2#
http://kedar.nitty-witty.com/blog/10-steps-mysql-monitoring-nagios-installation-configuration
https://wiki.icinga.org/display/howtos/Service+Monitoring
No comments:
Post a Comment