Archive for July, 2011

Small perl mechanize script to send sms from danish telco provider Bibob

Thursday, July 28th, 2011

It can be handy to send sms’es from scripts. In old time you could do that in Telia by sending a mail to <mobile number>@gsm1800.telia.dk. But that service was closed. Now that I am leaving Telia in favor of Bibob I saw that they had a websms service.

And so I combined their fine web service with my perl scripting skillz. The script can be downloaded here

Do not forget the agreement between you and bibob. You are only allowed to use the websms service (and thus this script) for personal use. I am not to blame if bibob closes your bibob account because you spam-smsed a lot of people.

The code is also included here:

 

#!/usr/bin/perl -w

#####################################################################
#
# File:         bibob_sms.pl
# Type:         bot
# Description:  Send an SMS using bibob websms and perl mechanize
# Language:     Perl
# Version:      1.0
# License:      BeerWare – Thomas S. Iversen wrote this file.
#               As long as you retain this notice you can
#               do whatever you want with this stuff.
#               If we meet some day, and you think this stuff is
#               worth it, you can buy me a beer in return. Thomas
#
# History:
#               1.0 – 2011.07.28 – Intial version
#
# (C) 2011 Thomas S. Iversen (zensonic@zensonic.dk)
#
#####################################################################

use strict;
use WWW::Mechanize;
use File::Basename;

# Variables controlling bot behaviour

my $sms_url=‘https://www.bibob.dk/bibob/bibob?cmd=websmssender’;
my $login_url=‘https://www.bibob.dk/bibob/bibob?cmd=loginFrame’;

my $script=basename($0);
die "$script <bibob mobile number> <bibob password> <recipeient number> <message>" if(!($#ARGV+1 == 4));

my $username=$ARGV[0];
my $password=$ARGV[1];
my $recipients=$ARGV[2];
my $message=$ARGV[3];

#
# You should not need to alter anything below this line
#

#
# Main code.
#

# Create mechanize instance
my $mech = WWW::Mechanize->new( autocheck => 1 ); #Create new browser object
$mech->agent_alias( ‘Windows IE 6′ ); #Create fake headers just in case
$mech->add_header( ‘Accept’ => ‘text/xml,application/xml,application/xhtml\+xml,text/html,text/plain,image/png’ );
$mech->add_header( ‘Accept-Language’ => ‘en-us,en’ );
$mech->add_header( ‘Accept-Charset’ => ‘ISO-8859-1,utf-8′ );
$mech->add_header( ‘Accept-Language’ => ‘en-us,en’ );
$mech->add_header( ‘Keep-Alive’ => ’300′ );
$mech->add_header( ‘Connection’ => ‘keep-alive’ );

# Get login page
$mech->get($login_url);
$mech->success or die "Can’t get the login page";

# Submit the login form with username (mobilnumber) and password
$mech->submit_form(with_fields => { ‘loginmsisdn’ => $username, ‘login-password’ => $password });
$mech->success or die "Could not login";

# Get sms page
$mech->get($sms_url);
$mech->success or die "Could not get sms page";

# Send sms by submitting sms form
$mech->submit_form(with_fields => { ‘recipients’ => $recipients, ‘message’ => $message });
$mech->success or die "Could not send sms";

# Figure out status
my $html = $mech->content();
die "Form submitted, but message does not appear to be sent" if(!$html=~/Beskeden blev afsendt/ig);

exit 0;

Upgrading OBP and ALOM on a SunFire v210/v240

Sunday, July 24th, 2011

Recently I got my hands on a piece of oldish SUN equipment (SunFire V210/V240). It was in an ok condition. Not perfect, but still usable and I will be able to fix the smaller issues.

One of the issues was the really really old OBP and ALOM installed. In this post I will show how to upgrade OBP and ALOM. The key thing to remember is to

  1. Read ALL the attached readmes and whats not.
  2. Make sure ALL dependencies are met
  3. Upgrade the OBP before you upgrade the ALOM

And as usual. If you break your stuff following this post, then sorry but I can and will not be held responsible for anything you do. It worked for me. If it works for you, great. If it doesn’t, then tuff luck.

With that out of the way lets get started. First we need to obtain the ALOM and OPB patch. As a private person you might have a hard time getting hold of these files without an active support contract with oracle. I know I had. Mail  me if you run out of luck. You will need

  • 142700-02.zip – OBP 4.30.0
  • ALOM_1.6.10_fw_hw0.tar.gz – ALOM 1.6.10

Below is the raw output of the upgrade so you can see how it is done. OBP first

**** While in the OS download and unpack the OBP firmware

# wget http://someserver/142700-02.zip

# unzip 142700-02.zip

# cd 142700-02

# cp flash-update*  /

# chmod 755 /flash-update*

# halt

**** From the OBP prompt issue

ok boot disk /flash-update-SunFire240

Firmware Release(s)                Firmware Release(s)
Currently Existing in the System      Available for Installation  /  Install?
———————————- ——————————————-
OBP 4.11.4 2003/07/23 08:04        OBP 4.30.0 2010/01/06 14:48          YES
POST 4.30.4 2010/01/06 15:10         YES

Type sa if you wish to select all available firmware releases for
installation.  Type h for help, quit to exit, or cont to continue: cont

The Flash programming process is about to begin.
Type h for help, q to quit, Return or Enter to continue:

Erasing the top half of the Flash PROM.
Programming OBP into the top half of the Flash PROM.
Verifying OBP in the top half of the Flash PROM.

Erasing the top half of the Flash PROM.
Programming POST into the top half of Flash PROM.
Verifying POST in the top half of the Flash PROM.
Programming was successful.

SC Alert: Host System has Reset
SC Alert: Host System has read and cleared bootmode.

Configuring system memory & CPU(s)
Probing system devices
Probing memory
NOTICE: Initializing security keystore
Probing I/O buses

Sun Fire V210, No Keyboard
Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
OpenBoot 4.30.4.a, 4096 MB memory installed, Serial #57866961.
Ethernet address 0:3:ba:72:fa:d1, Host ID: 8372fad1.

NOTICE: Updating OpenBoot NVRAM diagnostic configuration variables..
diag-script =  normal
diag-trigger =          error-reset power-on-reset
diag-level =            max
verbosity =             normal
service-mode? =         false
auto-boot-on-error? =   true
error-reset-recovery =  sync

Your OBP is now updated. Now to the ALOM. From the OS

# firmware

# /usr/platform/`uname -i`/sbin/scadm version

SC Version v1.3
SC Bootmon Version:  v1.3.0
SC Firmware Version:  v1.3.0

# /usr/platform/`uname -i`/sbin/scadm download boot alombootfw
……………….. (100%)
Download completed successfully

Please wait for verification

…………
Complete

# sleep 60
#  /usr/platform/`uname -i`/sbin/scadm version

SC Version v1.3
SC Bootmon Version:  v1.6.10
SC Firmware Version:  v1.3.0

# sleep 120
#  /usr/platform/`uname -i`/sbin/scadm version

SC Version v1.6
SC Bootmon Version:  v1.6.10
SC Firmware Version:  v1.6.10

You ALOM is now updated. Nothing fancy really.

Debugging ‘Unsupported authentication scheme ‘ntlm” errors while using Perl WWW::Mechanize

Thursday, July 21st, 2011

Recently I got a really boring task of performing the same task over and over again … in a GUI. Obviously I am waaay to lazy for that (and bright enough to figure out how big a waste of time that is).

In an instance I fired up vi and started to hack together a little perl script using WWW::Mechanize to do all the work for me. I quickly ran into problem …. I got ‘Unsupported authentication scheme ‘ntlm” errors when trying to fetch the pages.

I played around quite some time before I realized that i missed the Authen::NTLM module. I had the LWP::Authen/Ntlm and that tricked me for quite some time. I was down to a simple script that just had

#!/usr/bin/perl -w
use LWP::Authen/Ntlm;

Before I could see that I missed Authen::NTLM. Once I had that downloaded and installed, things started to work as expected.

Reducing RHEL5 idle cpu usage under esx

Tuesday, July 5th, 2011

Today I installed two RHEL5 servers on my ESXi rig. To my surprise they idled at around 300MHz?! My Debian 6.0 based server and my Win2k3 based server idles at around 50MHz, sowhat was the problem?!

Looking inside the vm showed that the vm was idle. So what was going on here? I tried to use vmxnet3 instead of E1000. I tried to stop a lot of services. To no avail.

It turns out that it is the frequency of the context switches. Edit /etc/grub.conf and add divider=10 to the ‘kernel’ line and reboot the beast. Usage will drop to sane levels!

Replacing a fuse on an Vaillant Ecotec gasburner

Monday, July 4th, 2011


Last night a big thunderstorm hit my home.

Ligtning hitting Sealand Denmark

During the storm a lightning actually hit the house/so close to the house that it went into the electrical system. Luckily the legislation about electricity in danish households requires that electricians installs HPFI and thermo fuses, so after the a white spark out of a wall plug, the HPFI and thermo fuses kicked in and took down the whole system.

…. or so I thought. The lightning had actually been fast enough to hit the control unit of my Gas Boiler – It would not turn on this morning to heat water for the day.

This post will show how to open a vaillant ecotec gasboiler and exchange the fuse(s).

<DISCLAIMER>

Turn off your boiler before doing anything. Disconnect it from the wall plug. Use original fuses. If in doubt – STOP! Do not tamper with the Gas part of the heater! If the fuse blows again, do NOT substitute with something that can not blow! Do call an qualified repair man if that happens!

And finally: if you blow up yourself and/or your house/friends/families/dogs/whatever I can not be held responsible! Do not trust a stranger on the internet just because you are trying to save a few bucks!

Safety before anything else!

</DISCLAIMER>


With the disclaimer out of the way, lets get going. First locate the front of your boiler. It will look like this.

 

The front of the boiler is held in place by one screw on the bottom:

 

Remove the screw with a screwdriver

 

Remove the front by pulling outwards after you have ‘unclipped’ it (there are two clips to secure it besides the screw)

 

You should now be able to look inside the boiler. If you are unsecure, stop. Remember the disclaimer!

 

Grab the to white, apply pressure and pull down the control unit like this:

 

Now we are going to open up the control unit.

 

Locate the fuses:

 

Exchange the fuses. On the vaillant you have two spare fuses on the inside of the control unit:

Assemble the whole lot back and turn on the boiler again. Hopefully it will come back to life. If it doesn’t something is seriously wrong – call an vaillant approved repair man.

And …. do not forget to order a new fuse right away!