Wednesday, August 3, 2011

How to Customize Centos DVD using Kickstart file

How to Customize Centos DVD using Kickstart file
================================================

Here i am using CentOS 64 Bit OS to customize that.

1. Create a kickstart file with postscript and packages list
# yum install system-config-kickstart
# system-config-kickstart
# save as ks.cfg

2. Mount that DVD into /mnt
# mount -o loop /dev/cdrom /mnt ( If it is in DVD )
# mount -o loop /opt/ISO/centos_5.5_64bit_final.iso /mnt ( It is an ISO File )

3. Create a Dir for ISO Editing
# mkdir /opt/newbuild

4. Copy all the contents from /mnt to /opt/newbuild
# cp -R /mnt/* /opt/newbuild

5. Edit the isolinux.cfg in newbuild Dir
# vim /opt/newbuild/isolinux/isolinux.cfg

default linux
prompt 0
timeout 600
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append initrd=initrd.img ks=cdrom:/ks.cfg ( Add this entry in this line )
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -

6. Modify the permission of ks.cfg file
# chmod 755 ks.cfg

7. Copy the ks.cfg file to newbuild Dir
# cp ks.cfg /opt/newbuild

8. Install mkisofs to make ISO
# yum install mkisofs

9. Make Customized ISO
# mkisofs -o CentOS-5.5_64_Kickstart.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T .

10. Now ISO is ready
Write the CentOS-5.5_64_Kickstart.iso file in DVD

How to configure NTP Server in Linux

How to configure NTP Server In Linux
=====================================

Configured NTP Server in 192.168.100.223 ( support.symbioticinfo.com )

#Server Side
============
NTP Server Pool Address
1.server 1.asia.pool.ntp.org
2.server 0.asia.pool.ntp.org

#Permitting local network to use this
restrict 192.168.100.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.10.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.20.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.30.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.40.0 mask 255.255.255.0 nomodify notrap

#full access to the local net
restrict 127.0.0.1

#Client Side
===========

#yum install ntp

edit the ntp.conf file
#vim /etc/ntp.conf

#comment the following lines
#server 0.centos.pool.ntp.org
#server 1.centos.pool.ntp.org
#server 2.centos.pool.ntp.org

#add the following lines
restrict default ignore
server 192.168.100.223
restrict 192.168.100.1 mask 255.255.255.255 nomodify notrap noquery

#save and quit the file.

#Before starting the ntp daemon, run the following command

#ntpdate -b 192.168.100.223

#service ntpd start

#check the ntp

[root@gw ~]# ntpq -pn
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.100.223 140.109.1.4 11 u 3 64 1 0.257 0.368 0.001
127.127.1.0 .LOCL. 10 l 2 64 1 0.000 0.000 0.001
[root@gw ~]#

#you will get output like this..

++++++++++++++++++++++++++++++++++++THATS ALL++++++++++++++++++++++++++++++++++

Monday, April 25, 2011

How_to_customize_centos_using_kickstart

How to Customize Centos DVD using Kickstart file
================================================

Here i am using CentOS 64 Bit OS to customize that.

1. Create a kickstart file with postscript and packages list
# yum install system-config-kickstart
# system-config-kickstart
# save as ks.cfg

2. Mount that DVD into /mnt
# mount -o loop /dev/cdrom /mnt ( If it is in DVD )
# mount -o loop /opt/ISO/centos_5.5_64bit_final.iso /mnt ( It is an ISO File )

3. Create a Dir for ISO Editing
# mkdir /opt/newbuild

4. Copy all the contents from /mnt to /opt/newbuild
# cp -R /mnt/* /opt/newbuild

5. Edit the isolinux.cfg in newbuild Dir
# vim /opt/newbuild/isolinux/isolinux.cfg

default linux
prompt 0
timeout 600
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append initrd=initrd.img ks=cdrom:/ks.cfg ( Add this entry in this line )
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -

6. Modify the permission of ks.cfg file
# chmod 755 ks.cfg

7. Copy the ks.cfg file to newbuild Dir
# cp ks.cfg /opt/newbuild

8. Install mkisofs to make ISO
# yum install mkisofs

9. Make Customized ISO
# mkisofs -o CentOS-5.5_64_Kickstart.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T .

10. Now ISO is ready
Write the CentOS-5.5_64_Kickstart.iso file in DVD

Friday, April 15, 2011

How to Install nagios grapher on nagios

#!/bin/bash
#Author Karthikeyan.S

#Any Failing Command Will Cause The Script To Stop
set -e

#Treat Unset Variables As Errors
set -u

test $(id -u) -eq 0 || { echo "You are not a root user to run this script " ; exit 1; }

rpm -qa | grep rpmforge
status=$?

if [ $status = 0 ]
then
echo "rpmforge repo is already installed"
else
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm ivh rpmforge-release-0.5.2-2.el5.rf.i386.rpm
fi

yum update

yum -y install autoconf rrdtool perl-GD* ImageMagick-perl perl-URI.noarch perl-Calendar*

if [ -d /opt/downloads ]
then
echo "/opt/downloads folder already exists"
else
mkdir /opt/downloads
fi

cd /opt/downloads
wget http://sourceforge.net/projects/nagiosgrapher/files/nagiosgrapher/NagiosGrapher-1.7.1/NagiosGrapher-1.7.1.tar.gz/download

tar -xvf NagiosGrapher-1.7.1.tar.gz
cd NagiosGrapher-1.7.1

autoconf
./configure --with-layout=default
make install

cat >> /usr/local/nagios/etc/nagios.cfg << EOF cfg_dir=/usr/local/nagios/etc/serviceext process_performance_data=1 service_perfdata_file=/usr/local/nagios/var/service-perfdata service_perfdata_file_template=$HOSTNAME$\t$SERVICEDESC$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\t$TIMET$ service_perfdata_file_mode=a service_perfdata_file_processing_interval=30 service_perfdata_file_processing_command=process-service-perfdata-file EOF cat >> /usr/local/nagios/etc/objects.commands.cfg << EOF
#NagiosGrapher commands
define command{
command_name process-service-perfdata-file
command_line mv /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/service-perfdata.$TIMET$
}
EOF

/etc/init.d/nagios restart
/usr/local/nagios/contrib/collect2.pl restart

echo "Nagios Grapher installation finished successfully..."

Saturday, February 5, 2011

Nagios Installation Script

#!/bin/bash
#Author Karthikeyan.s

#Any Failing Command Will Cause The Script To Stop
set -e

#Treat Unset Variables As Errors
set -u

test $(id -u) -eq 0 || ( echo "You are not a root user to run this script " ; exit 1; )


echo "IMPORTANT: KINDLY MAKE SURE THAT YOU HAVE DISABLED SELINUX AND IPTABLES ........"
echo "NAGIOS INSTALLATION IS GOING TO BE START WITHIN 10 SECONDS......................"
sleep 5
echo "Nagios installation started : " `date`

echo "Installing Pre-requisites"
yum -y install httpd php
yum -y install gcc glibc glibc-common
yum -y install gd gd-devel
yum -y install openssl-devel

echo "Creating nagios user and setting password "
/usr/sbin/useradd -m nagios
echo "nagios" | /usr/bin/passwd --stdin nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
echo " Creating downloads folder in /opt directory "

mkdir /opt/downloads
cd /opt/downloads/
echo "Downloading Nagios and Nagios plugins "
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
tar -xvf nagios-3.2.3.tar.gz
cd nagios-3.2.3
echo "configuring Nagios"
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
echo "Set htpasswd for nagios"
htpasswd -nb nagiosadmin nagios > /usr/local/nagios/etc/htpasswd.users
/sbin/service httpd restart
cd ../
tar -xvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
echo "nagios Plugins "
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
/sbin/chkconfig --add nagios
/sbin/chkconfig nagios on
echo "verifying nagios "
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/sbin/service nagios start

echo "Nagios Installation finished successfully..."

How to install ndoutils on centos

How to Install Ndoutils on nagios version 3 above
==================================================


Install Ndoutils pre-requists
-----------------------------

# yum -y install mysql mysql-server mysql-client gcc-c++ libdbi-dbd-mysql
# /etc/init.d/mysqld start
# /sbin/chkconfig mysqld on
# /usr/bin/mysqladmin -u root password your_password


Create database for nagios
---------------------------

# mysql -u root -pyourpassword
mysql> create database nagios;
mysql> grant all privileges on nagios.* to 'nagios'@'localhost' identified by “nagios” with grant option;
mysql> flush privileges;
mysql> quit

Download ndoutils
-----------------

# mkdir /opt/downloads
# cd /opt/downloads
# wget http://sourceforge.net/projects/nagios/files/ndoutils-1.x/ndoutils-1.4b9/ndoutils-1.4b9.tar.gz/download
# cd /opt/downloads/ndoutils-1.4b9

Installing ndoutils
--------------------

./configure --prefix=/usr/local/nagios/ --enable-mysql --disable-pgsql --with-ndo2db-user=nagios -with-ndo2db-group=nagcmd

make

Manual install ( NO MAKE INSTALL )

-----------------------------------
# db/installdb -u nagios -p nagios -h localhost -d nagios

# cp ./src/ndomod-3x.o /usr/local/nagios/bin/ndomod.o
# cp ./src/ndo2db-3x /usr/local/nagios/bin/ndo2db
# cp ./config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
# cp ./config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
# chmod 774 /usr/local/nagios/bin/ndo*
# chown nagios:nagios /usr/local/nagios/bin/ndo*

Install the init script
------------------------

# cp ./daemon-init /etc/init.d/ndo2db
# chmod +x /etc/init.d/ndo2db
# chkconfig -add ndo2db


Edit nagios.cfg and verify or add the following lines
------------------------------------------------------
# vim /usr/local/nagios/etc/nagios.cfg

event_broker_options=-1
broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg



Make necessary modifications in ndo2db.cfg file ( My Sample cfg file )
----------------------------------------------------------------------
# vim /usr/local/nagios/etc/ndo2db.cfg

lock_file=/usr/local/nagios/var/ndo2db.lock

ndo2db_user=nagios
ndo2db_group=nagios

socket_type=unix
#socket_type=tcp

socket_name=/usr/local/nagios/var/ndo.sock

tcp_port=5668

use_ssl=0

db_servertype=mysql

db_host=localhost

db_port=3306

db_port=3306

db_prefix=nagios_

db_user=nagios
db_pass=nagios

max_timedevents_age=1440

max_systemcommands_age=10080

max_servicechecks_age=10080

max_hostchecks_age=10080

max_eventhandlers_age=44640

max_externalcommands_age=44640

debug_level=0

debug_verbosity=1

debug_file=/usr/local/nagios/var/ndo2db.debug

max_debug_file_size=1000000


# vim /usr/local/nagios/etc/ndomod.cfg

instance_name=default

#output_type=tcpsocket
output_type=unixsocket

output=/usr/local/nagios/var/ndo.sock

tcp_port=5668

use_ssl=0

output_buffer_items=5000

buffer_file=/usr/local/nagios/var/ndomod.tmp

file_rotation_interval=14400

file_rotation_timeout=60

reconnect_interval=15

reconnect_warning_interval=15

data_processing_options=-1

config_output_options=2


Start the ndo2db init script and restart the nagios
----------------------------------------------------

# /etc/init.d/ndo2db start
# /etc/init.d/nagios restart



You will get the log report like this

# tail -f /usr/local/nagios/var/nagios.log


[1296905045] LOG VERSION: 2.0
[1296905045] ndomod: NDOMOD 1.4b9 (10-27-2009) Copyright (c) 2009 Nagios Core Development Team and Community Contributors
[1296905045] ndomod: Successfully connected to data sink. 0 queued items to flush.
[1296905045] Event broker module '/usr/local/nagios/bin/ndomod.o' initialized successfully.
[1296905045] Finished daemonizing... (New PID=7529)


#### Installation finished ####