Thursday, April 18, 2013

AIX5.3/6.1 NRPE install- pre-compiled

Monitoring AIX with Nagios


This document describes how to monitor AIX servers using Nagios.


These instructions cover how to install and use pre-compiled binaries to monitor AIX 5.3 using NRPE.

Download Pre-Compiled Binaries

You will need to download two packages of pre-compiled binaries to your AIX server.
First download the pre-compiled Nagios plugin binaries for AIX 5.3 from the following URL:
cd /tmp
Next download the pre-compiled NRPE binaries from the above URL as well:

Create Directories

Login to your AIX server as the root user and run the following commands:
cd /usr/local
mkdir nagios
cd /var
mkdir run
cd run
And now change owner to nagios as
chown –R nagios.nagios ../run

Unpack Binaries

Next unpack the pre-compiled plugins and place the extracted files into the /usr/local/nagios directory using commands similar to the following:
cd /tmp
gunzip < aix53_nrpe-nsca-plugins.tgz | tar xvf –
cd /tmp/nagios
cp -R * /usr/local/nagios
Next, unpack the prec-ompiled NRPE binaries using commands similar to the following:
cd /tmp
gunzip < AIX-5.3-nrpe-2.12-binaries.tar.gz | tar xvf -
cp usr/local/nagios/bin/nrpe /usr/local/nagios/bin
cp usr/local/nagios/etc/nrpe.cfg /usr/local/nagios/etc

Create Nagios User and Group

Next, create a Nagios user and group on the AIX server.
Use the following command to create a new group:
mkgroup nagios
Make a home directory for a Nagios user using the following command:
cd /users/
mkdir nagios
Next, open up smitty and add a group and new user with the name
users and nagios. Launch smitty with the following command:
smitty group
                Group Name = users                                                 

smitty user
Once smitty openes, select Add a user, and use the
following settings:
• User NAME = nagios
• Primary Group = users
• Group SET = users,nagios
• HOME directory = /users/nagios

Set Permissions

Change folder permissions so NRPE will operate properly, with the following command:
chown -R nagios.nagios /usr/local/nagios
Verify the permissions on the directory using the following commands:
cd /usr/local/nagios
ls –l to check the permission

Specify NRPE Port Number

Next, edit the /etc/services file to add a port number for NRPE.
To edit the file, use the following command:
vi /etc/services
Add a line to the file that looks exactly like this:
nrpe 5666/tcp #nrpe
Save the file.

Edit the nrpe.conf

Comment the following line as shown below:
comment #server_address=
 #allowed_hosts= in nrpe.conf

Configure NRPE for Automatic Startup

Next, configure NRPE to automatically start when the AIX server reboots. To do this, use the following command:
nohup /usr/local/nagios/bin/nrpe -n -c /usr/local/nagios/etc/nrpe.cfg –d
You should get this reponse:
Sending nohup output to nohup.out.
Note: The -n flag specifies that the NRPE server should run without SSL support. This reduces security of the NRPE daemon, but dramatically increases performance under heavy server load and may be okay if your server is on an internal network protected by a firewall.

Start NRPE

Start NRPE using the following command:
/usr/local/nagios/bin/nrpe -n -c /usr/local/nagios/etc/nrpe.cfg –d

Test Your NRPE Configuration

Test your AIX server to see if NRPE is running properly. To do this, use the following command:
ps -ef | grep nrpe
You should see something that looks like this:
nagios 111345 43675 /usr/local/nagios/bin/nrpe –c /usr/local/nagios/etc/nrpe.cfg -n –d
Note: The output you see may differ slightly, as the PID number will be different on your system.
Important: If you don't see any output when running the above command, it means something is wrong with your setup! This may be related to problems in your NRPE configuration file (/usr/local/nagios/etc/nrpe.cfg).

Monday, April 1, 2013

Nagios service dependency configuration generator script

#Date : 1st April 2012
#Purpose : Nagios service dependency configuration generator script
#Authors : Babu Dhinakaran S and Ranjith Kumar R

`grep host_name /usr/local/nagios/var/status.dat | cut -d= -f2 | sort | uniq > /tmp/servers`

while read line
`grep -A1 -B0 $line /usr/local/nagios/var/status.dat | grep service_description | cut -d= -f2 | sort | uniq > /tmp/tempvariable`
count=`wc -l < /tmp/tempvariable`
if [ $count -le 1 ]
check=`cat /tmp/tempvariable`
if [ "$check" == "PingCheck" ] || [ "$check" == ""  ]
echo $line

        while read line2
                if [ "$line2" != "PingCheck" ]
                temp=`echo $temp,$line2`
        done < /tmp/tempvariable

# remove the comma
temp=$(echo $temp | cut -c 2-)

`echo "define servicedependency{
        host_name                       $line
        service_description             PingCheck
        dependent_host_name             $line
        dependent_service_description   $temp
        execution_failure_criteria      n
        notification_failure_criteria   u,c
       }" >> /tmp/ibsserdepdefinition.txt`

done < /tmp/servers