High forked-daapd cpu usage?

So there I was playing with Rhythbox and bemoaning the non-existant DLNA support when I noticed (even though it’s always been there) the DAAP plugin. “What is this DAAP of which you speak?” I thought, and ended up installing mt-daapd. Turns out DAAP is rather good, and there’s even a very useful Android app for it, so I’m quite keen to continue with it.

Now mt-daapd hasn’t been maintained for years, and according to the man who forked the project and created (by his own admission) the terribly named forked-daapd you’d need to be a confirmed stick in the mud to continue using the older version. And as forked-daapd is in the Ubuntu Precise repositories, it got installed. Initial tinkering showed positive signs of life so I left it doing it’s thing and went to bed.

The following morning as I padded into the lounge I noticed the normally quiet fan on the media server sounding quite breathless, and one htop later could see the cpu at 100%. A quick

ls -l /proc/`pidof forked-daapd`/fd

showed forked-daapd holding open a Microsoft Word document. I ran a

find /media/music -name \*.doc -exec rm {} \;

(don’t run this on your home dir) to blitz any .docs in the music directory and restarted forked-daapd (in fact I had to kill -9 the daap server as it was still avidly reading the Word doc). I had to run through a similar process with some old Thumbs.db files that forked-daapd wouldn’t parse or let go of, but all now appears well.

So in conclusion, if you’re running forked-daapd and it’s pegging your cpu at 100% for a long time, check which files it’s holding open. Naturally unlike me you won’t have a music folder full of junk.

Posted on March 13, 2012 at 4:26 pm by mcmlxxii · Permalink · Leave a comment
In: Linux · Tagged with: , , , , ,

Attachments missing with altermime and postfix

We recently experienced a problem with attachments going missing when using altermime to add a disclaimer to emails. The problem was only evident when the client was Outlook or Entourage (mange tout Rodney, mange tout). It was a real head scratcher as some emails would go through fine, others would be oddly truncated.

I even resorted to ‘catting’ out the email to file before and after applying the disclaimer, and then running diff on the resulting pair of files, but there was apparently no difference bar of course the added disclaimer text.

After protracted googling by myself and a colleague, we found that the Microsoft clients, when parsing the emails prior to sending (which all clients do to chop the lines down to the RFC specified length) allow single full stops to appear by themselves on their own lines. Now Postfix handles these fine when the email comes in over SMTP. However, when it comes out of the disclaimer script, it is injected back into the mail queue with the sendmail command. Seems that this sees the full stop and accepts it as the end of the email, thereby neatly truncating it sans attachment and often without some of the text.

To get around this, we added a single line to the disclaimer script, just prior to the sendmail command:

sed -i 's/^\.$/. /g' in.$$

where in.$$ is the mail. This adds a single space after the full stop which gets around the problem. I hope this saves someone a few hours.

Edit: After spotting a comment on howtoforge, it seems there’s a flag you can set for sendmail to stop it seeing single dots as EOF:

-i Ignore dots alone on lines by themselves in incoming mes-
sages. This should be set if you are reading data from a
file.

which is a lot neater than the fix above. Just sendmail -i in.$$

Posted on November 9, 2010 at 6:50 pm by mcmlxxii · Permalink · 2 Comments
In: Linux · Tagged with: , , , , , , ,

Drupal Calendar 0000 glitch

If you use the Drupal calendar module and wonder why the navigation links always link to the year 0000, there is a simple fix. Open up the file sites/all/modules/calender/theme/theme.inc and after this stanza (lines 19-23):

// Create the links to other displays.
$now = date_now();
$url = $view->get_url();
$view->date_info->url = $url;
$arg = $view->date_info->date_arg;

add the following line:

$view->date_info->year = $view->date_info->year && $view->date_info->year != $view->argument['date_argument']->options['wildcard'] ? $view->date_info->year : date_format($now, 'Y');

Posted on July 22, 2010 at 6:02 pm by mcmlxxii · Permalink · 3 Comments
In: Drupal · Tagged with: , , , , , ,

imap sent or sent items?

Imap rocks, especially since Thunderbird 3.0 and its smart folders allow all email accounts to look like local folders. Emails can be left on the server, where proper backups can be configured, and emails can be accessed from any number of devices and clients, including webmail. Having to nip home to check email is just so 1990s.

It’s not all jolly jolly however. Outlook hasn’t yet followed Thunderbird’s lead – each additional imap account means another sheaf of folders to watch for new mail. But the most irritating aspect of everywhere email with multiple clients is the lack of standardisation of folder names. Oh yes, there’s always an INBOX. But schizophrenia sets in around the Deleted Items folder, which likes to be Trash now and then. And that email I just dispatched – was it Sent? Or a Sent Item? I’m sure we all agree that Spam is also Junk, but at the risk of being accused of folderism, c’mon, won’t one folder do?

Having the ability to create folders that are instantly available to all my clients is great, truly. But the default four – Inbox, Sent, Trash and Junk – please let us all agree on these. I for one don’t want seven folders for each account where four will do.

Posted on January 28, 2010 at 8:41 pm by mcmlxxii · Permalink · Leave a comment
In: Uncategorized · Tagged with: , , , , , , , ,

Siemens SE 587 Dynamic DNS Update script

Quick script I knocked up to update dynamic dns record at freedns.afraid.org, querying the router for its IP address. Uses expect to login via telnet to the router and curl to GET the http update url.

#!/bin/bash
# Siemens SE 587 freedns update script
# Jonathan Cutting mcmlxxii.co.uk
# 20/9/2009

# Config
router_login="your_login_name"
router_password="your_login_password"
router_address="192.168.1.1"
afraid_url="your_dynamic_dns_url"
afraid_update_url="http://freedns.afraid.org/dynamic/update.php?YOUR_UPDATE_CODE"
# End config

dns_record=$(dig +short $afraid_url)
ip_address=$(expect -c "
    set timeout 15
    spawn telnet $router_address
    expect gin:
    send \"$router_login\r\"
    expect word:
    send \"$router_password\r\"
    expect >
    send \"ip show interface ipwan\r\"
    expect >
    exit
" | grep Ipaddr | awk '{print $3}' | sed -e 's/^M//')

if [ $ip_address != $dns_record ]
then
    date
    curl $afraid_update_url
fi

Posted on September 20, 2009 at 10:07 am by mcmlxxii · Permalink · Leave a comment
In: Linux · Tagged with: , , , , , , , , ,

AR5008 and Network Manager.

In both Ubuntu Jaunty and now Karmic, I have been experiencing pretty dreadful wireless performance using a combination of the Atheros AR5008 chipset and the default GNOME connection management tool Network Manager. I have read elsewhere that Network Manager scans at regular intervals for available networks in the vicinity, which appears to have the effect of disassociating the AR5008 from the current access point, and this does indeed seem to be what is happening.

In order to test the theory, I installed WICD instead, as I have in the past, and once again WICD fixed the problem. I’m not sure why the WICD team just seem to be able to get wireless to work where Network Manager boys persistently struggle, and WICD lacks the additional functionality of 3G connection management, but it just bloody works and that’s the most important feature of a connection manager.

I’ve been using WICD on and off for some time, and I’m impressed with the speed it has developed. It also looks a lot slicker than it did in the early days, something that has not gone unnoticed in the Ubuntu camp as it’s now available in the repositories. One command,

sudo apt-get install wicd

now ditches Network Manager and installs WICD. If you’re having problems with the AR5008 in Ubuntu, it’s well worth a try.

Posted on July 4, 2009 at 6:36 am by mcmlxxii · Permalink · Leave a comment
In: Uncategorized · Tagged with: , , , , , , ,

Turning Firefox into a web screensaver using a bash script

There’s a little program available for windows that lets you turn your browser into a screensaver, looping through various web content. However, there are 2 things wrong with it. Firstly it costs money. Secondly it doesn’t run on linux.

So what? – we have bash – and after a bit of digging around this morning and combining a few bits and pieces this is my version for Ubuntu :)

Firstly, in order to run firefox full screen we need the AutoHide plugin, which appears to have been written by someone with an interesting sense of humour.

Secondly, a small alteration needs to be made to the  javascript prefs file (.mozilla/firefox/$profile/prefs.js, $profile = your profile). THIS MUST BE DONE WITH THE BROWSER CLOSED as Firefox overwrites the file on shutdown. Add these two lines at the end of the file:

user_pref("browser.link.open_external", 1);
user_pref("browser.link.open_newwindow", 1);

Now that’s done there’s just a little bash script. Feel free to hack but if you improve it please let me know! I just saved the following few lines as a file “Webscreen” in my home directory:

#!/bin/bash

remoteclient=$(find /usr/lib/ -type f -name mozilla-xremote-client | grep -m 1 xulrunner)

if [ `ps -e | grep firefox | wc -l` -eq 0 ]; then

    /usr/bin/firefox -fullscreen &
    sleep 5

fi

while [ `ps -e | grep firefox | wc -l` -gt 0 ]; do

    urls=$(cat /home/huff/Desktop/pages)

    for i in $urls
        do
        $remoteclient -a firefox "openurl($i)"

        if [ $? -gt 0 ]; then
            echo "Firefox not running or ignoring me, bailing out...."
            killall firefox
            exit 0
        fi
        sleep 15
        done
done
exit 0

Note the path to the mozilla-xremote-client – this is correct on Ubuntu Jaunty but I had to use find to well, you know, find it:

find /usr/lib -iname \*mozilla-xremote\*

As can be seen the script takes the pages you want to cycle through from a text file called (I felt quite pleased with this) “pages” on the Desktop, one url on each line such as:

http://bbc.co.uk

http://flickr.com

http://yoursite.whatever.com

and scrolls through the selection every 15 seconds.

The last detail is to

chmod +x ~/Webscreen

and add a Custom Application Launcher to the panel. Thanks to mozilla for continuing the command line options started by Netscape and the cool AutoHide plugin, this was pretty easy. Hope it helps someone.

Posted on April 19, 2009 at 9:44 pm by mcmlxxii · Permalink · 2 Comments
In: Linux · Tagged with: , , , , , , ,

Gedit document words autocompletion plugin

Gedit autocompletion plugin in action

I followed a submission to reddit the other day highlighting a few choice plugins for gedit, as I am fond of using the default GNOME text editor. One plugin in particular caught my eye, the document words autocompletion plugin, written by Perriman. Retyping my inventive variable names (not to mention the oft flowery default php function names) is both error-prone and onerous and this plugin is the perfect remedy.

The following applies to Ubuntu Intrepid. I’m using 64 bit, but there’s no difference for 32 bit.

The plugin is not packaged in with the gedit-plugins package and needs to be compiled. It depends on quite a few packages. I chose to cheat a little when installing the required development libraries by first installing the build dependencies for gedit itself. If you haven’t already installed it, the build-essential package will install the most commonly used compilation tools too:

sudo apt-get install build-essential
sudo apt-get build-dep gedit gedit-plugins

Then download the source. The document auto completion plugin depends on Perriman’s gtksourcecompletion, which also needs to be compiled first. The source is available from this Sourceforge page.

Once extracted and in the directory:

./configure --prefix=/usr
make
sudo make install

The plugin itself is also on Sourceforge, the 0.51 version is now on the download page.  Again, once extracted and in the directory:

./configure --prefix=/usr
make
sudo make install

and assuming there are no errors, the plugin should appear in the gedit plugins list (Edit > Preferences > Plugins). Now all I need to do it try to train my left hand pinky not to keep stabbing the tab key for autocompletion!

Posted on February 1, 2009 at 12:22 am by mcmlxxii · Permalink · Leave a comment
In: Linux · Tagged with: , , , , , , , , , ,

PHP class using Imagick – resize, reflect or drop shadow

Imagick used to generate reflectionI’ve been spending a bit of time getting to know PHP classes over the Christmas holiday, and I’ve written a couple to test out my knowledge.
The first is an image uploading class, which checks for various problems with files prior to moving them to a destination directory. It checks:

before moving the file. The next class gives various options for manipulating the image, resizing, rounding corners, adding a reflection etc. all using the Imagick class, which is installed with php5-imagick (available from the ubuntu repos and other reputable linux software emporiums!). The reflection and drop shadow parts of the class owe a great deal to Mikko Koppanen who provides some great Imagick examples and code snippets on his blog. I’ve uploaded the classes, including an index file that can be used as an example in the absence of proper documentation!

I’ve uploaded a working version of the test files shown below as a demo to a website of mine: try it here.

Available to dowload as a zip archive including the four empty directories the example script needs to run. Any suggestions for improvement gladly received.

Posted on January 6, 2009 at 3:19 pm by mcmlxxii · Permalink · 2 Comments
In: Linux · Tagged with: , , , , , , , , ,

Nvidia 180 on Ubuntu Intrepid Ibex

EDIT: It seems the packages needed are in Intrepid updates now, so as long as they are enabled in System > Applications > Software Sources they should be installed with a simple sudo apt-get update && sudo apt-get install nvidia-glx-180

As a long-time (since Gutsy) follower of Ubuntu bug 99508, Gnome-terminal showing titlebar problems the one about the badly drawn window decoration (see right), I was thrilled to see that Nvidia’s 180 Beta driver fixed the problem. The driver is packaged up and available in the alpha of Jaunty’s next release, 9.04. However, running the alpha as your main OS is folly, not to mention a pain in the butt if you just want to get something done and it’s a bit broken at that moment.

One can always install nvidia’s driver from a shell using the installer provided, but I’m always happier using a .deb, and luckily the 180 debs are coming to Intrepid’s backports. Just not yet. So if you want to try the 180 driver, you can use the Jaunty .debs.

compizI’ve tested it on my laptop under Intrepid, with its integral Nvidia 6100 Go chipset, and it works very well. Some Jaunty testers have reported increased temperatures and odd black spots, but all is ok here. In fact I ran a full screen video on each desktop under compiz (left) without issue.
The debs are available from the Jaunty repos, and the packages required are nvidia-glx-180 and nvidia-180-kernel-source. At present, these contain the 180.11 beta driver – there is a newer one available from nvidia and no doubt the packages in the Jaunty repos will be updated shortly. Once downloaded, a few commands (i386 users will need to alter the architecture part of the filename):

sudo apt-get remove nvidia-glx-177
cd Desktop (if this is where the debs are)
sudo dpkg -i nvidia-180-kernel-source_180.11-0ubuntu1_amd64.deb
sudo dpkg -i nvidia-glx-180_180.11-0ubuntu1_amd64.deb

And a reboot and (fingers x!) you’re done :)

Posted on December 26, 2008 at 12:11 am by mcmlxxii · Permalink · 4 Comments
In: Linux · Tagged with: , , , , , , , ,