Wednesday 4 May 2011

Installing Clearcase/Clearquest on Ubuntu 10.04

Just a couple of pointers if you ever need to install CC/CQ 7.1.2.02  on ubuntu 10.04.
First and foremost, their instructions for installing CC on a 64 bit system are missing a vital step. They tell you to install the 32 bit compat libraries (fair enough) and libstdc++5 amongst other things. Well, libstdc++5 is no longer available with 10.04 so they messed up there (and their binaries are built against it). Just follow the instructions at http://www.hackourlife.com/ubuntu-10-04-lucid-lynx-libstdc-so-5/ for how to get around the problem. Easy enough really.
Now, CQ. Set up your repositories from the IBM Installation manager with the patch as well but there are a few issues you’'ve got to be aware of. Firstly, the install fails because it can’t install gsk7bas-7.0-4.11.i386.rpm. Well, it’s a debian system so that would be correct.
Anyway, it does come with rpm but you have got to make sure you do a …...
sudo rpm –rebuilddb

first. That still won'’t get you out of the woods as installing an rpm on ubuntu/debian requires the use of –--force-debian
So ...
sudo bash
cd /usr/bin
mv rpm rpm.real
cat > rpm << EOF
#!/bin/bash
# Wrapper script to force RPM installs on Debian based systems
/usr/bin/rpm.real --force-debian $*
EOF
chmod 755 rpm
 
and then try the install again.
Well, it seems to work, but I can’t tell until I have a license server :)

Thursday 21 April 2011

Re-installing vmware modules on linux

This took me a little while to find. If you start up vmplayer after a reboot and the vmware kernel modules are missing viz. not loaded, the easiest way to solve this is :-

sudo vmware-modconfig --console --install-all

You should get something like ...

Stopping VMware services:
   VMware USB Arbitrator                                               done
   VM communication interface socket family                            done
   Virtual machine communication interface                             done
   Virtual machine monitor                                             done
   Blocking file system                                                done
Installed vmmon pre-built module
Installed vmnet pre-built module
Installed vmblock pre-built module
Installed vmci pre-built module
Installed vsock pre-built module
Starting VMware services:
   VMware USB Arbitrator                                               done
   Virtual machine monitor                                             done
   Virtual machine communication interface                             done
   VM communication interface socket family                            done
   Blocking file system                                                done
   Virtual ethernet                                                    done
   Shared Memory Available                                             done


Changing the username, UID and GID default rules on linux

I always forget this one but certain companies I work for have a username, UID standard which doesn't comply with the POSIX norm.
I've seen several people on forums saying they have hacked the tools to accomplish this but there is no need. Just edit /etc/login.defs

BTW, to see what files useradd looks at, just use :-

strace -e trace=file useradd somebody

Forcing ethernet duplex and speed during startup on linux (Suse)

a) Modify /etc/sysconfig/network/config file to have
  following options set to 'yes'.

GLOBAL_POST_UP_EXEC="yes"
GLOBAL_PRE_DOWN_EXEC="yes"

b) Create a script file (E.g, ethtool-settings) in
  /etc/sysconfig/network/if-up.d directory with required ethtool commands.

E.g, the file can contain the following ethtool command -

  /usr/sbin/ethtool -s ethX speed 10

c) Set the mode of the file to 755.
#chmod +755 ethtool-settings

Converting java JKS key store DER format to PEM

openssl x509 -out ca.pem -outform pem -text -in ca.der -inform der

after extracting using keytool obviously.

Also see http://mark.foster.cc/kb/cacert-keystore-extraction.html

Syncing a clearcase view with a changed stream

cleartool chstream -gen viewname
cleartool setcs -stream

Using tcpdump and iptrace on AIX

tcpdump -s 0 -i en1 -n tcp port 8766 and ip proto \\tcp and ip host nodename1 and nodename2 > 8766-2.tcpdump

iptrace -a -i en2 -b -d nodename1 -p 22 /tmp/22iptrace.out

For iptrace, you have to kill -15 to end the trace. iptrace output is usable in wireshark/ethereal.

Creating a new perl module

Use something like :-

h2xs -X IB::Soap

AIX CPU Information

Any of the following:
lsdev -Ccprocessor | grep -ci available

lparstat -i | grep "Online Virtual CPUs"
Online Virtual CPUs : x

The following will tell you what the specification is...
lsattr -El proc0

Wednesday 20 April 2011

41 and an era

8 track. Remember that? I do. My dad was a mechanic and a music enthusiast. More to the point, he was country mad. That's what made him having Queen's greatest hits on it even harder to believe! I was 4 - or 5, or even maybe older. Who cares. It was a time of music revolution. We were all encouraged to learn an instrument.. Get involved. So we did. Top of the pops reigned. MTV was non existent. We remembered ABBA. Boney M was brilliant. B sides were as good as the A. Then cassettes came. Duran Duran. OMD. Depeche Mode. Dire Straits. Your brother gets a job and buys you Simple minds. Life would change forever. You miss Queens last ever live gig because you were too young. For the one split second in your life, you hate your mother. You state that when you are older, you will buy every single going. Then CDs happen. And you buy all your best albums all over again. The pixies turn up, and the Smiths, and you buy the Springsteen live double album all over again. Then your tape of Alchemy Live finally can't take any more patching so you buy the CD. Your collection is pretty awesome so you decide that you've had enough and live music is the way to go - for quite some time. Many beers later, you come out of your shell and realise that, once again, all the rules have changed. MP3 is what the game is all about. But wait, apparently, some sneaky b has stolen a quick one and started charging you for having what you already own in some new digital format, which isn't even as good as the one you have! Sod him. Let's try OGG or FLAC or whatever it is they call it. Sod this. Live is the way to go again. Steve comes along and convinces the masses that iTunes is really what is needed. Hmm, ok, fed up with all this fragmentation. After all, Coldplay is the only thing that has changed since Belfast Child - or is that the same? But wait, Sergey has a different view ...
Now, I've got a phone that can do the lot - except it's still not the same as seeing them live. Different skin, same purpose. True to life really ...

Tuesday 29 March 2011

All things mod_gsoap

Well, the documentation in gsoap itself and even the internet is non existent for using gsoap as an apache module. Hopefully, this entry might make it a little less painful for those wanting to give it a go.

I have built this on Ubuntu 10.10 but this example is using SLES11. It really shouldn't matter much as long as you have a proper development toolchain installed on your flavour of distro. You may have to explicitly add a -fPIC to the build, but we'll come to that later.
I've also done this on AIX 5.3L

I always find that the best way to try anything like this out is to build all components from scratch so you know exactly what you are looking at. For the purpose of this exercise, you need to download a recent version of apache http server and gSOAP.
We are going to build these under a testuser account (/home/testuser) but substitute your own if you like.

cd /home/testuser
mkdir apachegsoap
cd apachegsoap
tar -xjf httpd-2.2.17.tar.bz2
cd httpd-2.2.17
./configure --prefix=/home/testuser/apachegsoap --with-mpm=worker --enable-mods-shared=most


There are all sorts of ways of configuring apache, but I am sticking to a simplistic model just to show you how mod_gsoap works.

make -j4; make install (or whatever your machine supports)

Now, we are going to build gsoap.

cd ..
tar -xzf gsoap_2.8.1.tar.gz
cd gsoap-2.8

./configure --prefix=/home/testuser/apachegsoap --enable-debug --disable-samples CFLAGS=-fPIC CXXFLAGS=-fPIC
make; make install

We now need to build mod_gsoap and have it installed in the apache modules directory. It's probably a good idea (but not necessary) to copy the header file to your include directory to make module building easier later on. This is as simple as :-

cd gsoap/mod_gsoap/mod_gsoap-0.6/apache_20
/home/testuser/apachegsoap/bin/apxs -a -i -c -I /home/testuser/apachegsoap/include mod_gsoap.c
cp apache_gsoap.h /home/testuser/apachegsoap/include

This adds the LoadModule directive for mod_gsoap to /home/testuser/apachegsoap/conf/httpd.conf and we will look at what other configuration we need to do after we build our example service.
We are going to use the calculator example that comes with gsoap to build a service under apache and call it from the gsoap client. mod_gsoap works by dynamically loading your own gsoap module and calling the appropriate entry points from there. We need to modify calcserver.c to use the mod_gsoap hooks instead of having a main().

cd gsoap/samples/calc

Remove the main() function entirely and replace with :-

#include "apache_gsoap.h"
IMPLEMENT_GSOAP_SERVER()

The easiest way of building our own module is to use apxs again, but first, we must use the gsoap toolkit to generate our stubs and headers.

/home/testuser/apachegsoap/bin/soapcpp2 -c calc.h
/home/testuser/apachegsoap/bin/apxs -a -c calcserver.c soapC.c soapServer.c -lgsoap

If you have installed anything in some other directories, you will need to add appropriate -I and -L directives for the above. Because we didn't tell apxs to install the shared library (-i), it will reside in a seperate .libs directory where you are now.
viz. /home/testuser/apachegsoap/gsoap-2.8/gsoap/samples/calc/.libs
That is good enough for our purposes. You will also notice that we have linked in the libgsoap.a archive which is necessary. gsoap does not build as a shared library by default and I won't go into detail here about how to do this.

To build the test client, we first need to modify the endpoint it will talk to. This will be our new apache instance. I would recommend for testing that we change the Listen directive in httpd.conf to use something like 9080 instead of the default port 80 to save us having to start the service with a priviledged user. Edit calcclient.c and change the server definition to :-

const char server[] = "http://localhost:9080/soap";

Building it is just a matter of :-

gcc -I /whome/testuser/apachegsoap/include -L /whome/testuser/apachegsoap/lib -o calcclient calcclient.c soapC.c soapClient.c -lgsoap

Now we have our calcserver.so, we can go ahead and setup our httpd.conf to finalise our test service. We are going to add to the end

<IfModule mod_gsoap.c>
<Location /soap>
SetHandler gsoap_handler
SOAPLibrary /home/testuser/apachegsoap/gsoap-2.8/gsoap/samples/calc/.libs/calcserver.so
Order allow,deny
Allow from all
</Location>
</IfModule>


This is a very open configuration and is only here for ease of use for the example.

Remember, the LoadModule directive was already added earlier. We are now in a position to start up our service and give it a test.

/home/testuser/apachegsoap/bin/apacectl start

You should now be able to point your browser to http://localhost:9080 and get the default index page with It works! displayed.
If this is all in order, we should now be able to execute of calcclient test program and get some results.

/home/testuser/apachegsoap/gsoap-2.8/gsoap/samples/calc/calcclient add 2 5
result = 7


You now have a starting point to writing your own soap modules!!

However, it would be cruel of me to write this and not give a quick pointer on how to debug the thing. We really need to stop the service and start it up in single threaded mode so we can attach to it using a debugger. You can either use gdb on the command line, ddd or any other front end to your particular debugger. I'll use gdb for this example.

/home/testuser/apachegsoap/bin/apacectl stop
/home/testuser/apachegsoap/bin/httpd -X -f /home/testuser/apachegsoap/conf/httpd.conf &

Now, using the pid reported back from this, attach to it with gdb :-

gdb /home/testuser/apachegsoap/bin/httpd 25487

You will see a load of symbols loading, include mod_gsoap.so. Set a breakpoint on the soap_serve call (the main entry point), say yes to accepting a pending breakpoint, continue and then execute our calcclient from another window.

(gdb) b soap_serve
Function "soap_serve" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (soap_serve) pending.
(gdb) c
Continuing.

When you execute the calcclient, you should get gdb stopping at that breakpoint. Off you go!

[Switching to Thread 0x7f3fbd209950 (LWP 25493)]

Breakpoint 1, 0x00007f3fb059e398 in soap_serve () from /home/testuser/apachegsoap/gsoap-2.8/gsoap/samples/calc/.libs/calcserver.so
Current language: auto; currently asm
(gdb) n
Single stepping until exit from function soap_serve,
which has no line number information.
0x00007f3fb05a5eec in apache_default_soap_serve () from /home/testuser/apachegsoap/gsoap-2.8/gsoap/samples/calc/.libs/calcserver.so
(gdb)

If you do this under an installed instance of apache running as user wwwrun or something, you will have to execute the debugger as that user. Just use something like :-

sudo -u wwwrun gdb /usr/sbin/httpd2-worker 25487

instead.I hope that people find this short tutorial informative as it is maddening getting this to work the first time. The documentation on it is woeful, which is a shame, as the standard of documentation for gSOAP in general is excellent. The mod_gsoap module itself is lacking in several areas but, hopefully, I'll be able to post something here in the near future which will show you how to use it for more production like environments.