Archive for July, 2008

AIX TL and hardware (Documentum 5.3 friendly)

IBM Technology levels are obtained by using

oslevel

with no params tells you the version of AIX.  (For Documentum it should be at least 5.2 currently).

oslevel -q -s

Will give a lengthy list of service packs and the technology level.

Example:

$ oslevel -q -s
Known Service Packs
——————-
5300-07-04-0818
5300-07-03-0811
5300-07-02-0806
5300-07-01-0748
5300-06-07-0818
5300-06-06-0811
5300-06-05-0806
5300-06-04-0748
5300-06-03-0732
5300-06-02-0727
5300-06-01-0722
5300-06-01-0000
5300-06-00-0000
5300-05-CSP-0000
5300-05-06-0000
5300-05-05-0000
5300-05-04-0000
5300-05-03-0000
5300-05-02-0000
5300-05-01-0000
5300-04-CSP-0000
5300-04-03-0000
5300-04-02-0000
5300-04-01-0000
5300-03-CSP-0000

$ oslevel -s
5300-06-07-0818

Which is AIX 5.3 TL6 SP7

Systems running Documentum include

$ oslevel  -s
5300-06-00-0000

Which is AIX 5.3 TL6  No SP
prtconf

will tell you the cpu, network and other information. Abbreviated example below:

$ prtconf
System Model: IBM,9117-570
Machine Serial Number: 65045F0
Processor Type: PowerPC_POWER5
Number Of Processors: 2
Processor Clock Speed: 1900 MHz
CPU Type: 64-bit
Kernel Type: 64-bit
LPAR Info: 5 manch0010
Memory Size: 4096 MB
Good Memory Size: 4096 MB
Platform Firmware level: Not Available
Firmware Version: IBM,SF240_320
Console Login: enable
Auto Restart: true
Full Core: false

At time of writing it is believed (by me) TL05 is out of support from IBM.

Leave a Comment

mysql 5 trigger upgrade

Mysql triggers are not the best in the world and it seems you can’t call something external from the db – like, for example, running a script.

Well, I needed to know if an update had occurred on a table and to fire off a remote command to another server.

The solution was:

1. Add a field to the table called action – default it to NULL
2. Perl script to check the table for rows which contained default=NULL
3. If such a row existed then do some file system action
4. Update the table so that action is no longer null
5. Make the whole thing reliable

Step 1. Create a shell script

check_relay.sh
#!/bin/bash
echo “running application”;
while [ 1 ]; do
echo “running”
perl /home/user/relay2.pl
sleep 3
done

2. create a perl script to query the db table we spoke off earlier (relay2.pl – in my app)

my $database = ‘relay’;
my $host = ‘localhost’;
my $user = ‘relay_user’;
my $pass = ‘relay_pass’;
my $dbh = DBI->connect(“DBI:mysql:database=$database;host=$host”,”$user”,”$pass”) or die “Can’t open DB: $!”;
my $sth = $dbh->prepare(q{SELECT tr_id, actioned FROM relay where actioned is null});
$sth->execute() or die $dbh->errstr;
my $actioned;
my $tr_id; # should use a transaction id so you know which row was updated in case there is more than one.
$sth->bind_columns(\$actioned,\$tr_id);

while($sth->fetch()) {
#here we do stuff on the os, e.g. system(“php ./relay2.php $field_from_db_etc”);
#now update the db so the row no longer requires a trigged type event
my $newQ2 = “UPDATE transactions SET actioned =true WHERE tr_id=$tr_id”;
my $sth3 = $dbh->prepare($newQ2);
$sth3->execute() or die $dbh->errstr;
$sth3->finish;
}
$sth2->finish;
}
$sth->finish;
$dbh->disconnect;

3. create a perl script to check the process is actually running (which it wont be unless you ran it by hand)

#!/usr/bin/perl
open PROS, “ps -ef|grep check_relay.sh |”;
while ($line = <PROS>){
unless ($line =~ m/grep/){
#print “is already running\n”;
exit;
}
}
print “check_relay was not running. Trying to start it.\n”;
exec ‘nohup /home/user/./check_relay.sh &’;
4. Make sure the damn thing boots up about 60 seconds after the system starts and check it is still running every 60 seconds.

Edit cron for the user under which this script will run -

(crontab -e)

* * * * * /home/user/ps_check.pl

If you have done everything right then kill the process and see that it launches again within 60 secs which is the resolution of cron.

Obviously make sure mysql is configured to autostart at the correct run levels if the machine is booted up.

(if I remember correctly on centos, chkconfig mysqld on –level 35)

Comments (1)

ImageMagick Annotate/Watermark/Add text to graphic image

Where logo_01.jpg is the source image.
The output image is out.jpg
The text put on is 12345
The font was installed on the system by default and standard TTF which can be found with a basic search FS.

convert logo_01.jpg -fill ‘#0008′ -draw ‘rectangle 5,128,114,145′ -font /usr/share/fonts/bitstream-vera/Vera.ttf  -fill white   -annotate +10+141 ‘12345′ out.jpg

Leave a Comment