Script to generate interface configs on Linux

September 16th, 2009

Generate ifcfg-eth1 307-366 configs.

touch ifcfg-eth1:{307..366}
for f in ifcfg-eth1:{307..366}; do cat origfile > “$f”; done
for f in eth1:{307..366}; do echo “DEVICE=$f” >> “ifcfg-$f”; done
for f in {307..366}; do echo “IPADDR=aaa.bbb.ccc.$((f-239))” >> “ifcfg-eth1:$f”; done

origfile contains:

GATEWAY=eee.fff.ggg.hhh
TYPE=Ethernet
BOOTPROTO=none
NETMASK=255.255.255.192

How do I find out Linux Disk utilization RHEL/Centos?

September 2nd, 2009

iostat syntax for disk utilization report

iostat -d -x interval count

-d : Display the device utilization report (d == disk)
-x : Display extended statistics including disk utilization

interval : It is time period in seconds between two samples . iostat 2 will give data at each 2 seconds interval.

count : It is the number of times the data is needed . iostat 2 5 will give data at 2 seconds interval 5 times

Display 3 reports of extended statistics at 5 second intervals for disk

Type the following command:

# iostat -d -x 5 3

Output:

[root@vari Desktop]# iostat -d -x 5 3

Linux 2.6.18-128.7.1.el5xen (vari.taashee.com) 08/26/2009 _i686_ (2 CPU)

Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util

sda 2.41 12.42 3.27 5.37 134.84 142.70 32.13 0.12 14.04 1.83 1.58

Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util

sda 0.00 1.60 0.00 0.40 0.00 16.00 40.00 0.00 0.00 0.00 0.00

Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util

sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

Where,

rrqm/s : The number of read requests merged per second that were queued to the hard disk
wrqm/s : The number of write requests merged per second that were queued to the hard disk
r/s : The number of read requests per second
w/s : The number of write requests per second
rsec/s : The number of sectors read from the hard disk per second
wsec/s : The number of sectors written to the hard disk per second
avgrq-sz : The average size (in sectors) of the requests that were issued to the device.
avgqu-sz : The average queue length of the requests that were issued to the device
await : The average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.

svctm : The average service time (in milliseconds) for I/O requests that were issued to the device
%util : Percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100%.

How do I interpret the output result for optimization?

First you need to note down following values from the iostat output:

1. The average service time (svctm)
2. Percentage of CPU time during which I/O requests were issued (%util)
3. See if a hard disk reports consistently high reads/writes (r/s and w/s)

If any one of these are high, you need to take one of the following action:

Get high speed disk and controller for file system (for example move from SATA I to SAS 15k disk)
Tune software or application or kernel or file system for better disk utilization
Use RAID array to spread the file system

Update from phpBB 3.0.4 to 3.0.5

August 19th, 2009

To perform the update, either follow the instructions from the Administration Control Panel->System Tab – this should point out that you are running an outdated version and will guide you through the update – or follow the instructions listed below.

Go to the downloads page and download the latest update package listed there, matching your current version.
Upload the archives contents to your phpBB installation – only the install folder is required. Upload the whole install folder, retaining the file structure.
After the install folder is present, phpBB3 will go offline automatically.
Point your browser to the install directory, for example http://www.example.com/phpBB3/install/
Choose the “Update” Tab and follow the instructions

Installing perl audio converter

August 5th, 2009

Download the latest version of pacpl from:

Download PACPL from http://pacpl.sourceforge.net/

install cpan, either with yum,apt..

Install these cpan modules:

cpan install Ogg::Vorbis::Header
cpan install Inline::MakeMaker
cpan install MP3::Tag
cpan install Audio::FLAC::Header
cpan install MP4::Info
cpan install Audio::WMA
cpan install Audio::Musepack
cpan install CDDB_get

Untar the pacpl source and move the binary into /usr/bin and the share/pacpl files into /usr/share/pacpl, also the config file (pacpl.conf) should be in /etc/pacpl/

To convert from .caf to mp3 use:

pacpl –to mp3 file.caf

Joomla: Change Super Admin/Administrator password

July 30th, 2009

Login with your mysql client and issue either one of these:

UPDATE `jos_users` SET `password` =MD5(“getsmart”) WHERE usertype = “Super Administrator”;
or
UPDATE `jos_users` SET `password` =MD5(“getsmart”) WHERE usertype = “Administrator”;

Joomla : .htaccess SEO friendly

July 30th, 2009

Site->Global Configuration-> Go to Search Engine Friendly URLs and select and Use Apache mod_rewrite. Select both to “YES”.

Then on your hosting server copy htaccess.txt to .htaccess. Now you should have urls like : http://site.com/contact

Joomla with suPHP: Premature end of script headers: index.php

July 30th, 2009

Got this error while I was trying to configure Joomla to work with suPHP. This is the config I`m using to make it work:


ServerAdmin aa@aa.com
ServerName www.site.org
ServerAlias site.org
DocumentRoot /home/virtuals/www.site.org/public_html/
ErrorLog /home/virtuals/www.site.org/logs/error.log
CustomLog /home/virtuals/www.site.org/logs/access.log combined
ServerSignature On
php_admin_flag safe_mode Off
php_admin_flag register_globals On
php_admin_value open_basedir /home/virtuals/www.site.org/public_html:/tmp



AllowOverride All
Allow from All
Options Indexes FollowSymLinks



php_admin_flag engine on
suPHP_Engine on
AddHandler php5-script .php
php_admin_flag engine on

Error : Database Error: Unable to connect to the database:The MySQL adapter “mysql” is not available.

July 30th, 2009

Got this error :

Database Error: Unable to connect to the database:The MySQL adapter “mysql” is not available.

There are some reasons why this occurs:

- php-mysql not installed
- php admin flags wrong set
- wrong suphp configuration, handlers should be:

[handlers]
;Handler for php-scripts
x-httpd-php=”php:/usr/bin/php”

;Handler for CGI-scripts
x-suphp-cgi=”execute:!self”

Error: not within configured docroot

July 30th, 2009

Got this error these days :

[Thu Jul 30 06:58:16 2009] [warn] Script “/home/virtuals/www.site.org/public_html/index.php” resolving to “/home/virtuals/www.site.org/public_html/index.php” not within configured docroot

add docroot into your suphp.conf file and restart apache

How to sort folders by size with one command line in Linux

July 30th, 2009

du –max-depth=1 $PWD | sort -n -r
du -H –max-depth=1 $PWD

“-H” – produce human readable format sizes (like: 1K 10M 1G)

A good and short one liner using xargs

du -s ./* | sort -n| cut -f 2-|xargs -i du -sh {}

This will sort the folders according to size and display them in human readable format… to reverse the list
use sort -nr option.