Search This Blog

Tuesday, April 26, 2011

Hard Disk Performance Monitor

Use following well written article for checking disk performance.

http://www.linuxjournal.com/article/5203

Monday, April 18, 2011

Ps Command .

Good article over PS command can be found at following webpage.

http://www.thegeekstuff.com/2011/04/ps-command-examples/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+TheGeekStuff+%28The+Geek+Stuff%29

How to find Old powered off machines in oracle vm .

With VM environment consisting of more than 500 virtual machines,You may find this helpful .

It might not be possible to observe each and every virtual machines to find instances of powered off machines since long time .

A little bit of scripting will help you find such machines.

Create a file called VM_Shutdown_Count.sh
Should be run specifying number of days.
For example.
#VM_Shutdown_Count.sh 30
Will list all the vm machines powered off since 30 days.i.e 1 Month.

Arg=$1

if [ -z $Arg ]
then
echo "Please Enter Argument"
exit
fi



cat `find /var/ovs/mount/ -name vm.cfg` | grep "disk" | awk -F ":" '{print $2}'| awk -F "," '{print $1}' |grep running_pool| grep -v "^$" > /tmp/file1.txt

find /var/ovs/mount/ -name *.img -mtime +$Arg > /tmp/file2.txt

rm -rf /tmp/final.txt
while read line
do
cat /tmp/file2.txt | grep $line >> /tmp/final.txt
done < /tmp/file1.txt

while read line
do
ls -ltrh $line
done < /tmp/final.txt

Sunday, April 17, 2011

How to Install TexttoHtml .

Why do you need TexttoHTML ?

A system administrator needs to send alert mails .Most of the times the alert mail contains the output of specific commands say ps -aux.

When this output is forwarded as mail the mail seems to be all text and no proper formatting.

Texttohtml utility helps to first convert this output to mail and then send it to user mail account.

Prerequisite:
Perl module is needed for installing TexttoHTML.

I m using following version of texttohtml.
/usr/bin/txt2html version: 2.51

http://txt2html.sourceforge.net/

Perl Module version installed on my distribution.
v5.8.8.

The simplest way of installing Texttohtml is via CPAN Module.

You can use the shell (perl -MCPAN -e shell ) to change settings, search for modules, install, update, ...

For easy installation of modules the community developed a module to fetch, install, and update modules not in the core distribution . To install a module including all dependencies, just type perl -MCPAN -e 'install HTML::TextToHTML' .

#perl -MCPAN -e shell

#perl -MCPAN -e 'install HTML::TextToHTML'
While

Sunday, April 10, 2011

How to Copy an entire directory to another server?

Copy an entire directory to another server.


#scp -r username@hostname:sourcepath destinationpath
example
# scp -r /OVS2/seed_pool/Window2008_Standard_R2_64_Eval 10.180.13.111:/OVS/seed_pool/


More on this coming soon.

Thursday, April 7, 2011

How to find crashed,blue dumped machines in Oracle VM.

With VM environment consisting of more than 500 virtual machines,You may find this helpful .

It might not be possible to observe each and every virtual machines to find instances of crashed machines (Such as Hanged,Blue dumped Machines).

Well with little bit of observation you can find such machines .
Below script helped me find out more than 10-15 crashed machines.
The trick is simple : You need to get the number of running machines and then compare their harddisk's modified date (System.img file specified in vm.cfg file) against Current date.
If you found any machines having Harddisk not modified on current date and still its running You are pretty sure it has some problem.

Executed below script on each VM machine and observed the output.


First of List all the running machines and store it in file called machine

#!/bin/bash

xm list | awk '{print $1}' > machine

while read line
do
#ls -ltr `find /var/ovs/mount/ -name $line` >> log
#find /var/ovs/mount/ -type f -name $line | sed "s#^.#$(pwd)#" > log
find `find /var/ovs/mount/ -name $line -type d` -name *.img -type f >> log
done < machine


while read line
do
ls -ltr $line
done < log

Wednesday, April 6, 2011

Machine Architectures.

Most of the time you get confused over i386, i586, i686, x86_64 terms .especially while installing rpms.
I found following thread entry to be very useful for addressing such problems.
http://www.linuxforums.org/forum/newbie/28214-rpm-differences-i386-i586-i686-x86_64-ppc-etc-etc.html

Tuesday, April 5, 2011

RAM Upgrade Activity on SUN FIRE

The server is running oracle virtualization.

Existing RAM :

RAM SLOTS occupied /Total RAM SLOTS
24 /64

RAM Size Each

4 GB.

Total RAM
4*24 = 96 GB.
Its easier to validate all the above information by opening up the physical server and examining ram slots.

However In production environment you hardly get any downtime so question of opening physical server has its own disadvantages.

The only option left is to Gather all the information from operating system itself.

Here is how i gathered the information.

# free -m
total used free shared buffers cached
Mem: 2048 2026 21 0 43 1693
-/+ buffers/cache: 290 1757
Swap: 10236 0 10236


# cat /proc/meminfo | grep Mem
MemTotal: 2097152 kB
MemFree: 30884 kB

Both the above statements only returned RAM size allocated to Dom-0 (Which is only 2 GB) and not the actual physical RAM.

To check the actual physical RAM i needed to run

# xm info | grep mem
total_memory : 98294
free_memory : 4276
node_to_memory : node0:4276

Which returned me the actual physical memory which is 96 GB.

Its time to explore deep into RAM allocation.i.e. to determine
How many RAMs are used?
What RAM size allocated for each slot?(As the server is capable of holding 2 GB, 4 GB, or 8 GB DDR3 ECC Registered DIMMs)

One tool that helps in determining all these without going into BIOS is dmidecode .

Fired following command to get the memory related information.
# dmidecode -t memory
It listed a huge output.

With little bit of grep i managed to get most out of the output.
For example.
1) Determine How many Memory Slots are available.

# dmidecode -t memory | grep "Bank Locator" | wc -l
65
Sets of physical memory modules may also be referred to as memory banks.

Useful link.
http://knowaddict.blogspot.com/2010/01/check-ram-slot-in-linux-using-dmidecode.html

Monday, April 4, 2011

SAR utility to monitor cpu utilization.

Downloaded Sar from below url.

http://sebastien.godard.pagesperso-orange.fr/download.html

I found it little difficult to install rpm(sysstat-10.0.0-1.i586.rpm) so i moved my attention to install sysstat-10.0.0.tar.gz using make install method.

# ls -ltr
total 328
-rw-r--r-- 1 root root 330646 May 3 13:09 sysstat-10.0.0(2).tar.gz
# gunzip sysstat-10.0.0\(2\).tar.gz
# ls -ltr
total 1796
-rw-r--r-- 1 root root 1832960 May 3 13:09 sysstat-10.0.0(2).tar
# tar -xvf sysstat-10.0.0\(2\).tar
# ls -ltr
total 1800
drwxr-xr-x 8 501 501 4096 Mar 14 01:16 sysstat-10.0.0
-rw-r--r-- 1 root root 1832960 May 3 13:09 sysstat-10.0.0(2).tar


The simplest way to compile this package is:

1. `cd' to the directory containing the package's source code
# cd sysstat-10.0.0
Now type
`./configure' to configure the package for your system.
#./configure
If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.

Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.

2. Type `make' to compile the package.
#make
3. Optionally, type `make check' to run any self-tests that come with
the package.(Not very Important)

4. Type `make install' to install the programs and any data files and
documentation.
#make install

5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
(Source of information: INSTALL file that comes bundled with sar utility)


Install various dependencies from Distribution CD.(This is only required if above installation is failed due to dependencies. )

Everything You need to know about SAR is written in below article.

Lets explore more into SAR.

Let monitor the CPU utilization for some time .Gathering a cpu stat at a point makes no sense so continuous gathering has its own advantages .
Say in below command cpu is observered 10 times in an interval of 2 seconds.

# sar 2 10
Linux 2.6.18-92.el5 (OEL-5.2-32bit) 04/06/2011 _i686_ (1 CPU)

03:45:19 PM CPU %user %nice %system %iowait %steal %idle
03:45:21 PM all 0.00 0.00 0.51 0.00 0.00 99.49
03:45:23 PM all 0.00 0.00 0.51 0.00 0.00 99.49
03:45:25 PM all 0.00 0.00 0.51 0.00 0.00 99.49
03:45:27 PM all 0.00 0.00 1.01 0.00 0.00 98.99
03:45:29 PM all 0.00 0.00 1.01 0.00 0.00 98.99
03:45:31 PM all 0.00 0.00 0.00 0.00 0.00 100.00
03:45:33 PM all 0.00 0.00 1.01 0.00 0.00 98.99
03:45:35 PM all 0.00 0.00 0.00 0.00 0.00 100.00
03:45:37 PM all 0.00 0.00 1.01 0.00 0.00 98.99
03:45:39 PM all 0.00 0.00 1.01 0.00 0.00 98.99
Average: all 0.00 0.00 0.66 0.00 0.00 99.34

The most important row from above output is the one which displays average of cpu utilization(highlighted in bold).
The Most Important column from above output is the one which displays idle cpu(Since my machine is just a sar utility testing machine ,i m not getting any cpu utilization .In short most of the time my cpu is idle).

Now its time to generate some load on CPU and then examine the output of SAR.
created a simple scipt with name cpuload.sh .
#!/bin/bash

while : ; do
true
done
and executed it in background using .
# ./cpuload.sh &

Ran above sar command one more time and examined the output.

# sar 2 10
Linux 2.6.18-92.el5 (OEL-5.2-32bit) 04/06/2011 _i686_ (1 CPU)

04:21:31 PM CPU %user %nice %system %iowait %steal %idle
04:21:33 PM all 100.00 0.00 0.00 0.00 0.00 0.00
04:21:35 PM all 99.50 0.00 0.50 0.00 0.00 0.00
04:21:37 PM all 99.49 0.00 0.51 0.00 0.00 0.00
04:21:39 PM all 99.49 0.00 0.51 0.00 0.00 0.00
04:21:41 PM all 100.00 0.00 0.00 0.00 0.00 0.00
04:21:43 PM all 98.99 0.00 1.01 0.00 0.00 0.00
04:21:45 PM all 99.49 0.00 0.51 0.00 0.00 0.00
04:21:47 PM all 99.49 0.00 0.51 0.00 0.00 0.00
04:21:49 PM all 99.49 0.00 0.51 0.00 0.00 0.00
04:21:51 PM all 99.49 0.00 0.51 0.00 0.00 0.00
Average: all 99.55 0.00 0.45 0.00 0.00 0.00

Now its time to find the culprit behind the cpu load.
Below command displays top 10 cpu utilized processes.

# ps -auxf | sort -nr -k 3 | head -10
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
root 4962 87.6 0.1 4476 964 pts/1 R 16:18 4:15 \_ /bin/bash ./cpuload.sh
root 309 0.5 0.0 0 0 ? S< 15:40 0:14 \_ [kjournald]
root 4663 0.2 0.1 1948 644 ? S 15:42 0:05 \_ hald-addon-storage: polling /dev/hdc
root 4844 0.1 0.8 27388 4140 ? Sl 15:42 0:03 /usr/libexec/gdm-rh-security-token-helper
root 4224 0.1 2.0 42336 10580 ? Ssl 15:42 0:03 /usr/bin/python -E /usr/sbin/setroubleshootd
root 1 0.1 0.1 2064 620 ? Ss 15:40 0:03 init [5]
xfs 4572 0.0 0.3 3928 1700 ? Ss 15:42 0:00 xfs -droppriv -daemon
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
smmsp 4518 0.0 0.2 8052 1484 ? Ss 15:42 0:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
rpc 4211 0.0 0.1 1808 608 ? Ss 15:42 0:00 portmap

Examine the entry in bold.

Now its time to terminate the script .
# ps -ef | grep cpuload
root 4962 4875 89 16:18 pts/1 00:04:55 /bin/bash ./cpuload.sh
root 4987 4875 0 16:23 pts/1 00:00:00 grep cpuload
Kill it using process id.
# kill -9 4962

CPU is back to normal again.

# sar 2 10
Linux 2.6.18-92.el5 (OEL-5.2-32bit) 04/06/2011 _i686_ (1 CPU)

04:24:13 PM CPU %user %nice %system %iowait %steal %idle
04:24:15 PM all 0.00 0.00 0.51 0.00 0.00 99.49
04:24:17 PM all 0.00 0.00 0.00 0.00 0.00 100.00
04:24:19 PM all 0.00 0.00 0.00 0.00 0.00 100.00
04:24:21 PM all 0.00 0.00 0.50 0.00 0.00 99.50
04:24:23 PM all 0.00 0.00 0.00 0.00 0.00 100.00
04:24:25 PM all 0.00 0.00 0.50 0.00 0.00 99.50
04:24:27 PM all 0.00 0.00 0.00 0.00 0.00 100.00
04:24:29 PM all 0.00 0.00 0.00 0.00 0.00 100.00
04:24:31 PM all 0.00 0.00 0.00 0.00 0.00 100.00
04:24:33 PM all 0.00 0.00 1.01 0.00 0.00 98.99
Average: all 0.00 0.00 0.25 0.00 0.00 99.75

Find more info Here.

http://www.thegeekstuff.com/2011/03/sar-examples/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+TheGeekStuff+%28The+Geek+Stuff%29

Please Leave us with your comments and Queries/Suggestions.
I will try to reply asap.