Tuesday, June 8, 2010

How to count files in a directory in linux

count files in a directory : ls -1 | wc -l
count files including hidden files : ls -1a | wc -l

Read More !

Tuesday, June 1, 2010

How to resolve Squid error

Error message when restarting squid :

Error message : squid: ERROR: Could not send signal 0 to process 20348: (3) No such process

Solution :

Executed the following command for detailed squid log /path/to/sbin/squid -DNYCd3 .
Error was due to /var partition being full where squid creates the pid file and other logs.
Cleared the /var parition and squid started working perfectly fine.

Read More !

Monday, May 24, 2010

How to configure LVM (Logical Volume Management)

A 5 Step guide to LVM (logical volume management)

1. Prepare partitions for lvm

pvcreate /dev/hardisk /dev/hardisk

example : pvcreate /dev/sda1 /dev/sdb1

pvdisplay - to display physical volumes

2. next create volume group with each physical volume

vgcreate
/dev/hardisk /dev/hardisk
example : vgcreate fileserver /dev/sda1 /dev/sdb1

vgdisplay - to display volume group

3. next create logical volumes

lvcreate --name --size xxG

example : lvcreate --name share --size 25G fileserver

4. create filesystem

mkfs.ext3 /dev//

example : mkfs.ext3 /dev/fileserver/share

5. mount the logical volume

mount /dev/fileserver/share /var/share
Read More !

Nagios client installation guide

if xinetd is not installed, install it.

1. add nagios user and set a password.

2. create nagcmd group and add nagios and apache to it.
(used to issue commands directly from web interface)

/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache


3. download and install nagios plugin

cd /home/downloads
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz
tar xfv nagios-plugins-1.4.14.tar.gz
cd nagios-plugins-1.4.11

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install


4. change the permissions

chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec


5. download and install nrpe plugin (nrpe uses 5666)

cd /home/downloads
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
tar xfv nrpe-2.12.tar.gz
cd nrpe-2.12

./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd


6. nrpe configuration

vim /etc/xinetd.d/nrpe

only_from = 127.0.0.1 (change to nagios server ip address)

7. add nrpe port to services file

vim /etc/services

nrpe 5666/tcp # NRPE


8. service xinetd restart

9. testing nrpe

netstat -at |grep nrpe

output : tcp 0 0 *:nrpe *.* LISTEN

Read More !

Nagios server installation guide

Nagios is network monitoring tool used to monitor servers ,routers , switches and other devices.

Server Installation

Prerequisites : Apache, PHP, GCC compiler, GD development libraries

yum install httpd php gcc glibc glibc-common gd gd-devel

1. add nagios user and set a password.

2. create nagcmd group and add nagios and apache to it.
(used to issue commands directly from web interface)

/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache


3. download nagios core and nagios plugin from nagios website.

4. extract the nagios core into a directory and configure with the group option.

cd /home/downloads
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.1.tar.gz
tar xfv
nagios-3.2.1.tar.gz
cd nagios-3.2.1
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

5. start apache

6. Next install nagios plugin with nagios user and nagios group

cd /home/downloads
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz
tar xfv
nagios-plugins-1.4.14.tar.gz
cd nagios-plugins-1.4.11
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install


7. service nagios start

8. to view the webinterface

http://ipaddress/nagios/

To monitor remote server, you need to install nrpe plugin

1. download and install nrpe plugin (nrpe uses 5666)

./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd

2. nrpe configuration

vim /etc/xinetd.d/nrpe

only_from = 127.0.0.1
(change to nagios server ip address)

3. add nrpe port to services file

vim /etc/services

nrpe 5666/tcp # NRPE

4. service xinetd restart

5. testing nrpe

netstat -at | grep nrpe

output : tcp 0 0 *:nrpe *.* LISTEN


Read More !