Thursday, September 27, 2007

RMagick installation on Fedoras

RMagick requires ImageMagick and ImageMagick-devel libraries.
Your distribution may include at least some of these libraries by default and probably provides pre-built packages for the others. If not, these are available as source code tarballs from http://www.imagemagick.org/pub/delegates/.

Or you can install these using the yum command:

$yum install ImageMagick

$yum install ImageMagick-devel

RMagick also needs Windows TureType font, download the rpm from here:

http://www.zacharywhitley.com/linux/rpms/fedora/core/6/i386/msttcorefonts-2.0-1.noarch.rpm

Install this:
$ rpm -ivh msttcorefonts-2.0-1.noarch.rpm

Make a symbolic link the font dir to the place rmagick expects them:

ln -s /usr/share/fonts/msttcorefonts /usr/share/fonts/default/TrueType

Some applications based on RMagick also requires freeimage header files.
Download freeimage from here
http://freeimage.sourceforge.net/download.html
Unzip the file and cd to the freeimage dir and run following commands

# make
# make install

Now install RMagic using the gem

$ gem install RMagick --include-dependencies

Thursday, August 30, 2007

Connecting Bluetooth devices

Tested on FC7 running on Compaq Presario and Nokia-N73 and Sony w300i

Start the bluetooth device like mobile phone having bluetooth support.
Oviously device should have in-front of the Laptop.

Start the Bluetooth service on FC7.
System => Administration => Server Settings => Services => Bluetooth
Turn on the Wireless on FC7

Run the Bluetooth File Sharing
Applications => System Tools => Bluetooth File Sharing

To check whether FC7 is able to scan the mobile devices
Run at terminal:

$ hcitool scan

It will display the mobile name.

Now open the file browser to send file to mobile.

Right click on file => Send to => Bluetooth => Select the mobile name

In the Mobile it will ask for confirmation, click yes to accept the file from computer.

Wednesday, August 22, 2007

running mp3 and video on Fedora

As default Fedora installation does not support player for MP3 and some video format like avi and MP4, we have to install either MPlayer or VLC to play these files.

To install MPlayer and VLC:

Copy the freshrpm from here

Install this rpm:

$rpm -ivh freshrpms-release-1.1-1.fc.noarch.rpm

Now install MPlayer and VLC

$ yum -y install mplayer vlc

After successful installation you get the 'MPlayer' and 'VLC media player' menu in the Applications => Sound and Video

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

Whats new in Ajuby 0.5