I’ve written a detailed procedure on how to migrate a server using SAN disks as intermediate storage.
Read it!
it is fun.
276/433
Author: rdircio
Vmware tools won’t compile on suse 9.2
You basically get “/bin/sh: scripts/basic/fixdep: No such file or directory”
Using 2.6.x kernel build system.
make: Entering directory `/tmp/vmware-config9/vmmon-only’
make -C /usr/src/linux/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. modules
make[1]: Entering directory `/usr/src/linux-2.6.5-7.314′
Makefile:465: .config: No such file or directory
CC [M] /tmp/vmware-config9/vmmon-only/linux/driver.o
/bin/sh: scripts/basic/fixdep: No such file or directory
make[2]: kraftek.html POSTS rescue rescued.html rescued.txt x y z [/tmp/vmware-config9/vmmon-only/linux/driver.o] Error 1
make[1]: kraftek.html POSTS rescue rescued.html rescued.txt x y z [module/tmp/vmware-config9/vmmon-only] Error 2
make[1]: Leaving directory `/usr/src/linux-2.6.5-7.314′
make: kraftek.html POSTS rescue rescued.html rescued.txt x y z [vmmon.ko] Error 2
make: Leaving directory `/tmp/vmware-config9/vmmon-only’
Unable to build the vmmon module.
If you don’t have a .config file in your kernel source you can:
# make cloneconfig
Then it might complain that
“scripts/modpost: No such file or directory”
So you just copy it according to the kernel you’re running:
89/433
# uname -a
Linux imdalapp300b 2.6.5-7.314-smp #1 SMP Mon Sep 15 16:43:00 UTC 2008 i686 athlon i386 GNU/Linux
# cp /usr/src/linux-2.6.5-7.314-obj/i 386/smp/scripts/modpost /usr/src/linux-2.6.5-7.314
Now you can run again “vmware-config-tools.pl”
90/433
Add a VCS hagui admin user to your cluster
To add an hagui admin user you do:
# haconf -makerw
# hauser -add rdircio
# hauser -addpriv rdircio Administrator
# haconf -dump -makero
103/433
Call progress for dahdi calls in asterisk-java
I wanted to generate a call from a script, and deliver a voice message, through a DAHDI channel, to a pots line.
This class does it, it tells you in the end if the line was busy, if it was never answered or if the call succeeded.
This is, if you trust dahdi callprogress, which is really broken… this example works better for SIP calls.
import org.asteriskjava.live.AsteriskChannel;
import org.asteriskjava.live.DefaultAsteriskServer;
import org.asteriskjava.live.LiveException;
import org.asteriskjava.live.ManagerCommunicationExcept ion;
import org.asteriskjava.live.OriginateCallback;
import org.asteriskjava.manager.action. OriginateAction;
import org.asteriskjava.util.Log;
import org.asteriskjava.util.LogFactory;
public class AsteriskCall implements OriginateCallback {
private final Log logger = LogFactory.getLog(getClass());
private DefaultAsteriskServer asteriskServer = null;
private String strChannelStatus = “NoStatusYet”;
private String number=””;
private String message=””;
public AsteriskCall() {
this.asteriskServer = new DefaultAsteriskServer(“somewhere.org”,”admin”,”mypass”);
}
public OriginateAction setupOriginate(String number,String message) {
OriginateAction originateAction = new OriginateAction();
originateAction. setChannel(“DAHDI/1/”+number);
originateAction. setApplication(“Playback”);
originateAction. setData(message) ;
originateAction. setActionId(number);
originateAction. setAsync(Boolean.TRUE);
originateAction. setTimeout(new Integer(30000));
return originateAction;
}
public void originate() {
OriginateAction originateAction = this.setupOriginate(number,message);
// System.out.println(“————— Calling: “+originateAction.getChannel()+”, Sending:
“+originateAction.getData());
try {
this.asteriskServer.originateAsync(originateAction, this);
}
catch (ManagerCommunicationException e) {
logger.error(“ManagerCommunicationException”);
}
15/433
Boolean out=false;
String previousStatus=””;
while(!out) {
if
(this.strChannelStatus.equals(“Busy”)||this.strChannelStatus.equals(“Success”)||this.strChannelStatus.equals(“No
Answer”)||this.strChannelStatus. equals(“Failed”) ) {
out=true;
}
try {
String currentStatus=this.strChannelStatus;
if (!currentStatus.equals(previousStatus)){
logger.info(“Current Channel State: “+currentStatus) ;
previousStatus=currentStatus;
}
Thread.sleep(1000);
}
catch (InterruptedException e) {
logger.info(“Interrupted.”);
}
}
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
logger.info(“Final Verdict: “+this.strChannelStatus);
}
@Override
public void onBusy(AsteriskChannel channel) {
this.strChannelStatus = “Busy”;
}
@Override
public void onDialing(AsteriskChannel channel) {
this.strChannelStatus = “Dialing”;
}
@Override
public void onFailure(LiveException cause) {
this.strChannelStatus = “Failed”;
}
@Override
public void onNoAnswer(AsteriskChannel channel) {
this.strChannelStatus = “No Answer”;
}
@Override
public void onSuccess(AsteriskChannel channel) {
this.strChannelStatus = “Success”;
}
public void setNumber(String n){
16/433
number=n;
}
public void setMessage(String m){
message=m;
}
public static void main(String[] args) throws Exception {
if (args.length<2){
System.out.println(“Usage: Call <number> <message>”);
System.exit(1);
}
AsteriskCall call = new AsteriskCall();
call.setNumber(args[0]);
call.setMessage(args[1]);
call.originate() ;
}
}
17/433
What to do when hpacucli is locked but there is no process for it
# hpacucli
HP
Array Configuration Utility CLI 7.50.18.0
Detecting Controllers…
Error:
Another instance of ACU is already running (possibly a service). Please
terminate the ACU application before running the ACU
CLI.
# ps -ef | grep -i
acu
root 26127 11377 0 15:12 pts/3 00:00:00 grep -i
acu
go to /opt/compaq/cpqacuxe/bld/locks and remove all the files in that directory, then run hpacucli
Thanks to Justin Lim
83/433
Performance charts
I made some performance charts from the output of sar and custom scripts, check them out!
http://www.kraftek.com/perf/
The source is in
http://www.kraftek.com/perfsrc/
open flash chart
and my own php/ksh scripts.
48/433
Physical PCI card position in sunfire E12k/E15k/E20k/E25k
if you need to know where, for instance is “qfe0” in your e25k, so someone can connect a cable there… you can use sun
doc #202571, which i have transformed to a script called “pos.ksh”:
#!/bin/ksh
echo “Expander Slot Device”
grep pci /etc/path_to_inst |while read nic;do
A=`echo $nic | awk -F”@” ‘{ print $2 }’ | awk -F”,” ‘{print $1}’`
O=`echo $nic | awk -F”,” ‘{print $2}’| awk -F”/” ‘{ print $1 }’`
T1=`grep ” $A” t1.txt`
E=`echo $T1 | awk ‘{ print $2 }’`
C=`echo $T1 | awk ‘{ print $1 }’`
S=`grep “^$C…$O” t2.txt | awk ‘{ print $2 }’`
echo “$E $S $nic”
done
You will need t1.txt:
IOC Expander AgentID
0 0 1c(28)
1 0 1d(29)
0 1 3c(60)
1 1 3d(61)
0 2 5c(92)
1 2 5d(93)
0 3 7c(124)
1 3 7d(125)
0 4 9c(156)
1 4 9d(157)
0 5 bc(188)
1 5 bd(189)
0 6 dc(220)
1 6 dd(221)
0 7 fc(252)
1 7 fd(253)
0 8 11c(284)
1 8 11d(285)
0 9 13c(316)
1 9 13d(317)
0 10 15c(348)
1 10 15d(349)
0 11 17c(380)
1 11 17d(381)
0 12 19c(412)
1 12 19d(413)
0 13 1bc(444)
117/433
1 13 1bd(445)
0 14 1dc(476)
1 14 1dd(477)
0 15 1fc(508)
1 15 1fd(509)
0 16 21c(540)
1 16 21d(541)
0 17 23c(572)
1 17 23d(573)
and t2.txt
IOC Slot Offset
0 0 600000
0 1 700000
1 2 600000
1 3 700000
So basically, inside any given domain you can do:
#./pos.ksh > slotmap.txt
then, if you want to know where your Quad Fast Ethernet “qfe” cards are, you can do:
bash-2.03# egrep “qfe|Expander” slotmap.txt
Expander Slot Device
2 3 “/pci@5d,700000/pci@1/SUNW,qfe@0,1” 0 “qfe”
2 3 “/pci@5d,700000/pci@1/SUNW,qfe@1,1” 1 “qfe”
2 3 “/pci@5d,700000/pci@1/SUNW,qfe@2,1” 2 “qfe”
2 3 “/pci@5d,700000/pci@1/SUNW,qfe@3,1” 3 “qfe”
17 3 “/pci@23d,700000/pci@1/SUNW,qfe@0,1” 4 “qfe”
17 3 “/pci@23d,700000/pci@1/SUNW,qfe@1,1” 5 “qfe”
17 3 “/pci@23d,700000/pci@1/SUNW,qfe@2,1” 6 “qfe”
17 3 “/pci@23d,700000/pci@1/SUNW,qfe@3,1” 7 “qfe”
And you’ll find out you have 2 quads, one is at IOBoard 2 slot 3, the other is at IOBoard 17 slot 3
A typical IOBoard has 4 slots, numbered from 0-3,
|—–|—–|
| | |
| slot|slot |
| 3 | 1 |
| | |
| | |
|—–|—–|
| | |
| | |
| slot|slot |
| 2 | 0 |
| | |
|—–|—–|
118/433
So Both cards are at the upper left, one on IOBoard 2 the other on IOBoard 17
Qfe0 is at IOBoard 2 slot 3
119/433
grub possible boot disks
If you get obfuscated about grub’s disk device numbering, in the grub prompt you can do:
“root (” + tab
like:
grub > root ( <press the tab key>
Possible disks are: fd0 hd0 hd1
77/433
non-root sessions with vnc for solaris sparc from sunfreeware
When you want to run a vncserver session on a non-root user from a solaris sparc machine, it just ends with this
message:
_XSERVTransSocketCreateListener: failed to bind listener
After going around some places i found something to fix this at
http://www.webservertalk.com/archive100-2004-2-131777.html
That involves creating a script in /usr/bin/fixXdir.ksh and putting it at the crontab, like this:
#!/usr/bin/ksh
PATH=”
IFS=’ ‘
ice_dir=/tmp/.ICE-unix
x11_dir=/tmp/.X11-unix
for dirname in $ice_dir $x11_dir
; do
{
if (! [ -d $dirname ] )
then
/usr/bin/mkdir $dirname
if [ $? != 0 ];
then
/usr/bin/echo “Warning: $0: cannot
mkdir $dirname.”;
fi
fi
if ([ -d $dirname ] )
then
/usr/bin/chown root:root $dirname
if [ $? != 0 ];
then
/usr/bin/echo “Warning: $0: cannot chown $dirname.”;
fi
/usr/bin/chmod 1777 $dirname
if [ $? != 0 ];
then
/usr/bin/echo “Warning: $0: cannot chmod $dirname to 1777.”;
fi
fi
}
done
289/433
The crontab line is this:
0,5,10,15,20,25,30,35,40,45,50,55
/usr/bin/fixXdir.ksh
290/433
recursive scripting in bash
Needed to rename all directories and files in a deep directory structure to remove spaces and ugly characters in their
names, in order to build a playlist, take a look at this recursive bash shell:
#!/usr/bin/bash
DIR=/200gb/MP3
FTYPE=mp3
renamedir ()
{
cd
find . -type d -maxdepth 1 -name “??*” | while read d; do
DN=`echo “$d” | sed “s/&/And/g;s/-//g;s/ //g;s/(//g;s/)//g;s/[/
/g;s/]//g;s/’//g” | tr -s ‘_’`
if [ “$d” != “$DN” ];then
echo “— `pwd` $d”
mv “$d” $DN
fi
renamedir
$DN
cd ..
done
}
echo ” —- Recursively clean directories”
renamedir $DIR
echo ” —- Now clean files”
cd $DIR
find . -type f -iname “*.$FTYPE” | while read f;do
FN=`echo “$f”| sed “s/&/And/g;s/-//g;s/ //g;s/(//g;s/)//g;s/[//g;s/]/
/g;s/’//g” | tr -s ‘_’`
if [ “$f” != “$FN” ];then
echo “— $f”
mv “$f” $FN
fi
done
echo “done.”
197/433