setup icinga monitoring server and client complete (basic swap ,load,disk ,http service monitor)


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

#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*


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-procs

check/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

Setup Nagios Server and Client

Scenario
In this tutorial i am going to use two systems as mentioned below.

Nagios server:

Operating system : CentOS 6.5 minimal installation
IP Address       : 192.168.1.101/24

Nagios client:

Operating System : Ubuntu 13.04
IP Address       : 192.168.1.100/24
Prerequisites
Before installing Nagios, make sure that you’ve a properly installed and configured LAMP stack in your server. To install and configure LAMP server, refer any one of the following links.
Also install the following prerequisites too. All commands should be run as root user.
# yum install gd gd-devel gcc glibc glibc-common
Install Nagios

I tested this how-to on CentOS 6.5 minimal server, although it should work on all RHEL 6.x and its clones like CentOS 6.x and Scientific Linux 6.x.
Nagios will not be found in CentOS official repositories, so let us add the EPEL repository to install nagios. To add and enable EPEL repository :
First go to the EPEL repository download page. Download the latest EPEL rpm and install it as shown below.

For x86
# wget http://epel.mirror.net.in/epel/6/i386/epel-release-6-8.noarch.rpm
 
For x64
#wget http://epel.mirror.net.in/epel/6/x86_64/epel-release-6-8.noarch.rpm 
 # rpm -Uvh epel-release-6-8.noarch.rpm
Adding EPEL Repository to RHEL / CentOS / Scientific Linux 5.x
First go to the EPEL repository download page. Download the latest EPEL rpm and install it as shown below.
# wget http://epel.mirror.net.in/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -Uvh epel-release-5-4.noarch.rpm
Now list out the installed repositories using command:
# yum repolist


Next install nagios with all plug-ins and nagios agents(nrpe-agent) using command:
# yum install nagios*
Note: It worked for me either if i keep SELINUX and iptables enable or disable. All you need to do is allow the apache port through iptables as shown below.
# vi /etc/sysconfig/iptables
Add the following line:
[...]
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
[...]
Save and close the file. Restart iptables.
# service iptables restart
Configure Nagios
Add the admin mail address in the nagios contact file to receive alerts from nagios server. To do that edit file /etc/nagios/objects/contacts.cfg,
# vi /etc/nagios/objects/contacts.cfg
Find the following line and enter the email id:
[...]
email                           sk@unixmen.com ;
[...
Save and close the file. Then Edit file /etc/httpd/conf.d/nagios.conf,
# vi /etc/httpd/conf.d/nagios.conf
And edit the following lines if you want to access nagios administrative console from a particular IP series. Here i want to allow nagios administrative access from 192.168.1.0/24 series only.
[...]
## Comment Lines 15 & 16 ##
#   Order allow,deny
#   Allow from all

## Uncomment and Change lines 17,18 & 19 as shown below ##
Order deny,allow
Deny from all
Allow from 127.0.0.1 192.168.1.0/24
[...]
Set nagiosadmin password
# htpasswd /etc/nagios/passwd nagiosadmin
New password:
Re-type new password:
Updating password for user nagiosadmin
Start nagios and httpd services and let them to start automatically on every boot.
# service nagios start
# service httpd start
# chkconfig nagios on
# chkconfig httpd on
Access Nagios admin console
Open nagios administrator console with URL http://nagios-server-ip/nagios and enter the username as nagiosadmin and its password which we created in the earlier steps.

Add Monitoring targets to Nagios server
Now let us add some clients to monitor by Nagios server. To do that we have to install nrpe and nagios-plugins in our monitoring targets.
On CentOS/RHEL/Scientifc Linux clients:
Like i said before, you have to add EPEL repository in your CentOS/RHEL/Scientific Linux 6.x clients to install nrpe package.
Install “nrpe” and “nagios-plugins” packages in client systems to be monitored.
# yum install nrpe nagios-plugins-all openssl
On Debian/Ubuntu clients:
$ sudo apt-get install nagios-nrpe-server nagios-plugins
Configure Monitoring targets
Edit /etc/nagios/nrpe.cfg file,
# vi /etc/nagios/nrpe.cfg
Add your Nagios server ip address
[...]
## Line 81 - Add the Nagios server IP ##
allowed_hosts=127.0.0.1 192.168.1.101
[...]
## line around 215 add some plugin like mailq posfix
command[check_mailq]=/usr/lib/nagios/plugins/check_postfix_queue -w 300 -c 1000
Start nrpe service:
# service nrpe start
# chkconfig nrpe on
For Debian/Ubuntu Clients, start nrpe service as shown below.
$ sudo /etc/init.d/nagios-nrpe-server restart
Now go back to your Nagios server to add the clients to be monitored through nagios server. Edit “/etc/nagios/nagios.cfg” file,
# vi /etc/nagios/nagios.cfg
and uncomment the following lines.
## Line 52 - Uncomment ##
cfg_dir=/etc/nagios/servers
Create a directory called “servers” under “/etc/nagios/”.
# mkdir /etc/nagios/servers
Create config file to the client to be monitored:
# vi /etc/nagios/servers/clients.cfg
define host{

use                             linux-server

host_name                       client

alias                           client

address                         192.168.1.100  ## Client IP ##

max_check_attempts              5

check_period                    24x7

notification_interval           30

notification_period             24x7

}
Finally restart nagios service.
# service nagios restart
Now open the nagios admin console in the browser and navigate to “Hosts” section in the left pane. You will see the newly added client will be visible there. Click on the host to see if there is anything wrong or alerts.


Like this way, you can define more clients by creating a separate config files “/etc/nagios/servers directory for each client.
Define services
We did define the monitoring host before. Now let us add some services of the monitoring host. For example to monitor the ssh service, add the following lines shown in red colour in the /etc/nagios/servers/clients.cfg file.
# vi /etc/nagios/servers/clients.cfg
define host{

use                             linux-server

host_name                       client

alias                           client

address                         192.168.1.100  ## Client IP ##

max_check_attempts              5

check_period                    24x7

notification_interval           30

notification_period             24x7

}

define service {
        use                             generic-service
        host_name                       client
        service_description             SSH
        check_command                   check_ssh
        notifications_enabled           0
        }
Save and close the file. Restart Nagios.
# service nagios restart
Now log in to Nagios web console and check for the added services. Navigate to Services section, you’ll see the ssh service there.
Nagios Core - Mozilla Firefox_008To know more about object definitions such as Host definitions, service definitions, contact definitions and more please do visit here. This page will describe you the description and format of all object definitions.
That’s all about now. Good Luck! Stay healthy!


cut command CUT command

Select specific field 
 
$ cut -d':' -f1 /etc/passwd                                             #f1=field1 #d=delimiter
 
Multiple feilds 
 
history
 | awk '{$1=$1;print}' | cut -d' ' -f2-       #remove beginning spaces 
and history number , cut -f2- will start printing from 2nd field to last
 
history | awk '{$1=$1;print}' | cut -d' ' -f1-4     # cut -f1-4 will print from field 1 to 4 
$ grep "/bin/bash" /etc/passwd | cut -d':' -f1,6
root:/root
bala:/home/bala
 
Multiple feilds with defined range
 
$ grep "/bin/bash" /etc/passwd | cut -d':' -f1-4,6,7
 
root:x:0:0:/root:/bin/bash
bala:x:1000:1000:/home/bala:/bin/bash 
 
Example: Usage
 
[root@mx2 ~]# cat rbllist 
server=cbl.abuseat.org
server=spamtrap.drbl.drand.net
server=spamguard.leadmon.net
server=ix.dnsbl.manitu.net
server=relays.nether.net
server=rbl.orbitrbl.com
[root@mx2 postfix]# cat rbllist | cut -d'=' -f2 | while read line; do echo $line, ; done
 
cbl.abuseat.org,
spamtrap.drbl.drand.net,
spamguard.leadmon.net,
ix.dnsbl.manitu.net,
relays.nether.net,
rbl.orbitrbl.com,

PAC (Perl Auto Connector) for Debian Linux , by David Torrejon Vaquerizas

download PAC Manager fromhttp://sourceforge.net/projects/pacmanager/
which is a debian package

Now install the pac.X.deb file from Ubuntu Software (Center GUI) or from terminal like below :-
 
#sudo dpkg -i pac-4.5.4-all.deb
 
this step is optional
# apt-get install libgtk2-appindicator-perl


du

$ du -c
This gives you a grand total as the last line of the output. eg. 

[root@mx2 MailScanner]# du -ch
... .....
116K    ./reports/cz
116K    ./reports/cy+en
1.8M    ./reports
16K    ./mcp
8.0K    ./conf.d
2.3M    .
2.3M    total


 $du -sh
Gives you directory size  eg. MailScanner is directory
[root@mx2 etc]# du -sh MailScanner
2.3M    MailScanner


[root@mx2 ~]# du -sh *
4.0K    Mail
5.9M    MailScanner-4.84.6-1
5.7M    MailScanner-4.84.6-1.rpm.tar.gz
3.3M    rpmbuild
412K    sent
100K    stuff
22M    webmin-1.680-1.noarch.rpm