Wednesday, August 8, 2007

installing and running memcached

memcached is a general-purpose distributed memory caching system.
It is often used to speed up dynamic database-driven websites by caching data and objects in memory to reduce the amount the database needs to be read.

memcached is dependent on libevent library, so firstly download the source files for Libevent
from http://www.monkey.org/~provos/libevent/

Install libevent:

$ tar -xvf libevent-1.3c.tar.gz
$ cd libevent-1.3c
$ ./configure
$ make
$ make install

In Fedora the library (libevent-1.3c.so.1.0.3) will be installed at
/usr/local/lib
Create a link or copy this file to standard libarary location (/lib) of Fedora
$ cd /lib
$ ln -s /usr/local/lib/libevent-1.3c.so.1.0.3 libevent-1.3c.so.1

Download the latest memcached from http://www.danga.com/memcached/download.bml


$ tar -xzf memcached-1.2.2.tar.gz
$ cd memcached-1.2.2
$ ./configure
$ make
$ make install

Running:
$ memcached -h
(Will display various options)

To run as a deoman
$ memcached -d -u apache
Will start as daemon with default options Port(p): 11211 and Max memory (m) to use: 64MB

Wednesday, August 1, 2007

Create swap file in Fedora- Linux

Swap file is used by the Kernel for Virtual Memory.
It is recommended to have swap size double of the RAM but if RAM is more than enough (>512 MB) then
smaller swap has no issue.

To know the actual memory (RAM) and already swap on a Linux box use the free command.

$ free
total used free shared buffers cached
Mem: 507956 489860 18096 0 9580 76876
-/+ buffers/cache: 403404 104552
Swap: 1012084 69668 942416

Now to create extra swap file follow the steps:
(To create swap file of approx 1GB)

$ dd if=/dev/zero if=/usr/more_swap bs=1000000 count=1024

(It will create one swap file more_swap in /usr)

$ chmod 600 /usr/more_swap
$ mkswap /usr/more_swap
$ swapon /usr/more_swap


Now add this file to the /etc/fstab file (at last)
$ vi /etc/fstab

/usr/more_swap swap swap defaults 0 0

Tuesday, July 17, 2007

Installing and running Nagios

Download latest & stable nagios from here. Select the tarball
Download
Also download the plugins

Here these steps have been performed on Fedora 2 and Fedora5 using the nagios-2.9 and nagios-plugin-1.4.9.

Add one user nagios and one group nagcmd
$adduser nagios
(There is no need of assigning password to this user as this user is not going to login to the
system)
$groupadd nagcmd

Add user nagios and web server user apache to this group
(To know who is the owner of web server
$grep "^User" /etc/httpd/conf/httpd.conf
)

$usermod -G nagcmd nagios
$usermod -G nagcmd apache

$cd /usr/local/
Create one dir to hold all the nagios files
$ mkdir nagios
Change ownership of this dir to nagios
$chown -R nagios:nagios nagios

Untar the downloaded nagios tar file
$tar -xzf nagios-x.x.tar.gz

It will create one dir nagios-x.x inside the /usr/local
$cd nagios-x.x/

Configure the nagios and install
$./configure --prefix=/usr/local/nagios --with-cgiurl=/nagios/cgi-bin --with-htmurl=/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd
$make all
$make install
$make install-init
$make install-commandmode
$make install-config

Installing Plugins
$ cd /usr/local

Untar the downloaded nagios plugin
$tar -xzf nagios-plugins-1.x.x.tar.gz
$cd nagios-plugins-1.x.x/

Configure the nagios plugin, and install plugins
$./configure --prefix=/usr/local/nagios

$make
$make install

Plugins will be installed at
/usr/local/nagios/libexec

Setup The Web Interface

Configure Aliases and Directory Options For The Web Interface
Add these line (at last) in the httpd.conf file (at /etc/httpd/conf dir)

ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin



Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user


Alias /nagios /usr/local/nagios/share


Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user


Restart the webserver
$ /etc/init.d/httpd restart

Configure Web Authentication
$htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

(Enter the password)

Rename the config sample file
Nagios creates sample configurtion files at /usr/local/nagios/etc
Rename these files
$cd /usr/local/nagios/etc
$mv nagios.cfg-sample nagios.cfg
...and so on

Start nagios
$/etc/init.d/nagios start

After changing any config file check the main nagios.config
$ /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

It will display any syntax error in any config file with file name and line number, rectify the errors and reload the nagios.

$/etc/init.d/nagios reload

Point your browser at:

http://localhost/nagios

It will ask for apache authentication, supply the user: nagiosadmin and password

Thursday, July 12, 2007

Friday, June 29, 2007

add svn repository

1. add one svn user and group

$ useradd svn -c "SVN Owner" -s /bin/false
(-c comment, -s shell , here no shell access)

2. If we want more than one repository then add group for each one.

$ groupadd reposgp
$ usermod -G reposgp svn
(Add this group to svn user/group)

3. Create a Subversion repository

We are creating it at /var ; svn will be the folder containing all repos
$ install -v -m 0755 -o svn -g svn -d /var/svn
$ svnadmin create --fs-type fsfs /var/svn/repos

(Here 'repos' will be our repos)

Now we can import some files/dir to the repos

$ svn import -m "Initial import." /path/to/source/tree
file:///var/svn/repos


Now change owner and group information on the repository, and add
an unprivileged user to the svn and reposgp groups:

$ chown -R svn:odotgp /var/svn/repos
$ chmod -R g+w /var/svn/repos
$ chmod g+s /var/svn/repos/db
$ usermod -G svn,repsogp sanjay

(here sanjay is already a user in the system)

We can verify the existing groups of user with the commands

$ groups sanjay

Monday, June 18, 2007

Regular Expressions

Regular Expression:

^ : Matches the Beginning of string
$ : Matches the End of string
(): Parentheses, define the scope and precedence of Operators

Quantification: How often the preceding expression is allowed
There are 3: ?, * and +

?: 0 or 1 [ colou?r will match color or colour ]
*: 0, 1 or any number [ go*gol will match ggol, gogol, googol, gooogol etc ]
+: at least 1 [ go+gol = gogol, googol, gooogol etc ]

{n}: Repeat n times the previous exp

Examples:

1xx : ^1[0-9]{x}
21xx or 22xx: ^2[12][0-9]{2}
3xxxxxxxxxx, 4xxxxxxxxx, 9xxxxxxxxx (10 digits telephone number starting with 3, 4 or 9)
^[349][0-9]{9}

Thursday, June 14, 2007

Setting a Crontab

Syntax:

* * * * * command

# Use the hash sign to prefix a comment
# +---------------- minute (0 - 59)
# | +------------- hour (0 - 23)
# | | +---------- day of month (1 - 31)
# | | | +------- month (1 - 12)
# | | | | +---- day of week (0 - 7) (Sunday=0 or 7)
# | | | | |
# * * * * * command to be executed


Crontab Example
_______

A line in crontab file like below removes the tmp files from /home/someuser/tmp each day at 6:30 PM.

30 18 * * * rm /home/someuser/tmp/*

Changing the parameter values as below will cause this command to run at different time schedule below :

min hour day/month month day/week Execution time
30 0 1 1,6,12 * -- 00:30 Hrs on 1st of Jan, June & Dec.

:

0 20 * 10 1-5 --8.00 PM every weekday (Mon-Fri) only in Oct.

:

0 0 1,10,15 * * -- midnight on 1st ,10th & 15th of month

:

5,10 0 10 * 1 -- At 12.05,12.10 every Monday & on 10th of every month
:

By default cron jobs sends a email to the user account executing the cronjob. If this is not needed put the following command At the end of the cron job line .

>/dev/null 2>&1

Thursday, May 17, 2007

Happy Bday to Shlok


My son Muthu aka Shlok just celebrated his first birthday at 12th May

Wednesday, May 16, 2007

bugzilla installation on Fedora

Download latest stable Bugzilla from here
Untar the package at /var/www/html folder
$ tar -xzf bubzilla.x.x.tar.gz

Bugzilla's installation process is based on a script called checksetup.pl. The first thing it checks is whether you have appropriate versions of all the required Perl modules. The aim of this section is to pass this check. When it passes, proceed to Section 2.2.

To check you have the required modules, run:

bash# ./checksetup.pl --check-modules

checksetup.pl will print out a list of the required and optional Perl modules, together with the versions (if any) installed on your machine. The list of required modules is reasonably long; however, you may already have several of them installed

$ perl -MCPAN -e 'install ""'

Create one database in mysql with user/passord

Change the localcongif file of bugzilla (db related)

Run the
./checksetup.pl

Change the apache httpd.conf file add

AddHandler cgi-script .cgi
Options +Indexes +ExecCGI
DirectoryIndex index.cgi
AllowOverride Limit


Restart the webserver
Point browser at
http://localhost/bugzilla

Monday, May 7, 2007

Favorite Hindi books

1. Shekhar - Ek Jeevani (part 1)- Agyey

2. Shekhar - Ek Jeevani (part 2)- Agyey

3. Nadi ke Dweep - Agyey

4. Apane-apane ajnabi- Agyey

5. Yayaati - Vishnu Sakharaam Khandekar

6. Rag-Darbaari - Shree Laal shukla

7. Vishrampur ka Sant - Shree Laal shukla

8. Mujhe Chaand Chahiye - Surendra Verma

9. Mratunjay - Vishnu Sawant (Hindi)

10. Yatha-sambhav - Sharad Joshi

11. Vaishnav Ki Fislan: Harishankar Parsai

12. Gunaho ka Devata - Dharmveer Bharati

13. Aur Ant mein Prarthana- Udai Prakash

14. Tastari mein toofan: Meenaxi Puri

15. Apka Bunty : Mannu Bhandari

16. Saara Akash : Rajendra Yadav

17. Warren Hastings Ka Saand : Udai Prakash

18. Zindaginama : Krishna Sobti

19. Ghaalib Chuti Sharab: Ravindra Kaaliya

20. Chaak: Maitreyi Pushpa

21. Edennmam: Maitreyi Pushpa

22. Mitro Marjani: Krishna Sobti

23. Paul Gomara ka scooter: Udai Prakash

24. Maila Aanchal: Renu

25. Sunita : Jainendra

26. Peeli Chhatri Wali Larki: Udai Prakash

27. Tirich: Udai Prakash

28. Andha Yug: Dharam Vir Bharti

29. Dilo Daanish: Krishna Sobti

30. Kasap: Shyam Manohar Joshi

31. Tyaag Patra: Jainendra

Whats new in Ajuby 0.5