Disk contention

To see if we have disk contention problems we’d take a look at an iostat. if asvc_t >50 for sustained periods, the system
has disk contention problems.

[root@ehrpitlin001 ~]# iostat -x 3 10000 | awk '$11>=50'
Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util

we can also check if the %wio cpu is > 5% for more than a minute constantly

[root@ehrpitlin001 ~]# vmstat 1 3000 | awk '$16>=5'
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st

if we have SAR setup we could check it

[root@ehrpitlin001 ~]# sar | awk '$7>=3{print}' | head -5
12:10:01 AM       all      4.93      0.00      2.00     11.84      0.00     81.23
12:20:01 AM       all     22.83      0.00      4.96     14.90      0.00     57.31
12:30:01 AM       all     37.14      0.00      3.83     11.84      0.00     47.19
12:40:01 AM       all     44.26      0.00      3.88     12.71      0.00     39.16
12:50:01 AM       all     48.83      0.03      3.57      9.25      0.00     38.32

Suntrunking Quick setup notes

This is a quick setup guide for suntrunking 1.3
– Install the Suntrunking package. Install the most recent suntrunking patch.
– grab our ce instance numbers, we can get these from path_to_inst.
phoenix# grep ce /etc/path_to_inst
“/sbus@3,0/SUNW, ce@0,8c00000” 0 “ce”
“/sbus@3,0/SUNW, ce@0,8c10000” 1 “ce”
“/sbus@3,0/SUNW, ce@0,8c20000” 2 “ce”
“/sbus@3,0/SUNW, ce@0,8c30000” 3 “ce”
– make sure the local-mac-address? setting is set to true
phoenix# eeprom local-mac-address?
local-mac-address?=false
phoenix# eeprom local-mac-address?=true
In this case we are going to choose ce0 as the head of the trunk, so we set /etc/hostname.ce0 to the hostname and
make sure that
it has an entry in our host file.
There are four possible policies:
1 – MAC Default policy, at its simplest will divide the traffic equally, ie each interface in this example will handle 25% of
the traffic
2 – Round Robin Use each interface in turn
3 – IP Destination Address Use IP Destination address to get the transmission path
4 – IP Source Address/IP Destination Address Deterministic connections
In our case we are going to choose round robin as our policy. So to enable this permanently we edit
/etc/opt/SUNWconn/bin/nettr.sh and add the following line
nettr -setup 0 device=ce policy=2 members=0,1,2,3
We now reboot the server
phoenix# init 6
INIT: New run level: 6
The system is coming down. Please wait.
System services are now being stopped.
Print services already stopped.
Sept 3 09:41:12 phoenix syslogd: going down on signal 15
The system is down.
syncing file systems… done
Program terminated
……………..
Configuring Sun Trunking devices
ce trunk members:
ce0 (head)
ce1
ce2
ce3
configuring IPv4 interfaces: hme0 ce0.
Hostname: phoenix
…….
Now let’s check the configuration
phoenix# ./nettr -conf
Key: 0; Policy: 1;
60/433
Aggr MAC address: 0:14:4f:41:f4:34
Name Original-Mac-Addr Speed Duplex Link Status
—- —————– —– —— —- ——
ce0 0:14:4f:41:f4:34 1000 full up enb
ce1 0:14:4f:41:f4:35 1000 full up enb
ce2 0:14:4f:41:f4:36 1000 full up enb
ce3 0:14:4f:41:f4:37 1000 full up enb
And let’s check the load for each interface, this server is restoring data from tape and sending it to other
servers, so it has mainly outbound traffic. It is very important to push traffic through the trunk in order to see
how is it really operating.
phoenix# ./nettr -stats 0 interval=5
Sep 16 09:16:33 2009
Name Ipkts Ierrs Opkts Oerrs Collis Crc %Ipkts %Opkts
—- —– —– —– —– —— — —— ——
ce0 6 0 26873 0 0 0 0.01 25.01
ce1 6 0 26877 0 0 0 0.01 25.01
ce2 56764 0 26862 0 0 0 99.98 25.00
ce3 0 0 26848 0 0 0 0.00 24.98
(Aggregate Throughput(Mb/sec): 252.00(New Peak) 282.00(Past Peak) 89.36%(N)
61/433

resizing / on Oracle Enterprise Linux

i needed a bigger swap, its size was 2 Gb and we needed it to grow to 16gb, so we decided to shrink /. A task anybody
would say not possible.
So we tuck in the first installation CD for oracle enterprise linux and when prompted for a kernel option we
issued
: linux recover
Once asked to mount the root partition we said yes…
it ended up in /dev/VolGroup00/LogVol00
we checked a df -k, and it was mounted as /mnt/sysimage, and had a dev, proc and other directories
mounted inside, which were not evident in the df -k, so did a
# cat /etc/mtab
and found other dirs mounted, so for each entry in mtab inside /mnt/sysimage we unmounted it, and ended
up unmounting /mnt/sysimage
#umount /mnt/sysimage/selinux
#umount /mnt/sysimage/dev
#umount /mnt/sysimage/sys
#umount /mnt/sysimage/proc
#umount /mnt/sysimage/boot
#umount /mnt/sysimage
To reduce the filesystem, after unmounted and we issued:
# e2fsck -f /dev/VolGroup00/LogVol00
# resize2fs /dev/VolGroup00/LogVol00 110G
After that we needed to resize the volume, so we issued:
# lvm
> lvreduce -L -16G /dev/VolGroup00/LogVol00
And that did the trick to reduce the / filesystem
Then we booted up the server and resized the swap volume issuing:
# lvresize -L +16G /dev/VolGroup00/LogVol01
Had to remake the swap area
190/433
# swapoff /dev/VolGroup00/LogVol01
# mkswap /dev/VolGroup00/LogVol01
And remount it
# swapon -a
You can verify the new swap size with a “top”
191/433

Add new UFS filesystem to existing zone from metadevice

You have to create it in the global zone, add it with zoneconfig, then mount it manually from the global zone
 bash-3.00# zonecfg -z zones004z3
 zonecfg: zones004z3> add fs
 zonecfg: zones004z3:fs> set dir=/myzone/cpbatch
 zonecfg: zones004z3:fs> set special=/dev/md/dsk/d132
 zonecfg: zones004z3:fs> set raw=/dev/md/rdsk/d132
 zonecfg: zones004z3:fs> set type=ufs
 zonecfg: zones004z3:fs> end
 zonecfg: zones004z3> verify
 zonecfg: zones004z3> commit
 zonecfg: zones004z3> exit
 bash-3.00# mount /dev/md/dsk/d132 /zones/CHB/myzone/cpbatch

get your top 10 list !!!

To get this week’s top ten from the web, you can first ask billboard using topten.ksh:
#!/bin/ksh
echo “—- getting bilboard’s heatseeker”
curl
158/433
“http://206.130.124.43//htmlsite/html_top.php?id=23&CALL_URL=http%3A//www.billboard.com/bbcom/charts/chart_display.jsp%3Fg%3DSingles%26f%3DHot%2 BDance%2BClub%2BPlay”
> /tmp/bb-hs.txt
cat /tmp/bb-hs.txt | sed -e ‘s/<[^>][^>]*>//g’ -e ‘/^ *$/d;s// /g;s/Featuring//g;s/ the //g’ | tr -s ‘ ‘ | grep “|”|
grep -iv billboard| cut -d ” ” -f4-9 > terms.txt
The top ten list is parsed and ends up as a text only list in “terms.txt”. We now proceed to search and
download the files both from filestube and skreemr, we use a PHP script called mysearch.php to look for files
in filestube(remembver to use your own key for filestube instead of XXXXXXXX):
#!/usr/bin/php
<?php
// Correct English grammar…
$argc > 1 x y z $plural = ‘s’ : $plural = ”;
// Display the number of arguments received
//fwrite(STDOUT, “Got $argc argument$pluraln”);
$args=””;
// Write out the contents of the $argv array
foreach ( $argv as $key => $value ) {
// fwrite(STDOUT,”$key => $valuen”);
if($key!=0){
if($key>1){
$args=”{$args}%20{$value}”;
}else{
$args=”{$value}”;
}
}
}
//print “args are:”;
159/433
//print $args;
$url=”http://api.filestube.com/? key=XXXXXXXXXXXXXXXXXXXXXXX&phrase=$args&extension=mp3&page=1″;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$result = curl_exec($ch) ;
print curl_error($ch);
curl_close($ch);
$document = new DOMDocument(‘1.0’, ‘UTF-8’);
$document->loadXML($result);
$answer = $document->getElementsByTagName(‘answer’)->item(0);
if($answer!=null) {
$hasResults = $answer->getElementsByTagName(‘hasResults’)->item(0);
if($hasResults->nodeValue == 1)
{
$hits = $answer->getElementsByTagName(‘hits’);
foreach($hits as $hit)
{
$name = $hit->getElementsByTagName(‘name’)->item(0)->nodeValue;
$extension = $hit->getElementsByTagName(‘extension’)->item(0)->nodeValue;
$desc = $hit->getElementsByTagName(‘description’)->item(0)->nodeValue;
$size = $hit->getElementsByTagName(‘size’)->item(0)->nodeValue;
$address = $hit->getElementsByTagName(‘address’)->item(0) ->nodeValue;
$details = $hit->getElementsByTagName(‘details’)->item(0) ->nodeValue;
$added = $hit->getElementsByTagName(‘added’)->item(0)->nodeValue;
$related = $hit->getElementsByTagName(‘related’)->item(0) ->nodeValue;
$counter=$hit->getAttribute(‘id’);
print “$name | “;
print ” $address nr”;
}
}
else {
print ‘0 resultsnr’;
}
}
else {
$error = $document->get ElementsByTagName(‘error’)->item (0);
if($error!=null){
$message = $error->getElementsByTagName(‘message’)->item(0)->nodeValue;
print ‘Message: ‘.$message.”nr”;
}
}
//——————————-SECOND PAGE!!!
$url=”http://api.filestube.com/? key=XXXXXXXXXXXXXXXXXXXXXXX
&phrase=$args&extension=mp3&page=2″;
$ch = curl_init();
160/433
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$result = curl_exec($ch) ;
print curl_error($ch);
curl_close($ch);
$document = new DOMDocument(‘1.0’, ‘UTF-8’);
$document->loadXML($result);
$answer = $document->getElementsByTagName(‘answer’)->item(0);
if($answer!=null) {
$hasResults = $answer->getElementsByTagName(‘hasResults’)->item(0);
if($hasResults->nodeValue == 1)
{
$hits = $answer->getElementsByTagName(‘hits’);
foreach($hits as $hit)
{
$name = $hit->getElementsByTagName(‘name’)->item(0)->nodeValue;
$extension = $hit->getElementsByTagName(‘extension’)->item(0)->nodeValue;
$desc = $hit->getElementsByTagName(‘description’)->item(0)->nodeValue;
$size = $hit->getElementsByTagName(‘size’)->item(0)->nodeValue;
$address = $hit->getElementsByTagName(‘address’)->item(0) ->nodeValue;
$details = $hit->getElementsByTagName(‘details’)->item(0) ->nodeValue;
$added = $hit->getElementsByTagName(‘added’)->item(0)->nodeValue;
$related = $hit->getElementsByTagName(‘related’)->item(0) ->nodeValue;
$counter=$hit->getAttribute(‘id’);
print “$name | “;
print ” $address nr”;
}
}
else {
print ‘0 resultsnr’;
}
}
else {
$error = $document->get ElementsByTagName(‘error’)->item (0);
if($error!=null){
$message = $error->getElementsByTagName(‘message’)->item(0)->nodeValue;
print ‘Message: ‘.$message.”nr”;
}
}
?>
Then we direct all the show with get.ksh:
#!/bin/ksh
#### Get the files from FilesTube
(cat terms.txt| while read line;do
./mysearch.php `echo $line | awk ‘{ print $1 ” ” $2 }’`| grep -i `echo $line | awk ‘{ print $3 }’` | head -1
done) >/tmp/results.txt
(cat /tmp/results.txt | while read result;do
curl “`echo $result | awk -F’|’ ‘{ print $2 }’| sed ‘s/ //g’`” | egrep ‘src.*mp3’ | awk -F”src=”” ‘{ print $2 }’ | awk ‘{
161/433
print $1 }’ | sed ‘s/”//g’
done) | while read url;do
wget -P /200gb/AUTODOWNLOADS “$url”
done
rm /tmp/results. txt
#### Or get them from skreemr
(cat terms.txt| while read line;do
st=`echo $line | awk ‘{ print $1 “+” $2 “+” $3 }’`
wget -P /200gb/AUTODOWNLOADS `curl “http://skreemr. com/results.jsp? q=$st” | egrep ‘href.*mp3’ | awk
-F”href=” ‘{ print $2 }’ | head -1 | sed ‘s/”//g’`
done)
The order of execution is: first “topten.ksh”, to get the list, then “get.ksh” to get the tracks.
Enjoy
162/433

copy only new files

To make a differential copy, so you copy all files in /a that are not in /b, you can do:
# cd /a
#/usr/local/bin/tar pcf – kraftek.html POSTS rescue rescued.html rescued.txt x y z | ( cd /b; /usr/local/bin/tar kxfp – )
The clue here is the “k” option, to keep existing files
compare directories for missing files
So you made a copy of /a into /b, but you see /b has less files, how to know which files are missing in /b x y z
# find /a | sort > as.txt
# find /b | sort > bs.txt
# comm -23 as.txt bs.txt
the last command will show the files that are in /a that are not in /b
enjoy
192/433