Monday, December 28, 2009

Installing PHP 5.2.x on Centos

Recently I have got into issue where the PHP framework requires php 5.2.x while the installed system of centos 5.4 have php 5.1.x.

The Testing repo of centos have php 5.2.x, I followed the following steps to install the php 5.2.x from centos dev repository.

Method 1:  Which will install all the new packages from Centos Testing repo.

sudo vi /etc/yum.repos.d/Centos-Test.repo

name=CentOS-5 Testing

# CentOS-Testing:
# !!!! CAUTION !!!!
# This repository is a proving grounds for packages on their way to CentOSPlus and CentOS Extras.
# They may or may not replace core CentOS packages, and are not guaranteed to function properly.
# These packages build and install, but are waiting for feedback from testers as to
# functionality and stability. Packages in this repository will come and go during the
# development period, so it should not be left enabled or used on production systems without due
# consideration.

If you are using "yum-priorities" like me then you also have to add the following to the above


Now install the updates

sudo yum --enablerepo=c5-testing update <--- this will install php 5.2.x along with other latest packages from Centos dev repo.

I am not sure how safe its to enable testing repository on production server in my case its a testing server so I can play with it.

Method 2: Only install php 5.2.x and related packages from Centos Testing Repo

sudo yum --enablerepo=c5-testing update php-*

 Package                               Arch                          Version                                       Repository                           Size
 php                                   i386                          5.2.9-2.el5.centos                            c5-testing                          1.2 M
 php-cli                               i386                          5.2.9-2.el5.centos                            c5-testing                          2.4 M
 php-common                            i386                          5.2.9-2.el5.centos                            c5-testing                          237 k
 php-mbstring                          i386                          5.2.9-2.el5.centos                            c5-testing                          1.1 M
 php-mysql                             i386                          5.2.9-2.el5.centos                            c5-testing                           80 k
 php-pdo                               i386                          5.2.9-2.el5.centos                            c5-testing                           62 k

Transaction Summary

This will install the php packages

For more information click Centos Repositories.

Saturday, December 19, 2009

Fedora 12 Yum New Feature 'history'

With Fedora 12 which was recently released and with F12 new version of Yum package manager also released. One of the new feature that new version of Yum bring is history.

The history command allows the user to view what has happened in past transactions. You can use info/list/summary to view what happened, undo/redo to act on that information and new to start a new his-tory file.

The info/list/summary commands take either a transactions id or a package (with wildcards, as in Specifying package names), all three  can also be passed no arguments. list can be passed the keyword "all" to list all the transactions.  undo/redo just take a transaction id.

Here are few examples:

$ sudo yum history
Loaded plugins: dellsysidplugin2, fastestmirror, refresh-packagekit
ID     | Login user             | Date and time    | Action(s)      | Altered
    23 | Askar Ali Khan | 2009-12-19 20:29 | Update         |   35
    22 | Askar Ali Khan | 2009-12-19 20:22 | Install        |    1
    21 | Askar Ali Khan | 2009-12-19 19:57 | Erase          |    1
    20 | System          | 2009-12-16 20:16 | Update         |   20
    19 | System          | 2009-12-13 10:03 | E, I, U        |   51
    18 | System          | 2009-12-09 19:19 | Install        |    1
    17 | System          | 2009-12-09 19:12 | Update         |   14
    16 | System          | 2009-12-07 20:51 | I, U           |   33
    15 | System          | 2009-12-03 17:20 | Update         |   10
    14 | Askar Ali Khan | 2009-12-02 17:57 | I, O, U        |   56
    13 | System          | 2009-11-30 20:37 | Update         |   46
    12 | Askar Ali Khan | 2009-11-30 20:29 | Install        |    1
    11 | Askar Ali Khan | 2009-11-25 20:53 | Update         |   19  <
    10 | Askar Ali Khan | 2009-11-22 09:55 | Erase          |    1 >
     9 | Askar Ali Khan | 2009-11-22 09:55 | Erase          |    3
     8 | Askar Ali Khan | 2009-11-22 09:54 | Install        |    1
     7 | Askar Ali Khan | 2009-11-22 09:53 | Install        |    1
     6 | Askar Ali Khan | 2009-11-22 09:52 | Erase          |    1
     5 | Askar Ali Khan | 2009-11-22 09:50 | Erase          |    3
     4 | System          | 2009-11-20 19:12 | I, U           |   38

To list packages of a transaction, use option 'info' followed by transactions id

$sudo yum history info 15
Loaded plugins: dellsysidplugin2, fastestmirror, refresh-packagekit
Transaction ID : 15
Begin time     : Thu Dec  3 17:20:15 2009
Begin rpmdb    : 1328:10c8f90e66eb2c26aa380265fb4b5b11e56aae7a
End time       :            17:20:53 2009 (38 seconds)
End rpmdb      : 1328:465b91d25241fa9452547719e554f9fb8ec9ac73
User           : System
Return-Code    : Success
Transaction performed with:
    Installed    rpm-4.7.1-6.fc12.i686
    Installed    yum-3.2.25-1.fc12.noarch
    Installed    yum-metadata-parser-1.1.2-14.fc12.i686
    Installed    yum-plugin-fastestmirror-1.1.24-2.fc12.noarch
Packages Altered:
    Updated      fontpackages-filesystem-1.35-1.fc12.noarch
    Update                               1.41-1.fc12.noarch
    Updated      gnome-python2-applet-2.28.0-1.fc12.i686
    Update                            2.28.0-2.fc12.i686
    Updated      gnome-python2-desktop-2.28.0-1.fc12.i686
    Update                             2.28.0-2.fc12.i686
    Updated      gnome-python2-gnomekeyring-2.28.0-1.fc12.i686
    Update                                  2.28.0-2.fc12.i686
    Updated      gnome-python2-libwnck-2.28.0-1.fc12.i686
    Update                             2.28.0-2.fc12.i686
    Updated      libsndfile-1.0.20-2.fc12.i686
    Update                  1.0.20-3.fc12.i686
    Updated      liveusb-creator-3.8.6-1.fc12.noarch
    Update                       3.8.7-1.fc12.noarch
    Updated      mdadm-3.0.3-1.fc12.i686
    Update             3.0.3-2.fc12.i686
    Updated      wget-1.11.4-5.fc12.i686
    Update            1.12-2.fc12.i686
    Updated      xorg-x11-drv-dummy-0.3.2-3.fc12.i686
    Update                          0.3.3-1.fc12.i686
history info

Now to undo a transaction, use option 'undo' with the transaction id:

$ sudo yum history undo 22
Loaded plugins: dellsysidplugin2, fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
updates/metalink                                                                                                                      | 7.7 kB     00:00    
 * fedora:
 Undoing transaction 22, from Sat Dec 19 20:22:12 2009
    Install      gnokii-0.6.28-1.fc12.i686
Resolving Dependencies
--> Running transaction check
---> Package gnokii.i686 0:0.6.28-1.fc12 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

 Package                            Arch                             Version                                     Repository                             Size
 gnokii                             i686                             0.6.28-1.fc12                               installed                             1.9 M

Transaction Summary
Remove        1 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)

Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing        : gnokii-0.6.28-1.fc12.i686                                                                                                             1/1
warning: /etc/gnokiirc saved as /etc/gnokiirc.rpmsave

  gnokii.i686 0:0.6.28-1.fc12                                                                                                                               


Undoing transaction 22 creates a transaction 24. If you want to reinstall what was installed in transaction 22, do the following:

 $ sudo yum history redo 22
Loaded plugins: dellsysidplugin2, fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
 * fedora:
 * rpmfusion-free:
 * rpmfusion-free-updates:
 * rpmfusion-nonfree:
 * rpmfusion-nonfree-updates:
 * updates:
Repeating transaction 22, from Sat Dec 19 20:22:12 2009
    Install      gnokii-0.6.28-1.fc12.i686
Resolving Dependencies
--> Running transaction check
---> Package gnokii.i686 0:0.6.28-1.fc12 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

 Package                             Arch                              Version                                     Repository                           Size
 gnokii                              i686                              0.6.28-1.fc12                               fedora                              539 k

Transaction Summary
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 539 k
Is this ok [y/N]: y
Downloading Packages:
gnokii-0.6.28-1.fc12.i686.rpm                                                                                                         | 539 kB     00:03   
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : gnokii-0.6.28-1.fc12.i686                                                                                                             1/1

  gnokii.i686 0:0.6.28-1.fc12                                                                                                                              


Option 'summary' associated with a package name gives the list of transaction where that package is involved.

$ sudo yum history summary gnokii
Loaded plugins: dellsysidplugin2, fastestmirror, refresh-packagekit
Login user                 | Time                | Action(s)        | Altered
Askar Ali Khan      | Last day            | E, I             |        4
System              | Last 3 months       | I, O, U          |     3909
history summary

And finally here is the option 'list'

$ sudo yum history list gnokii
Loaded plugins: dellsysidplugin2, fastestmirror, refresh-packagekit
ID     | Login user             | Date and time    | Action(s)      | Altered
    25 | Askar Ali Khan | 2009-12-20 12:50 | Install        |    1
    24 | Askar Ali Khan | 2009-12-20 12:46 | Erase          |    1
    22 | Askar Ali Khan | 2009-12-19 20:22 | Install        |    1
    21 | Askar Ali Khan | 2009-12-19 19:57 | Erase          |    1
     3 | System          | 2009-11-20 01:11 | I, O, U        | 1303
     2 | System          | 2009-11-20 00:21 | I, O, U        | 1303
     1 | System          | 2009-11-19 05:40 | I, O, U        | 1303
history list

Wednesday, December 16, 2009

Nagios and SNMP Traps

Recently I have worked on sending and receiving SNMP Traps to and from Nagios, its was really a great experience to extend Nagios alerts to other Managers for example HP NNM. Soon I'll document all the process.

Monday, December 14, 2009

Google Launches Public DNS Resolver

Recently Google launches their free DNS resolution service, called Google Public DNS.
According to their blog post, Google Public DNS uses continuous record prefetching to avoid cache misses — hopefully making the service faster — and implements a variety of techniques to block spoofing attempts. They also say that (unlike an increasing number of ISPs), Google Public DNS behaves exactly according to the DNS standard, and will not redirect you to advertising in the event of a failed lookup.

Google DNS Server IP Addresses

The Google Public DNS IP addresses are as follows:

Add Google DNS Server IP Address Under Linux

Edit the /etc/resolv.conf file and add above two ip address:


Mount an ISO image under Linux

Mounting ISO images under Linux using loop device.

Assuming /mnt/disk directory is already exists, if not then create it before running the below command.


# mount -o loop PathTo/images.iso /mnt/disk

That's it, images.iso has been mounted under /mnt/disk and now you can browse the files.


# umount /mnt/disk

What is loop device, click to read more about loop device. More about loop device.

Sunday, December 13, 2009

Too fast to report a problem!

Today when i tries to send SMS using gnokii from laptop with 'gnokii --sendsms' command it gives a long core dump, my bad that I didn't tries anything at my end and reported a problem on gnokii mailing list.
After a while when I tries with plug/unplug the USB cable which attached with my laptop and phone wow after this simple troubleshooting the 'gnokii --sendsms' start working.

Conclusion: Never report a problem on mailing lists but first exhausting every option at your end.

Make Your Own Holiday Cards with GIMP

Make Your Own Holiday Cards with GIMP: "It's the holiday season! And regardless of which holidays you celebrate, it's a good time to connect with relatives and absent friends.

Maybe you can send them some cards! But those packaged cards... so drab, so dull. Wouldn't it be more fun to make your own? GIMP is a great tool for that..."

Slashdot Linux Story | GNOME Developer Suggests Split From GNU Project

Slashdot Linux Story | GNOME Developer Suggests Split From GNU Project: "'In a recent posting from Philip Van Hoof, he suggests that GNOME split off from the GNU Project and has proposed a vote. He was informed he will need 10% of members to agree for a vote to be put forth. At the same time, David Schlesinger (on the GNOME Advisory Board) has agreed on a vote. Stormy Peters said she doesn't agree with this, but then gave everyone instructions on how to proceed with a vote. She mentioned that roughly 20 members are needed to agree.'"

Friday, December 11, 2009

Inserting character at some location using sed

Inserting Colon ":" after every 2nd digit

Before insertion: 0022938bdea4
After insertion: 00:22:93:8b:de:a4

Method 1: This will also insert Colon in the end
sed 's/\(..\)/\1:/g' <<<0022938bdea4


Method 2: This will work fine without doing the ending colon.
sed -e 's/\(..\)/\1:/g' -e 's/.$//' <<<0022938bdea4

Method 3: Same as Method 2
a=$(sed 's/\(..\)/\1:/g' <<<0022938bdea4); echo "${a:0:${#a}-1}"

Doing it on a file containing the data

while read file; do sed -e 's/\(..\)/\1:/g' -e 's/.$//' <<<"$file";done < mac_addresses.txt

Creating tar archive of the directories

Below is the script for creating .tar archives of the directories containing files, I have coded this script to create .tar archive of the RADIUS bill files.

This script simple create .tar (without compressing it) and later gzip filename could be used to compress the .tar files.

Script require one argument in the form of YYYYMM to create tar archive of all the directories for the specific month of the year.

For example to run, in the current directory

./billfiles 200912 <---will create .tar archives of all the directories in the current directory which have name like 200912*

The script

# Author: Askar Ali Khan
# Date: 2009-02-10
# Purpose: To create tar of bill files
# billfiles


if [ ! "$1" ]
echo "Must provide correct month"
echo "Format: YYYYMM Eg, 200901"
exit 0

if [ ! -d "$SOURCEDIR"/"$1" ]
echo "Directory does not exists,creating ...."
mkdir "$SOURCEDIR"/"$1"
echo "Directory already exists"
exit 0

# Creating tar
for f in "$1"*
echo "Making $f.tar, please wait..."
tar cvf "$SOURCEDIR"/"$1"/"$f".tar "$f"


Wednesday, December 9, 2009

New day!

I am feeling sleeping coz last night my daughter Ayesha was not feeling well and keep awaking all night. Well this is what usually kids do in this age, when its time to sleep they wake up :)
And this is what fun part of life, to sacrifice your sleep for your beloved ones.
Lot of work to do at work, today we have to finalize the shifting of Broadband users to new AAA which were previously made available by moving all the Narrowband users to another AAA.
I have already created all the required charge policies and services so that during time we do not have to waste time on making them.

I have still do modify the manual provisioning scripts to work with Oracle, as the old BB AAA have IBM IDS backend while this one having Oracle 9i.

I wouldn't be difficult to as I have already modified the "Close Account" script to use Oracle and only left the "Create Account" script.

My daughter Ayesha growing

My beloved daughter Ayesha is now almost one year and 2 months old and she is learn fast, walking by her own :)
Its really a fun watching her learn a little thing and walk, smile. Its all about her after I get back to home after work.

Tuesday, December 8, 2009

Google Dictionary

Recently Google launches free online dictionary Google Dictionary. So google is going to give a tough time to work/meaning providers :)
I think that the really interesting thing is how they've integrated Google Translate into the drop down language list. Absolutely beautiful. Very useful. Nice work.

Google Chrome Browser for Linux

Finally google release BETA version of chrome browser for Linux and OSX plateform, I have just install it on my laptop running Fedora 12. Installation was straight forward and as usual google chrome is fast and kick ass browser like all other google applications (GMAIL, gtalk, maps, google search) name the few :)

Google Chrome Extensions Are Now Available is now open for Windows and Linux users — but not yet for Mac — and contains around 300 extensions.