Tuesday 22 July 2014

swap partition with lvm in linux rhel6.5

#df -hT (for checking partions in linux)

then you need to check swap is created or not

#free -m

it will shows the swap size example output is below

[root@mudskipper ~]# free -m
                    total       used       free     shared    buffers     cached
Mem:          7685       4981       2703          0        189        547
-/+ buffers/cache:       4244       3440
Swap:            0             0             0

here Swap is mentioned zero

then you need to create partition lvm and add to swap

#lvcreate -L 16GB -n swap LVNAME

16GB is the swap size

# mkswap /dev/mapper/LVNAME-swap

then you need to enter the entry in fstab for permanent mount

#vi /etc/fstab

/dev/mapper/LVNAME-swap swap     swap    defaults        0 0

:wq (for saving the file)

check the swap is created or not

#free -m

                     total       used       free     shared    buffers     cached
Mem:          7685       4981       2703          0        189        547
-/+ buffers/cache:       4244       3440
Swap:        16383          0      16383

that's it your swap partition is created

nrpe installtion with simple script in linux rhel6.5

##create a directory in home as nrpe

http://www.mediafire.com/download/3jbwx9w9ww97uvo/nagios.rar
##place the attached files in this directory, if you dont have the ftp directory

#vi nagiosscript.sh

useradd nagios
if [ $? -eq 0 ]; then
cd /home/nrpe
lftp -u anonymous, 192.168.68.203 -e "cd pub; mirror -r . . ;bye"
tar -xvzf nrpe-2.12.tar.gz
tar -xvzf nagios-plugins-1.4.15.tar.gz
cd /home/nrpe/nagios-plugins-1.4.15
./configure
make
make install
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec
cd /home/nrpe/nrpe-2.12
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
cp /home/nrpe/nrpe /etc/xinetd.d/
chmod 755 /home/nrpe/check_mem.pl
cp /home/nrpe/check_mem.pl /usr/local/nagios/libexec/
echo "nrpe              5666/tcp                 # NRPE"  >> /etc/services
echo "command[check_mem]=/usr/local/nagios/libexec/check_mem.pl -w 20 -c 10 -f -C" >> /usr/local/nagios/etc/nrpe.cfg
echo "command[check_disk]=/usr/local/nagios/libexec/check_disk -w 5% -c 10% -p /dev/mapper/LVNAME-app /dev/mapper/LVNAME-var" >> /usr/local/nagios/etc/nrpe.cfg
service xinetd restart
cd /usr/local/nagios/libexec/
./check_http -H www.google.com
else
echo "Nagios User Already Exist. Please check"
fi

---------------------------

save :wq

#chmod 755 nagiosscript.sh

#sh nagiosscript.sh

Done