Recovering from power loss-interrupted Ubuntu distribution upgrade

Was doing an Ubuntu maverick (10.10) to natty (11.04) upgrade on a test system (desktop) and the power was lost. No UPS. On reboot it didn’t come back properly and I got,

The disk drive for / is not ready yet or not present

As far as I know this was part way through the package installations. If it fails during the package download then there is never any problem but with a part-install then parts of the system are running the new version and parts are on the old distribution.

The fix is fairly easy – at the prompt above then type M to get to the manual recovery.

The disk will be mounted as read-only so then remount this,

sudo mount -o remount,rw /

then try these commands,

sudo apt-get update
sudo dpkg --configure -a

then reboot and then the system should come back in a partially upgraded but stable state and you can continue with the distribution upgrade with,

sudo apt-get upgrade -f
sudo apt-get dist-upgrade

After the reboot it will be on the new distribution. Note that if a package is corrupted then you may need to delete that one package file from the /var/cache/apt/… location and re-run the sudo apt-get upgrade -f command. It is a pity the distribution upgrade process doesn’t have this kind of logic built in to facilitate unattended completion or recovery of a partial distribution upgrade.

Other useful commands that are related but not part of the repair: To start off the upgrade process (which was interrupted by the power supply problem),

sudo do-release-upgrade

To verify what version you are running,

lsb_release -r

Pancakes and queues.

I like cooking food: from small meals for one to large multi-course meals for a party, food cooking to me is not just the fun of preparing food but it is also a good way to experience queue theory and project management in a physical way beyond spreadsheets and gantt charts..

A good cook is a good project manager. Delivering a meal is not only an exercise in the skill of preparing the ingredients but it is very much an exercise in timing deliverables. Not much use if your perfectly prepared fish is now waiting for the rice or vegetables to finish cooking or for the salad leaves to be washed.

Same with queue theory:one off productions don’t usually hit queue theory but when you start to make a batch of repeat items then quite naturally you will want to make this more efficient and prepare the food as a queue.

I was making pancakes on the weekend and to speed up the delivery rate I use two fry-pans but rather than cooking two pancakes in parallel i.e. two servers, I decided to cook the pancakes as a pipeline i.e. a series of two servers but the service time for each server is halved. Start off the pipeline by cooking one side of the first pancake on one fry-pan and then when that first side is ready I flip that into the second fry-pan.

The first fry-pan then gets the side one of the next pancake and so on. This allows me to fine-tune the quality of the pancake i.e. the deliverable, on the second fry-pan and ideally the “goodput” i.e. the throughput of actual pancakes should be at a mean departure rate that is the worse-case time taken to cook one side.

We don’t have two gas hobs with the same flame rate so used the medium flame on the first fry-pan and a lower flame on the second thinking that it should suffice.

Within 1 pancake the pipeline was stalling. The second pan was taking too long to cook properly and so I had to take the first pan with a waiting 1/2 cooked pancake off the heat. I had to put the second fry-pan onto a larger hob and so the cooking time for the second side was now faster but the second fry pan after 1 round was now waiting for the first one to finish the first side.

The lesson here is that a pipeline is as efficient as the worse-case service time of all the servers in the pipeline. If any server stalls then the whole pipeline stalls and if any server is too fast then it ends up being idle.

A better strategy for pancakes if you have multiple fry-pans is to cook all of each pancake in each frypan and not try and pipeline the cooking steps unless you can guarantee an equal cooking time for each step,

They tasted great though in the end even if the queuing strategy that was chosen was wrong for this kitchen environment. By the way – the recipe I use is just a scaled up version of the BBC one here though I don’t use butter as a grease but just use a non-stick pan.

FreeSWITCH show command syntax help missing show registrations

I was converting my Asterisk commands to the closest equivalent FreeSWITCH command so I could display the data in the FMS Pandora Console. Nothing fancy here – just totals of registrations and current call counts (and channels – a subtle difference as a channel is one leg of a call). I was after numbers of registrations but the FreeSWITCH command line interface (fs_cli) didn’t list this as an option when you did a help on the show command.

But it really does have a show registrations with a switch for the totals i.e. show registrations count only the module source code didn’t have this in its help text. I’ll log it as a trivial bug.

Here is my Pandora FMS pandora_agent.conf snippet,

module_name FSRegnsCount
module_type generic_data
module_exec  /usr/local/freeswitch/bin/fs_cli -x "show registrations count" | awk '{if (match($0,"total")) { printf("%d",$1);}}'
module_description FreeSWITCH registrations

I will be adding more of thee snippets of Pandora agent configs to a special page on our web site here –

The “show” command help syntax is just a #define in  /usr/local/src/freeswitch/src/mod/applications/mod_commands/mod_commands.c so easy to fix.

Chunky text rendering in Adobe Acrobat Reader

Yuk yuk renderingI was viewing some PDF files on a PC and came across  a rather odd result. The PDFs were displaying text very chunky. An example is to the right.

The document prints perfectly; it is only the screen display that is chunky.

To fix this go into Adobe Acrobat Reader menu option Edit -> Preferences then in that in Page Display under “Rendering” make sure that the “Smooth Text” is set to something other than None. This fixes this issue.

Scribus 1.4 has been released on 1st Jan 2012

We use Scribus a lot – in the past year we have set two commercial trade paperback books, designed numerous A5/6 sized cards (both for charity and retail), newsletters for clients and 3-folds – so I think it is fair to put in a kind word for something that is Free and Open Source.

After 4 years since the last release, Scribus is now at release 1.4. See their release note here –

We’ve been using the beta version for the past year so it should be stable enough for production work. We’ll see and I’ll be upgrading our machines and producing a client e-mail newsletter as our first use of this new release.

Keep up the good work Scribus team !

PandoraFMS server v4 fails to start – exits with Unknown column errors

During the Pandora FMS console upgrade the database schema may not have been upgraded correctly. If this happens then the Pandora server will be unable to start, i.e. when you try /etc/init.d/pandora_server start then it fails and logs its error messages in the /var/log/pandora/pandora_server.error file. If there are Unknown column errors then this is a clear giveaway that the database that you are connecting to doesn’t have the expected schema,

DBD::mysql::db do failed: Unknown column 'extended_info' in 'field list' at /usr/lib/perl5/PandoraFMS/ line 567.
DBD::mysql::st execute failed: Unknown column 'disabled' in 'where clause' at /usr/lib/perl5/PandoraFMS/ line 399.
DBD::mysql::db do failed: Unknown column 'tags' in 'field list' at /usr/lib/perl5/PandoraFMS/ line 567.

The fix is easy to do (assuming you don’t want to fall back to the previous version). Ideally first make a backup of your database using whatever tools you have available (your cpanel Mysql tools or command line mysqldump or phpmyadmin).
Then run the following command line commands,

cd /path/to/pandora_console
cat extras/pandoradb_migrate_v3.1_to_v3.2.sql | mysql -u pandora -p -D pandora

and then at the Enter password: prompt enter the password of the mysql user pandora. Note that the -u is the user i.e. pandora and the -D pandora is the database of pandora. This is the default convention used on the Pandora FMS system though you can use any database username and database name. Yes that is the 3.1 to 3.2 schema upgrade file. There is no harm in repeating that command.

Then repeat that with the 3.2 -> 4.0 schema changes..

cat extras/pandoradb_migrate_v3.2_to_v4.0.sql | mysql -u pandora -p -D pandora

At the end of this then you can start the Pandora server and it should startup correctly.


wp-super-cache stale cache due to Apache permissions

This may happen to you in that web pages for anonymous users (i.e. not logged on) stay stale even when you use “Delete Cache” in WordPress dashboard and clear the data from your browser. The page contents stay stale and menus (if they were changed) stay on the old layout.

If this happens to you and you are pulling your hair out in testing and unable to get the pages to display on the new content then ssh into your server and check the permissions (ownership) of the /wp-content/cache is actually owned by the web server and has not been changed..

After a Plesk/Parallels upgrade (automatic I think) the user that Apache ran in changed and this meant that files that were previously created by Apache using the old user account were now not able to be deleted by the new Apache account user (www-data). This is probably never going to be seen on shared hosting but could be seen on virtual or dedicated servers.

The WordPress site would have kept dishing out the old file not matter what I did because the old cache files couldn’t be deleted.

The fix is easy (assuming your Apache installation is going to remain stable) and that is to ssh shell into your account and delete using the file owner (or root) the contents of the /wp-content/cache directory (which will have a “meta” and  supercache” subdirectories.

You may also be able to use your FTP client to do the same but probably the cache directory won’t actually be visible at all.

Once you have deleted all of that old stuff then go back into the wp-super-cache plugin settings and remove and then re-enable the cache settings.

Non-logged on browsers will now correctly display the site and the supercache/… files correctly build up with the ownership being the Apache web server.

To test this I use Firefox and Opera: Firefox is logged in and Opera is used to display the web site as an anonymous user. Opera has a nice feature in Opera -> Settings -> Delete private data that you can quickly clear the browser cache of everything.

Pandora FMS Agent not connecting to localhost tentacle server

This is one of those silly gotchas that works on some servers but not on others. On servers you’ve probably gotten used to common server processes like mysql and ssh and so on listening on all IP addresses (

Doesn’t work that way on virtual (e.g. venet0) interfaces used with virtual servers. Few things get to have bindings like

You probably know the answer now – If your tentacle server is bound to a specific IP then if the Pandora Agent (client) on the actual Pandora Server itself tries a default of “localhost” i.e. connect to itself then that isn’t going to work at all if the tentacle server is not listening on but is listening on a specific IP address.

Fix is easy – do a netstat -an | grep 41121 and you’ll see something like…

tcp        0      0 X.X.X.X:41121*               LISTEN

where X.X.X.X is an actual IP address and not

In the /etc/pandora/pandora_agent.conf then set the server_ip to that IP address or, better, set it to the domain name that resolves to that IP.

Fixing Default font doesnt exist in PandoraFMS v4 console

This is a first-day-of-use error message that will appear as a warning triangle at the top of your PandoraFMS v4 Administration Console. The fix is easy. Go into the menu option,

Administration -> Setup -> Visual Styles

and set the  Fontpath option (it will be set but not saved into the new
database schema) and then do an Update on that page just the once.

That clears that warning triangle message. If you didn’t notice then the warning triangle appears at the top near your username and logout icon.

Using error_log() with print_r() to gracefully debug PHP

When debugging php code (especially Open Source code you have not written yourself) then to get a feeling of what is passed around when it doesn’t work I find that the print_r() function is very useful.

Trouble is that if you just throw in print_r() into the code where you think it is faulty then you can upset json, AJAX or your web page layouts as the print_r() splatters stuff to your displayed web page or in some cases the PHP file is not going to a browser (e.g. the PayPal IPN notify).

The trick is to throw it at the error log as follows e.g. if I was tracing what $number was being set to then I would use….


note that you MUST set that print_r() option to “true” so that it returns a string. This string is then sent to the error_log() function which formats it with referrer details and puts it into the Apache error log.

Where does it end up ? Well on my test system on a non-vHost it is /var/log/apache2/error.log and on a vHosted server it is :/var/www/vhosts/<domain name>/statistics/logs/error_log so on your own system it will be a similar Apache error log file. Just tail that file to see what the messages are which will be something like this (in this example the $number was “2008” so the output for that error log message was,

[Sun Jan 01 13:21:12 2012] [error] [client] 2008, referer: http://19

To synchronize the log messages with your testing then just look at the logging time.

Ring then disconnect on registered VOIP SIP trunks

The setup is a (VOIP) SIP trunk provider in the UK connecting via the internet to a FreeSWITCH PBX with the web interface that is attached to the Internet via a NAT routed ADSL last mile. The local IP telephones connect to the FreeSWITCH PBX and the different trunks from the UK (using 3 trunks for 3 different projects) should appear on one of three of the 5 extension lines on a Cisco SPA 525G.

The trunk to the UK was registered correctly as far as FreeSWITCH/ was concerned but when you called the UK phone number from the PSTN then it rang but then went to disconnect tone. What was expected was that the call would use the SIP trunk to connect via the FreeSWITCH to the IP phone on the client site and light up the correct extension.

The problem is that in I had configured the trunk Bind to the Authenticated SIP interface and not the Authenticated SIP NAT interface. Changed it to the Authenticated SIP NAT interface and that worked. The Authenticated SIP NAT port has port 5070, auto-detect IP address via UPnP whereas the Authenticate SIP port I have is on the fixed local LAN private IP address used for local IP phones to proxy register against. These SIP interfaces are defined in under Connectivity -> SIP Interface and the trunk is defined under Connectivity -> Trunk manager.

You will see the FreeSWITCH console log has,

2011-12-25 12:29:06.274781 [WARNING] sofia_reg.c:1445
SIP auth challenge (INVITE) on sofia profile 'sipinterface_4'
for [] from ip X.Y.Z.A

for each inbound call attempt. Bit of a first day of setup gotcha.


Using audacity to create auto attendant /IVR prompts (low cost)

If you are getting someone to say the script (or yourself !) in-house and want a low-cost recording solution without a professional sound recording setup then I use Audacity with an ordinary microphone from a VOIP headset and a few tweaks. Audacity is a good Open Source digital audio recorder and effects processor.

I use a piece of A4/Letter (80gsm) photocopy/LASER copier paper between your mouth and the microphone. This will de-pop your speech. It makes a dramatic difference. Just hold the paper from the bottom so you can still see over it to read the script on your computer screen but don’t have the paper touch the microphone or your mouth (lips, beard, moustache etc).

Open Audacity and set the project rate to 16000 Hz and the input as 1 (Mono) Input. The input is in the Device toolbar (See View->Toolbar -> Device toolbar to make sure it is displayed).

Have your script visible on the computer screen, the de-popper paper held in one hand between the microphone and your mouth and click the record button.

Wait a few seconds to get the background noise (i.e. allow the microphone to pick up the ambient noise because we need to remove this later) then speak your script at a normal pace. At the end leave a few seconds of silence and then click the stop button.

Now select the starting silence (not your words or any clicks from your mouse button at the very start) and click the option Effect->Noise removal and then click the option button in the noise removal Step 1 of “Get noise profile”. It remembers this so now select ALL the audio and then redo the Effect -> Noise removal and take the defaults and click OK.

If you listen it should now be dead silent between words and phrases that you say.

Now select the silence at the start and use the scissor tool to cut this. Select the end silence and use the scissor tool to cut that. Note that you might see a tiny click at the start and end which is the mouse click when you clicked the Record button. Cut this out as well.

That is about all you need to do. Save this as a Audacity PROJECT and then export it as a 16 bit PCM wav file. Upload this and see if it works for you. If the volume is too low then re-open the Audacity project and use the Effect->Amplify to adjust this and then re-save as a new WAV file.

Other tricks are to use Bass boost effect to give your voice some gravitas or to use pitch controls, though you do risk sounding artificial if you alter it too much.

No text-to-speech with Flite on Freeswitch/ IVR

If you have configured a feature code that uses text-to-speech e.g. a talking clock or if you are setting up an auto attendant (IVR) on a new system and you have selected the flite voice but when you connect to the auto attendant Assigned Number you get no message audio even though you have selected the Flite voice then you can test this problem very quickly.

Look at the freeswitch console log and you should see a error message,

2012-12-26 09:57:14.381330 [ERR] switch_core_speech.c:61 Invalid speech module [flite]!
2012-12-26 09:57:14.381330 [ERR] switch_ivr_play_say.c:2439 Invalid TTS module!

If you are not at the console and if you are testing an IVR then connect to the IVR from a phone and  hit one of the key mapping option numbers that you have configured for it to action and if this works (which they probably will) then your problem is that you have not enabled the mod_flite in Freeswitch source modules.conf or the module is not automatically loading.

This is easy to fix. Edit the /usr/local/src/freeswitch/modules.conf  and uncomment the line,


(also make sure that you have mod_cepstral commented out as you can’t use flite and cepstral at the same time. Cepstral is licensed, albeit not very expensive – about 30 dollars per voice – and you can test with their TTS voices though the TTS engine will periodically insert nag messages.)

Now do a make on Freeswitch. This will see that you have enabled the mod_flite and it will download the flite package from  (about 14 Megabytes).

Note that if you break the download then you must cd to /usr/local/src/freeswitch/libs and sudo rm -R flite-1.5.1-current*  or similar to clean up the broken download and then run make again.

After the make then do a make install.

Once that has done (or perhaps you had already had that uncommented) then you must make sure that the module is autoloaded. To check this go to the runtime program path which is usually /usr/local/freeswitch) e.g.

cd /usr/local/freeswitch/conf/autoload_configs

and edit the  modules.conf.xml and again uncomment the mod_flite line so it is  the only one uncommented,

  <!-- ASR /TTS -->
    <load module="mod_flite"/> <!-- -->
    <!-- <load module="mod_pocketsphinx"/> -->
    <!-- <load module="mod_cepstral"/> -->
    <!-- <load module="mod_tts_commandline"/> -->
    <!-- <load module="mod_rss"/> -->

now restart freeswitch. Your feature code text to speech will now work.

Truthfully though the Flite TTS is synthetic (e.g. the rms voice) and will never be as good as a human spoken voice but it does allow you to quickly setup what option codes to use and test your options before you get a human speaker to say a script.

If you are getting someone to say the script (or yourself !) in-house and want a low-cost recording solution without a professional sound recording setup then I use Audacity with an ordinary microphone (VOIP headset) and a sheet of copy paper as a de-popper. See my post here for details.

Microwave oven wiring fix for scooter wiring

The wire on the temperature gauge of my Aprilia Leonardo finally broke near the socket so the temperature reading stayed on low/no reading. If you look you can see a metal pin on the gauge that the needle sits against. After about 2 minutes of motor operation the needle should move off that pin. If it doesn’t then check that wire.

To do this ideally remove the right-hand side inspection panel and the temperature sensor is towards the middle bolted into the engine block around the same level as the starter motor (the oil pressure sensor is much lower).

This can both come loose (mine did a year before) or finally snap off at the plug. The temperature sensor has a spade plug end on it so nothing special but you don’t have any slack to play with on the wiring loom so you need an extension wire but I discovered a nice fix that will probably work for you too.

Many months ago I had picked up a junk microwave from the road side: I had pulled it apart to see what was inside and I remember keeping all the wiring looms from the microwave. The wiring loom connects all the microwave door interlock switches together to the control board. Looking around for suitable wire to repair the bike I noticed that the microwave loom had these nice sockets with moulded plastic covers and reasonably good sized cable. The cable lengths are only a short distance of a few inches/centimetres but that’s all I needed.

I tried one of the sockets fitted the temperature sensor on the bike and it clicked on perfectly. So I chopped off one of the sockets with about 3 inches/8 cm of wire on it, stripped back the end and then stripped back the end of the broken wire on the bike, cleaned the corrosion away and then used a barrel/coupler connector to join the new bit of ex-microwave wire to the bike wiring loom wire.

It worked.

Using strace to identify Plesk 10 blank screen problems

Plesk 10 uses its own web server which runs as a process called sw-cp-serverd. This is started by init with a command line that results in the processing being called,

/usr/sbin/sw-cp-serverd -f /etc/sw-cp-server/config

That config directory is where you will find which ports it binds to and the URL re-writes. You should not change the bound port as that can upset other applications.
If you connect to Plesk on port 8443 and you get a blank screen or if you can logon to Plesk and administrative functions are blank then this is due to some problem with that server or the files that it is accessing.

To see what system calls it is doing and so help identify where to look next you can use strace as follows,

sudo strace  -p `ps -C sw-cp-serverd -o pid=` -s 8443 -o mydebugfile.txt

(note using backtics to run the ps command – if you are having trouble finding the backtic on your keyboard then you can do a ps and grep for that process name and then put the process number into that place in the strace command). If strace is not installed on your system (usually isn’t) then you can install it using your usual package manager or if using Ubuntu then I used,

sudo apt-get install strace

Don’t worry about EAGAIN (Resource temporarily unavailable) messages – this is just how it displays for non-blocking I/O when there is no data to read.

The really interesting ones are the connect(socket #..) then the writev(socket #..) and then read(socket #,..), where the socket # is the same socket number that was setup and in the writev() you can see your request with all the browser details and the read() that follows gives the response.

If the read() has a Status: 500 Internal Server Error in it then this won’t come back to your browser screen – which will stay blank.

If this happens then you have an inconsistent Plesk installation and this requires support from someone who knows how the Plesk server works.