Baltic cruise: Tallinn

Another day, another country. Today we are in Tallinn, Estonia.

Despite being quite far North and, you’d expect, quite cold, the climate was almost Mediterranean while we were there. The locals said it was freakishly hot and they never had weather like this. The sky was clear and blue and the sun was beating down.

In the port, there was a small market set up, mainly selling tourist novelties. The trademark gift seems to be palm-sized porcelain houses; some with a place to put incense so smoke comes from the chimney. But there was a large variety of different gifts, which was a refreshing change from some of the tourist markets we’d seen in other countries, where every stall had near-identical copies of precisely two varieties of gift.

This photo was taken from the dock market. You can’t really comprehend how huge these ships are until you walk between them.

MSC Ocean & MS Jewel of the Seas

It was only a short walk to reach the old town, which has a strange medieval feel and cobbled streets. For some reason, this building has a Swedish flag.

A building in Tallinn

Only a few steps away from the building above, I saw this colourful door.

A painted door

Minutes later, we reached the town square, Raekoja plats. There is a lively market here, and an imposing town hall (although behind the camera in this photo).

Tallinn square

I still can’t work out what this shop sells. Textiles, glass, ceramics, and err, schmuck?

Art shop

The old town in Tallinn is split into two halves – the upper and lower parts. You can get between the two parts in several places but the paths are quite steep. Here Edmund is walking up to the upper half.

The upper and lower towns of Tallinn

Perhaps the most impressive building we saw in Tallinn is the Alexander Nevsky Cathedral, an orthodox church.

Alexander Nevsky Cathedral

I love the cathedral’s onion domes.

Alexander Nevsky Cathedral

We went into the cathedral too. It was filled with lavish gold decorations and paintings but we were requested not to take photos. So you’ll have to make do with another photo of its beautiful exterior.

Alexander Nevsky Cathedral

A short walk brought us to St Mary’s Cathedral, a the city’s Lutheran cathedral.

St Mary’s Cathedral
St Mary’s Cathedral

Just as we had looked up into the upper town earlier on in the day, we found a viewpoint in the upper town to look over the lower town. Here you can see the new city in the background.

Tallinn’s lower old town

This view shows St Olaf’s church, and you can also see our ship in the dock.

Tallinn’s lower old town

Descending back into the lower town on our way back to the ship, we spotted some seats on the slope for fat tourists to rest on as they climb the (short) hill. My young, fit brothers apparently needed a break on the way down, though.

Between Tallinn’s upper and lower towns

After we left port it was a long journey to Oslo, and we sailed off into the sunset.

Sailing into the sunset

Oour route took us back under the Great Belt bridge (Storebæltsbroen) which joins two Danish islands. It was truly spectacular to sail under the bridge, but near impossible to capture on camera. These photos are awful, but hopefully interesting.

Storebæltsbroen

Apparently the ship was designed with this bridge in mind and passes only a couple of metres below the bridge deck! As we passed underneath, I was almost certain there would be a loud scraping noise as the Viking Crown Lounge was ripped off.

Storebæltsbroen

To be continued…

DV editing on Fedora

Recently, a friend asked me if I could copy her home videos from a miniDV tape onto a DVD. I said sure, OK, and if she lent me her camcorder I’d be able to get it done.

I’ve never actually used miniDV before, and I’ve only ever tried to process video on Linux a handful of times – and it’s usually been a disaster. Fedora seems to be a rock-steady platform for many tasks, although I would say it can be a bit lacking in high-quality media tools. I decided to give it a go on Fedora, but I was also prepared to fail over to Windows Movie Maker if necessary. Yuck.

So I searched the Fedora repos for the term DV, and came across a tool called Kino.

Kino is a non-linear DV editor for GNU/Linux. It features excellent integration with IEEE-1394 for capture, VTR control, and recording back to the camera. It captures video to disk in Raw DV and AVI format, in both type-1 DV and type-2 DV (separate audio stream) encodings.

Great – sounds like it will do the job. I plugged in the camcorder (a Sharp VL-NZ50) and fired up Kino. It immediately recognised the camera, no intervention necessary. Kino has full control of the tape – I was able to start, stop, rewind, and fast-forward the video. There was a single button to capture the entire tape to disk.

I found it made a new file for each time recording had been restarted on the camcorder. This might be ideal if you wanted to later burn a DVD with scene selection, but I wanted to create a single video.

After capture was complete, approximately one hour of video took up just over 12 GB – luckily I have crazy disks in my PC!

Kino also has features to export video in various formats. I simply exported as a single DV file (no re-encoding required).

Then I used DeVeDe to wrap the raw video file in a nice DVD format with a basic menu, and create an ISO image that I could simply burn to DVD.

I was very pleasantly surprised at how easy it was to get great results copying a miniDV tape to a DVD using Fedora.

Baltic cruise: St Petersburg

Our first taste of Russia, the view of St Petersburg from the ship, was unimpressive to say the least. It’s a mile or two outside the city and all we could see were some shabby, grey tower blocks. And when we disembarked from the ship, we soon discovered that the security in Russian ports is as strict as Heathrow airport.

Still, once we’d had our passports stamped there was a coach waiting for us, complete with a tour guide. She must have been about 60, and as mad as a hatter. As the party filed onto the coach, she said:

And now I count you in Russian like precious stones – один, два, три…

The Hermitage

Our first destination was the Hermitage – a museum comprised of several palaces. There are hundreds upon hundreds of rooms, each of them filled with sculptures, paintings and lavish decoration. The ceilings and walls were covered with gold leaf – I simply couldn’t comprehend how much of the interior (and exterior!) of the Hermitage was gold.

Of course, photos can’t do justice to such grandeur, but here are a few of my favourite shots. This first one is the small throne room.

The throne room
A gold room

Yep, this is all gold too.

Gold pillars

You guessed it – this is the large throne room. Although if I were the Tsar of Russia, I would probably want a small table to put my drink on.

The large throne room

Oh look! More gold!

Gilded archways

This urn is huge! (Yes, yes, I know. Those people are just far away). It’s carved from solid malachite.

A malachite urn

This guy is lost because there are so many rooms. Nah, not really. This is Orpheus, sculpted in 1777 by Antonio Canova.

Orpheus

Leaving the Hermitage, the sun had just come out.

Outside the Hermitage

Lunch

We were taken to an old, converted palace for lunch. It had grand marble pillars, and we were served a traditional three-course Russian lunch, including caviar and, of course, a shot of vodka.

A traditional Russian band with singers and dancers performed for our entertainment. After a few songs, they grabbed some of the tourists and made them play musical instruments on the stage. My brother Edmund was selected to be the conductor, and given a wooden spoon and a hat, much to his embarrassment (and our delight).

St Isaac’s Cathedral

After lunch we were taken to see St Isaac’s Cathedral. It took 40 years to build and at the time of its completion, it was the tallest church in Russia. During the Soviet era the building was turned into a museum of atheism. These days it’s a general tourist attraction.

The exterior, while being large, tall, and grand barely hints at the lavish opulence of the interior. And if you were wondering, yes, that’s real gold on the roof.

Exterior of St Isaac’s Cathedral

The interior is incredibly grand, covered with gold leaf, paintings, sculptures and precious stones. Here’s a view looking up inside the centre of the building. In the very centre of the dome there is a metal sculpture of the dove of peace.

Interior of St Isaac’s Cathedral

The inside of the cathedral is lined with yet more malachite, this time in the form of columns. Apparently each column weighs 114 tonnes!

St Isaac’s Cathedral

The columns were apparently lifted into place using a huge wooden framework, with ropes and dozens of labourers. There was a model of the setup in the museum.

The construction of St Isaac’s Cathedral

Above the door as we left, I saw this enormous sculpture.

A sculpture outside St Isaac’s Cathedral

And here’s the family, standing outside the cathedral. (You can see the above sculpture in the background). Aren’t we cool with our tour radios and earphones?

The family outside St Isaac’s Cathedral

Shopping

We went into a shop which claimed to have all traditional Russian goods, and was aimed at tourists. The shop served free coffee and vodka – and they just couldn’t give you enough of the stuff! But the products were high quality and with a couple of vodkas inside me, what better way could there be of spending the holiday rubles?

All of the Baltic countries we’d visited seemed crazy about amber, so I bought a silver and amber pendant for Hannah, while Edmund bought a shapka (which showed up on the receipt in Cyrillic script as Шапка).

Outside the the shop, I asked Edmund to try and look cold and hungry, and I took this photo.

Edmund in Russia

General sights

This is the Russian ship Aurora, which fired a blank shot to signal the start of the assault on the Winter Palace (now part of the Hermitage).

Aurora

Of course, no visit to Russia would be complete without the obligatory shot of a Lada. These cars are everywhere!

A Lada

This is me standing in front of the Church of the Spilled Blood. The blood reference comes from the fact that Alexander II was fatally wounded on that site in 1881.

Me by the Church of the Spilled Blood
Church of the Spilled Blood

In the evening I managed some night shots of the city skyline, as seen from the ship.

St Petersburg by night
St Petersburg by night

Overall, I thought that Russia was a strange juxtaposition of extreme wealth and extreme poverty – but certainly a fascinating country nonetheless.

To be continued…

VisitWales nomination

I was delighted to be nominated for the Wales in Words competition for my entry about Camping in Pembrokeshire.

Hi Jonathan,

We have read your site with interest and feel it deserves to be entered into the ‘Wales In Words’ blog competition. Congratulations!

We are looking for the great Welsh stories, posts, articles and sites that will celebrate the benefits of Wales.

The competition is entirely free to enter with a grand prize of 3 nights, dinner, bed and breakfast, plus use of luxurious spa facilities at Holm House, one of Cardiff’s finest boutique hotels. For more information, visit this page.

We will be reviewing all articles before compiling a shortlist from which the eventual winner will be chosen. You will receive a ‘shortlisted badge’ should you be selected. The winner will be decided and announced on September 29th 2009.

Keep up the excellent standards you have achieved and thank you for writing about Wales!

Web statistics with AWstats

A few months ago I set up a website, Memories of Korea, to showcase some slides I inherited. Naturally I was keen to find out how many visitors I’d had, so I set about finding something that could draw pretty graphs.

Based on my experiences setting up website statistics with AWstats, I’ve now prepared a guide for anyone else wishing to do the same.

This guide assumes you are running either Fedora or CentOS, with Apache httpd web server. The majority of the AWstats config will apply on any distro, and with several different web servers, but paths and installation procedures may vary.

Installing AWstats

First things first, let’s install AWstats. On Fedora:

sudo yum install awstats

On CentOS, you need to jump through a hoop first by enabling the EPEL repository:

sudo rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
sudo yum install awstats

Tweaking your Apache logs

AWstats works by reading your httpd access logs. Somewhere in your httpd.conf you should have a line like this.

CustomLog logs/access_log common

or

CustomLog logs/access_log combined

If you have virtual servers, each server is likely to have its own log file and associated CustomLog directive, too. For now, just pick one set of logs to work with and do the rest later. If your CustomLog directive ends in common, change it to combined. This keeps the log format the same, but causes a couple of extra fields to be logged.

Don’t worry if you can’t change the log format for one reason or another – AWstats will still work but you won’t get quite as many juicy stats.

While you’re nosing around in httpd.conf, make a note of the path and filename of the access log – you’ll need it in a second. In my case it’s /var/log/access_log, which is the default for non-virtual Apache servers.

Go into /etc/awstats. There should be a sample config file called awstats.model.conf. This contains most of the default options you will need, so let’s make a copy of it and work on that. Give the copy the same name as your website

cp awstats.model.conf awstats.www.memoriesofkorea.com.conf
vi awstats.www.memoriesofkorea.com.conf

You don’t need to change many options to get it going, so I will outline the basics here. Find the following directives in the config file, and change their values appropriately. Leave everything else alone – for now!
Tell AWstats where your Apache log file is:

LogFile="/var/log/httpd/access_log"

Leave this as 1 if you are using combined Apache logs. Change it to 4 if you are using common Apache logs.

LogFormat=1

Set this to the main name of your website.

SiteDomain="www.memoriesofkorea.com"

If your website has other names, add them here. Usually the only “other” name is simply omitting the www. Leave in 127.0.0.1 and localhost, which may be important if you access your website from the server it is running on.

HostAliases="memoriesofkorea.com 127.0.0.1 localhost"

Save your changes and exit.

Run AWstats for the first time

When you installed AWstats, it was automatically configured to run and collect log information hourly, but you’re too impatient to wait for cron, run the first AWstats update now:

/usr/share/awstats/tools/awstats_updateall.pl now

Grant access to the AWstats page

You need to edit the file /etc/httpd/conf.d/awstats.conf. This just tells Apache who can view the statistics. Somewhere in the middle of the file there should be a block like the one below. By default only 127.0.0.1 (the web server itself) is allowed to view the page, so if your web browser isn’t running on the server, you will need to change something.

You might want to add a single IP address, an IP address range (e.g. 192.168.0.1/24 for a home network) or simply all to grant access to the world.

    Options None
    AllowOverride None
    Order allow,deny
    Allow from 127.0.0.1
    Allow from 192.168.0.0/24
    Allow from all

Save the file and exit. Restart Apache.

service httpd restart

See your statistics

Assuming all went well, you should be able to view your statistics page at http://www.mysite.com/awstats/awstats.pl

Other options

You no doubt saw in the /etc/awstats.conf file that there are many, many more configurable options for AWstats, including user authentication to name but one.

The config file is well commented and there is plenty of documentation online to help you along.

Baltic cruise: Helsinki

The next day, we sailed into Helsinki, Finland. The weather was grey again, but we disembarked the ship and got straight onto a tour bus that was waiting in the port.

One of the first sights we saw was Helsinki Cathedral. I think the steps and paved area of the Senate Square add to the grand impression it makes.

Helsinki Cathedral

Not far away there is an abstract sculpture in tribute to the composer Jean Sibelius, who studied first law and then music in Helsinki as a young man, before moving to Berlin. At the time it was commissioned, there was debate about whether or not it should include the composer’s face. It was eventually decided that an effigy of Sibelius should be included – sadly you can’t see this in my photo.

The Sibelius Monument

Perhaps the most interesting thing we saw was the Temppeliaukio Church, which has been carved out of rock. The roof is partly made of glass, and the rest of it is made from a single piece of copper wire that has been coiled round, several kilometres in length.

Unfortunately the dim interior coupled with the large windows and bright floodlights didn’t make for ideal photographic conditions, but I took a few pictures nonetheless.

The copper roof of the Temppeliaukio Church
Edmund admires the glass roof
The organ

Just around the corner from the church, there was yet more evidence that the Finns are obsessed with Father Christmas. Santa’s Minimarket is partly a Christmas decoration shop, and partly a Happy Shopper with groceries and newspapers. Strange. Nevertheless, I bought a Snickers and a cuddly moose.

Santa’s Minimarket

The tour guide also pointed out a market where the stalls are held by members of the public – basically a car boot sale, but larger and taking place weekly.

Helsinki market

Finally, as we returned to the ship, I spotted a guy cleaning the windows on the 8th deck, and was immediately glad that it wasn’t my job.

Window cleaner

While it’s great seeing any new place, I couldn’t help but think that Helsinki was the most similar to Coventry out of any of the cities we visited on the cruise.

To be continued…

Heart rate monitor

Recently I went on a Baltic cruise for a fortnight with my family. The ship boasted a fully-equipped gym so I decided to have a go.

I cycle almost daily, for commuting and for exercise so I have no concerns about my general fitness. But I thought I may as well have a go at something other than cycling while I had the opportunity.

I spent quite a lot of time on the treadmills. I used to run a lot at sixth form but hardly at all since I left in 2004. I found it came back to me quite naturally, and was delighted to find that these treadmills have built-in heart rate monitors. I could run fairly hard for 20+ minutes and keep my heart rate within 160-165 bpm. I don’t know if this is good/normal/etc but I don’t care. I just like statistics! 😛

When I got home, I was curious about how my heart performs when cycling, so I went to Tesco and bought their cheapest heart rate monitor. It doesn’t have that many features, but I don’t want any features except to know my current heart rate. Annoyingly, it beeps once per heartbeat and you can’t turn this off, but never mind.

Yesterday I cycled the 6 miles to work on my racing bike with the heart monitor rigged up. The first 3-4 miles are on the Bristol-Bath cycle path which is almost completely flat, and I cruised at a speed of around 22mph with a pulse of around 160bpm. So far so good.

Next my route takes me through Old Market and eventually Broadmead. Here it’s a bit hillier, and I have to deal with traffic and traffic lights, which means I keep accelerating and braking. My heart got up to 175bpm with the extra exertion.

Finally I have to get up St Michael’s Hill, and ascending this climb, working hard out of the saddle, I peaked at 197bpm.

According to Diet and and Fitness Resources, the maximum heart rate (MHR) for my age and gender should be 197bpm and recommended heart rates for different types of exercise are in the following table.

Type of exercise % of MHR Heart rate
Recovery/Weight Loss 60 – 70% 118 – 138
Aerobic 70 – 80% 138 – 158
Anaerobic 80 – 90% 158 – 177
Maximum 90 – 100% 177 – 197

Of course these type of statistics vary hugely from person to person, but I guess it means I do a lot of exercise broadly in the anaerobic range.

Baltic cruise: Stockholm

Another day on our cruise finds us on our way into the Swedish port of Stockholm.

The day immediately got off to a fascinating start, as Stockholm is surrounded by an archipelago of tiny islands. Great fun if you have a motorboat to whizz round the sharp corners, but for a 90,000 tonne ship there are only two or three passable routes and the ship has to slow right down to only a few knots.

You can see the archipelago in the mini map below, plus the shipping routes in dotted lines – or you can see for yourself on Google Maps. We approached from Copenhagen in the South-West, circled the archipelago and ultimately homed in on Stockholm from the North-East, along the path of the shipping routes.

A map of Stockholm

I woke up early specifically to stand on deck and watch the ship carefully navigate its winding way through the archipelago. It was a little misty but absolutely beautiful, and I hope some of these photos have captured but a pinch of that beauty.

Stockholm archipelago
Stockholm archipelago
Stockholm archipelago
Stockholm archipelago
Stockholm

The city itself is spread across several islands, which are connected by a few bridges. It would be a long walk to visit all of the interesting islands, so we bought a day pass for the bus boats that are constantly whizzing around between the islands. This gave a unique view of the city, too.

Here we are standing by the water on Djurgården, an island which is home to an amusement park, several museums and lots of open land.

The family on Djurgarden

Later on, in Gamla stan (the old city) we witnessed the changing of the guard. It’s a grand ceremony with soldiers in full costume on horseback, accompanied by a mounted brass band.

The changing of the guard in Stockholm

We also visited Storkyrkan, the oldest church in Gamla stan. It was built in red brick rather than stone, and had all the usual features you would expect in a large church. It was also fairly dim inside so there wasn’t much scope for good photos, but this unusual stained glass window did catch my eye.

A stained glass window in Storkyrkan

It so happened that Stockholm Gay Pride festival was taking place on that day, too. We watched the parade pass – it was absolutely huge and there was a seemingly unending procession of floats, singers, dancers and actors. I took a few photos over the heads of the crowd.

Stockholm Gay Pride
Stockholm Gay Pride
Stockholm Gay Pride

Sailing out of Stockholm in the late afternoon, I saw a dockyard where the cranes were painted like giraffes. Cute.

A giraffe crane

We were also treated to our first decent sea sunset of the cruise. It was hard to capture such a breathtaking sight on a camera, but here’s my best attempt.

A sunset at sea

To be continued…

Monitoring AQL SMS credit with Nagios

Further to yesterday’s post about setting up SMS alerts from Nagios, I decided I wanted to monitor how many SMS credits I have left in my account.

AQL provide a way of finding out via an HTTP request, so I set about writing a perl module to check and return the result to Nagios.

N.B. I’ve now published this module on Monitoring Exchange. Please download the plugin from there, as I will keep that copy up to date if there are changes in the future (and the copy on this page is likely to go out of date).

check_aql_balance

#! /usr/bin/perl -w
# Usage: check_aql_balance [username] [password] [warning] [critical]
# Example: check_raid fred bloggs 100 50
#         WARNING Balance 23 credits

use strict;
use LWP::Simple;
use lib "/usr/local/nagios/libexec";
use utils qw(%ERRORS);

my $username = $ARGV[0];
my $password = $ARGV[1];
my $warningval;
my $criticalval;
$warningval = $ARGV[2] or $warningval = 20;
$criticalval = $ARGV[3] or $criticalval = 10;
$warningval =~ s/[^0-9]//gi;
$criticalval =~ s/[^0-9]//gi;

if (!defined $username || !defined $password) {
    print "UNKNOWN, Unable to retrieve account balancen";
    exit $ERRORS{'UNKNOWN'};
}

my $url = "http://gw1.aql.com/sms/postmsg.php?username=$username&password=$password&cmd=credit";
my $content = get $url;

if (!defined $content) {
    print "UNKNOWN, Unable to retrieve account balancen";
    exit $ERRORS{'UNKNOWN'};
} elsif ($content =~ m/AUTHERROR/i) {
    print "UNKNOWN, Unable to retrieve account balancen";
    exit $ERRORS{'UNKNOWN'};
}

$content =~ s/[^0-9]//gi;
if ($content >=0) {
    if ($content < $criticalval) {
        # critical
        print "CRITICAL, Balance $content creditsn";
        exit $ERRORS{'CRITICAL'};
    } elsif ($content < $warningval) {
        # warning
        print "WARNING, Balance $content creditsn";
        exit $ERRORS{'WARNING'};
    } else {
        # ok
        print "OK, Balance $content creditsn";
        exit $ERRORS{'OK'};
    }
} else {
    # invalid number
    print "UNKNOWN ,Unable to retrieve account balancen";
    exit $ERRORS{'UNKNOWN'};
}

The only required arguments are the AQL username and password, but you can optionally specify the limits that trigger Warning or Critical status. If you omit these, the script defaults to values of 20 and 10.

In your commands.cfg, add a block like this to define the command. Again, you can omit the last 2 parameters if you are happy with the defaults..

define command{
    command_name    check_aql_balance
    command_line    $USER1$/check_aql_balance $ARG1$ $ARG2$ $ARG3$ $ARG4$
}

And finally, in the localhost.cfg (or any other config file for hosts/services) you can add the service like this.

define service{
    use                             local-service
    host_name                       localhost
    service_description             AQL account balance
    check_command                   check_aql_balance!fred!bloggs!20!10
    notifications_enabled           1
}

Simples!

SMS alerts with Nagios

In a previous post I mentioned how easy it is to increase functionality in Nagios.

Today I was asked to set up SMS alerts in Nagios, as well as the existing email alerts. I am by no means the first person to write about this, but this post is intended to be a start-to-finish guide, covering all aspects.

Choosing a provider

The first step is choosing a provider which has a decent API for sending SMS messages. I chose AQL, as I have used them in the past. They allow you to send SMS messages via a web interface, HTTP GET, HTTP POST, or email.

In that way, perhaps the easiest way to get SMS alerts is to get Nagios to email its alerts to the AQL SMS gateway. But I wanted to do it “properly”.

So I signed up for an account with AQL and bought a small number of SMS credits for the account. It’s also possible to have a contract for heavy usage, but I can always upgrade to that if I need to.

Defining a new method of alerting in Nagios

In the file /usr/local/nagios/etc/objects/commands.cfg there is a section where notification commands are defined. I added a couple more definitions for SMS alerts for hosts and services. My SMS script would have a calling syntax like /path/to/script phone_number message.

So I added a couple of definitions like this, obviously using a real mobile phone number:

define command{
command_name alert-service-by-sms
command_line /usr/local/nagios/libexec/alert-by-sms 01234567890 "Nagios Service $NOTIFICATIONTYPE$ Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$"
}

define command{
command_name alert-host-by-sms
command_line /usr/local/nagios/libexec/alert-by-sms 01234567890 "Nagios Host $NOTIFICATIONTYPE$ Alert: $HOSTALIAS$ is $HOSTSTATE$"
}

The script

Now all remains is to write the script that will do the legwork. If you decide to go with AQL as your provider, you need to install their Perl module from CPAN. Use a command like this:

cpan SMS::AQL

And then make a Perl script like this. You can save it anywhere you like; I chose to put it with the other Nagios executables in /usr/local/nagios/libexec just to keep it with the rest. Adjust the username and password to match your AQL credentials, and set the sender parameter to be either a UK mobile number (so the recipient can reply to the message) or simply a text string which appears as a name to the recipient, and does not allow them to reply.

#!/usr/bin/perl -wT

use strict;
use SMS::AQL;

my $to = $ARGV[0];
my $msg = $ARGV[1];
$to =~ s/[^0-9]//gi;

my $sms = new SMS::AQL({
username => 'fred',
password => 'bloggs',
options => {
sender => 'Nagios',
},
});

my ($ok, $error) = $sms->send_sms($to, $msg);
if (!$ok) {
print "Failed to send the message, error: $errorn";
} else {
print "Success!n";
}

It is, of course, wise to test that your script works by calling it from the command line. Once you’re happy it works, it’s time to tell Nagios to start sending alerts.

Enabling SMS alerts

This time, we need to edit /usr/local/nagios/etc/objects/contacts.cfg. Modify your contact entry to add the lines in bold. This assumes you have only one user with a mobile phone – remember their mobile number is hard-coded into the command definition!

If you have more than one user and you set alert-service-by-sms or alert-host-by-sms for both, you will get two text messages sent to the same phone number for each Nagios alert. As I only have one user it’s not a problem for me, but in the future I will probably post a more elegant solution where each user can get an individual text message.

define contact{
contact_name                    jonathan
use                             generic-contact
alias                           Jonathan
email                           alerts@example.com
service_notification_commands   alert-service-by-sms
host_notification_commands      alert-host-by-sms

}

And that should be everything! Now you have to test it, either by breaking a host or service, or setting up a bogus one that will definitely fail.