Saturday, February 5, 2011
Nagios Installation Script
#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
==================================================
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 ####
Thursday, November 5, 2009
How to install Google Desktop And Gadgets in Ubuntu
========================================================
Now the Google applications coming to the Linux Desktop.Follow up the steps to configure that in your system.
Set the Repository
-------------------
Add the following line in /etc/apt/source.list or through graphical system-->administration--> software sources and manually add the line
deb http://dl.google.com/linux/deb stable non-free
Add Google signing key. you can do the same in graphically also.
wget -c https://dl-ssl.google.com/linux/linux_signing_key.pub
If you are getting any error while making signing key refer the following doc.
Verify this URL to Add google signing key through Graphically.
http://www.google.com/linuxrepositories/ubuntu704.html
Installing Google desktop
-------------------------
$sudo aptitude update
$sudo aptitude install google-desktop-linux picasa
You can use your grphical package installer to install the other google applications.
Applications-->Ubuntu software center.
Search google then install whatever you want in google applications.
How to install Google Gadgets in Ubuntu 9.10
=============================================
Search the Google Applications in Repository.search your repo for Google Gadgets
$ apt-cache search google-gadgets
google-gadgets-common - Common files for QT and GTK+ versions of google-gadgets
google-gadgets-gst - GStreamer Module for Google Gadgets
google-gadgets-gtk - GTK+ Version of Google Gadgets
google-gadgets-qt - QT4 version of Google Gadgets
google-gadgets-xul - XULRunner module for Google Gadgets
$ sudo apt-get install google-gadgets*
Now you Have installed google desktop and gadgets in your ubuntu 9.10.
Thats All.
How to configure linux machine as Router
I have given very simple steps to configure Linux Machine as router. Here we aregoing to use NAT option in firewall to make that.
1.Two lan cards.
eth0 - Connected with internet ( Public )
eth1 - Local Area Network ( Private )
2. Enable ipv4 packet forwarding ( run as a administrator or user with sudo power )
#echo "1" /proc/sys/net/ipv4/ip_forward
or
edit /etc/sysctl.conf and change 0 to 1 in net.ipv4.ip_forward
After that ran sysctl -p command to save that
#sysctl -p
3.Enable Iptables to handle NAT.
$/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
4.Save the Iptables rule
$/sbin/service iptables save
5.Check the iptable rule
$/sbin/iptables -t nat --list
Thats all.
Monday, October 5, 2009
How to install Denyhosts in linux
How to install Denyhosts in linux
==================================
1.Download denyhosts from http://sourceforge.net/projects/denyhosts/files/
2.Pre-requisite
*Python 2.4 or Above
3.Check the SSH tcp_wrappers
*Login as a root user and edit the follwing file
*vim /ets/hosts.deny
*add the following line
*sshd: 127.0.0.1
*Save the file
*Attempt to connect to the local sshd server
*$ssh localhost
*You should see the follwing ssh error message:
*ssh_exchange_identification: Connection closed by remote host
*If the above error message was displayed , Then sshd has been compiled with tcp_wrappers
*If your clients to the sshe server, then your sshd has not been compiled with tcp_wrappers
*edit the file /etc/hosts.deny
*Remove the line that you added earlier (eg. sshd: 127.0.0.1 )
*Save the file
4. Extract the Denyhosts tar file
*tar -xvf DenyHosts-2.6.tar.gz
*mv DenyHosts-2.6 /usr/local/src/Denyhosts
*cd /usr/local/src/Denyhosts
*python setup.py install
5.Copy the sample cfg file
*cp /usr/share/denyhosts/denyhosts.cfg-dist /usr/share/denyhosts/denyhosts.cfg
6.Make denyhost as a daemon
*cp /usr/share/denyhosts/daemon-control-dist /etc/init.d/denyhosts
*cp /etc/init.d/denyhosts /etc/rc3.d/S99denyhosts
*cp /etc/init.d/denyhosts /etc/rc5.d/S99denyhosts
*/etc/init.d/denyhosts start
7.Configure denyhosts.cfg as you want
*vim /usr/share/denyhosts/denyhosts.cfg
Tuesday, September 29, 2009
How To Setup PXE Boot in Linux
How to Setup PXE boot in linux
====================================
This document how to set up pxe boot in linux. This assumes that you are using RHEL 5.2 or Centos5.2
0) Following packages need to be installed for PXE
*tftp-server
*dhcpd
*syslinux
*nfs
#yum install tftp-server dhcp syslinux
1) Before configuring PXE you should configure your locat mini network through dhcp ( Lot of doc available to configure dhcp )
2) Activate tftp in xinetd. changed disable=yes to disable=no in /etc/xinetd.d/tftp file. Then restart xinetd daemon.
3) Now we need to setup the pxe environment. You should have linux in cd format.On the first CD or in DVD you can find a folder 'isolinux'.In that dir you will find two files vmlinuz and initrd.img. These are the kernel & initrd.img that the RH/FC bootable CDs use to get the installer (anaconda) booted for performing the installation . Copy both of those files into /tftpboot and make sure that they are world readable .
Next, you need the actual pxe boot linux kernel (what is actually run immediately after your PXE boot client box gets a DHCP lease). In this case, that file is pxelinux.0, and is part of the syslinux RPM. you can find it at "/usr/lib/syslinux/pxelinux.0" . Copy that file into /tftpboot and make sure that it is world readable.
4) Next we need to configure pxelinux. First create the directory /tftpboot/pxelinux.cfg (and make it world readable). Inside that directory you need to create a number of zero size files (use touch):
Ex: My IP is 11.1.0.0/16
So i have converted my ip to hexadecimal . Follow this links to convert that
http://www.kloth.net/services/iplocate.php
Then create files using touch
0B0200
0B020
0B02
0B0
0B
0
01-04-4B-80-80-80-03
First 8 Digit hexadecimal . You can use first 6 digit and make the empty file.
The last entry is the MAC address of your PXE boot client's NIC (with dashes substituted for the colons), with '01' pre-pended. The "01" at the front represents a hardware type of Ethernet, so pxelinux.0 see's the configuration string as an IP address.
5) Now create the default pxelinux configuration inside the new file
#vim /tftpboot/pxelinux.cfg/default
prompt 1
default linux
timeout 100
label linux
kernel vmlinuz
append initrd=initrd.img noapic acpi=off ks=nfs:11.1.0.5:/u1/Centos/ks.cfg
(Lot of doc available to create ks.cfg in linux)
9) Sample ks.cfg file
#vim /u1/Centos/ks.cfg
# Kickstart file automatically generated by anaconda.
install
nfs --server=11.1.0.5 --dir=/u1/Centos
lang en_US.UTF-8
keyboard us
text
network --device eth0 --bootproto dhcp
rootpw --iscrypted $1$nqP5r3zm$82An6lClteT0q4n4Jb3BR.
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc Asia/Calcutta
bootloader --location=mbr --driveorder=sda
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --drives=sda
part /boot --fstype ext3 --size=100 --ondisk=sda
part pv.6 --size=0 --grow --ondisk=sda
volgroup VolGroup00 --pesize=32768 pv.6
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=256 --grow --maxsize=512
logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
reboot
%packages
@development-libs
@editors
@text-internet
@dialup
@core
@base
@web-server
@admin-tools
@development-tools
kexec-tools
device-mapper-multipath
imake
-sysreport
6) Now you need to put the full contents of your Linux distro (all CDs) somewhere on disk. I put it under /u1/Centos/i386 folder.
7)Then we have to configure NFS
8) Lets see PXE by NFS
activate NFS in your system
#cat /etc/exports
9) Now you can add the mac address of the machine which you are going to install pxe installation like below
10) Need to make some changes in dhcpd file
Add two lines for Boot from lan in dhcpd.conf file
allow bootp;
allow booting;
10) See the sample dhcpd.conf file
[root@node1 ~]# cat /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
allow bootp;
allow booting;
subnet 11.1.0.0 netmask 255.255.0.0 {
# --- default gateway
option routers 11.1.0.5;
option subnet-mask 255.255.0.0;
option nis-domain "karthik.sk";
option domain-name "domain.org";
option domain-name-servers 11.1.0.5, 11.1.0.2;
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 11.1.1.10 11.1.1.200;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
}
# Group the PXE bootable hosts together
group {
# PXE-specific configuration directives...
next-server 11.1.0.5;
# You need an entry like this for every host
# unless you're using dynamic addresses
host monitoring.karthik.sk {
hardware ethernet 00:0c:29:ab:40:6a;
#fixed-address 11.1.0.6;
filename "pxelinux.0";
}
}