Interphero Miscellany

Hopefully something good will come of this…

Interphero Miscellany RSS Feed
 
 
 
 

Refresh conky when Network Becomes Available

For those of you using conky, you probably already realize that it allows you to pull a lot of useful information from other machines, or Internet sources, such as Google Calendar or Remember the Milk.  But, those pieces of information aren’t typically polled very often so lapses in network connectivity can cause those portions of your conky display to remain un-updated or showing blank, even after you regain network connectivity.  Fortunately, Debian based systems provide a script directory that is executed whenever a network interface is brought up, i.e., it regains network connectivity.  This directory is: /etc/network/if-up.d/.  Copy the following to a script in the directory and it will update all of your conky instances every time you regain network connectivity:

#! /bin/bash
killall -SIGUSR1 conky

Don’t forget to change the ownership to root:root and to set the permissions to 755.

Fix it: anacron doesn’t run after resuming from suspend

Anacron is a very useful tool for systems that aren’t left on constantly.  It works in conjunction with cron to make sure that your scheduled jobs get run, even if your computer is off when they are supposed to run.  Essentially, anacron will wait for a set period after your computer is turned back on, then it will run any jobs that were supposed to be run.  Tux Radar has a great, in-depth article about how they interact.

I personally use anacron on my HTPC (an Acer Aspire Revo), which is running XBMC 9.11, which is based on Ubuntu 9.10.  Anacron was not installed by default, so if you are running a similar setup, you can install it by running the following from the command line:

sudo apt-get install anacron

I am in the process of setting my HTPC to go into standby when I’m not using it, as opposed to leaving it on all of the time.  Obviously, having the HTPC in standby most of the time would interfere with my cron jobs.  One job in particular – updating my XBMC media library – is important, and needs to be run daily.  Luckily, anacron comes setup, out of the box, to run not just when you reboot the machine, but also when it resumes from standby.  Unfortunately, an issue exists that was preventing anacron from running – both at startup and when resuming from standby.

It turns out that anacron will not run if your computer is operating on battery power.  I’m assuming that the idea was that you don’t want to burn precious laptop battery power on background tasks.  But my HTPC was reporting that it wasn’t on AC power, even though it is incapable of operating any other way!  This was preventing anacron from running my jobs.  I was able to see the behavior by parsing my /var/log/syslog:

Jul  9 11:39:29 ***** anacron[2577]: Anacron 2.3 started on 2010-07-09
Jul  9 11:39:29 ***** anacron[2577]: Will run job `cron.daily’ in 5 min.
Jul  9 11:39:29 ***** anacron[2577]: Jobs will be executed sequentially
Jul  9 11:39:29 ***** init: anacron main process (2577) killed by TERM signal

As you can see, the anacron process was being started, and then immediately killed, because the HTPC thought that it was running on battery.  After a little more digging, I determined that the culprit was a script named on_ac_power.  On my system, this script was located in two locations: /sbin/ and /usr/bin/.  To fix the issue, I simply replaced both instances with my own on_ac_power script which contains the following 2 lines:

#!/bin/sh
return 0

This simply returns the value 0, which corresponds to the computer being on AC power.  Make sure to set the ownership for the file to root:root and the permissions to 755.  After making the replacement, anacron worked like a champ!

Ubuntu 10.04: Touchpad Only Works on Login Screen

For some reason, my laptop touchpad stopped working in Ubuntu 10.04, but would work on the login screen.  Here is a quick fix, just type the following command into a terminal window:

gconftool-2 –set –type boolean /desktop/gnome/peripherals/touchpad/touchpad_enabled true

Gmail on Postfix: Updating your Certificates

There are many guides on the web for setting up a postfix mail server to work with gmail, for example:

http://www.marksanborn.net/linux/send-mail-postfix-through-gmails-smtp-on-a-ubuntu-lts-server/

I have a separate gmail account for sending server notifications, such as mdadm failures, SMART warnings, etc.  Step 4 of the guide given above involves copying the Thawte Premium Server Certificate Authority to the end of your server certificate.  Recently, my setup stopped working and I noticed the following errors in /var/log/mail.info:

Jun 11 03:47:38 ******* postfix/smtp[2496]: certificate verification failed for smtp.gmail.com[74.125.113.109]:587: untrusted issuer /C=US/O=Equifax/OU=Equifax Secure Certificate Authority
Jun 11 03:47:38 ******* postfix/smtp[2452]: Untrusted TLS connection established to smtp.gmail.com[74.125.113.109]:587: TLSv1 with cipher RC4-MD5 (128/128 bits)
Jun 11 03:47:38 ******* postfix/smtp[2452]: C702D32C1A7: to=<*******>, relay=smtp.gmail.com[74.125.113.109]:587, delay=420914, delays=420912/0.08/2.5/0, dsn=4.7.5, status=deferred (Server certificate not trusted)
Jun 11 03:47:38 ******* postfix/smtp[2506]: certificate verification failed for smtp.gmail.com[74.125.113.109]:587: untrusted issuer /C=US/O=Equifax/OU=Equifax Secure Certificate Authority
Jun 11 03:47:38 ******* postfix/smtp[2514]: certificate verification failed for smtp.gmail.com[74.125.113.109]:587: untrusted issuer /C=US/O=Equifax/OU=Equifax Secure Certificate Authority
Jun 11 03:47:38 ******* postfix/smtp[2483]: Untrusted TLS connection established to smtp.gmail.com[74.125.113.109]:587: TLSv1 with cipher RC4-MD5 (128/128 bits)
Jun 11 03:47:38 ******* postfix/smtp[2496]: Untrusted TLS connection established to smtp.gmail.com[74.125.113.109]:587: TLSv1 with cipher RC4-MD5 (128/128 bits)

It turns out that gmail now uses a different Certificate Authority: Equifax Secure Certificate Authority.  So, to get things working again, simply use the Equifax certificate in step 4.  The Equifax Secure Certificate Authority can be found here:

https://www.geotrust.com/resources/root-certificates/index.html

Ubuntu 10.04: Why is ksmd eating CPU cycles?

If you use KVM virtualization, under Ubuntu 10.04 Server LTS, with more than one virtual host running at a time, you may have noticed ksmd eating a lot of CPU cycles.  This behavior was not present under 8.04 Server LTS.  Apparently, the kmsd functionality was enabled by default in 10.04.  KSM – Kernel Samepage Merging – merges memory pages between virtual hosts to save space.  Unfortunately, for some, it also utilizes a lot of CPU resources to perform this function.  For my use case, I don’t care about the amount of RAM occupied by my virtual hosts, indeed, I installed far more RAM than I need in my server so that I don’t have to worry about a lack of RAM.  If you would like to disable ksmd, edit your /etc/default/qemu-kvm file as follows:

# To disable qemu-kvm’s page merging feature, set KSM_ENABLED=0 and
# sudo restart qemu-kvm

KSM_ENABLED=0
#SLEEP_MILLISECS=2000

Then, as the comments in the file state, restart qemu-kvm.

Of Gateways and Metric Values

I recently diagnosed an interesting issue regarding the default gateway on my server.  I run several network adapters on my server, on different subnets, mostly for the purpose of separating virtual machine traffic from traffic native to the server itself.  After upgrade from Ubuntu Server 8.04 LTS to 10.04 LTS, I noticed several strange issues:

  • Using my VPN connection, I could connect to every machine on my network but the server
  • My postfix server (which relays server alert mails through gmail) stopped working
  • I couldn’t reach the Internet (I didn’t notice this because I use package-cache)

My first thought was to make sure that none of my networking related files changed (e.g., /etc/network/interfaces), but they weren’t touched during the upgrade.  I then followed some guides on the Internet related to network troubleshooting.  The route command, in particular, was of interest, however the output looked correct.  I had a route from the native network adapter to the Internet, through my gateway.  What’s more, I was able to ping my gateway.  But, just to be sure, I tried the following command, which adds a default route:

sudo route add default gw 192.168.1.1 eth-native

Lo and behold, everything worked and I was able to reach the Internet.  I re-ran the route command and I had a second route to my gateway, but this time, it had a metric of 0.  Metric, apparently, is used to determine the priority of each gateway, and accordingly which one to use as the default.  Prior to making the change, all of my subnets had a metric of 100.  Something must have changed between Ubuntu 8.04 and 10.04 to make this difference.

To make the fix permanent, I added metric 0 under my native network adapter in the /etc/network/interfaces file.

Installing Brother Printer Drivers in Ubuntu 10.04

As I posted about earlier, Brother’s printer drivers are superior to their open source counterparts in terms of speed.  The open source driver for my printer – HL-2170w – is essentially unusable with PDFs as printing takes 4-5 minutes per page.  I did a fresh install of Ubuntu 10.04 and was unable to get the Brother printer driver working.  The issue is that Ubuntu 10.04 does not have a /usr/share/cups/model/ directory, which is where the CUPS Wrapper installs the PPD file.  Luckily, the fix is simple:

sudo mkdir /usr/share/cups/model/

Delete Gnome Thumbnails on Shutdown

Gnome saves thumbnails for most document types.  This process can speed up subsequent viewing of files, but it can also be problematic:

  1. The number of files is not limited (this can be addressed with gnome-tweak) nor is the overall space occupied by thumbnails.
  2. Thumbnails leave a trail of what you have been downloading or looking at (cough porn cough).

So I put together this really simple script to delete all of my thumbnails at shutdown (replace USERNAME with your username):

#!/bin/sh
#Delete all USERNAME thumbnails when shutting down
rm -rf /home/USERNAME/.thumbnails/normal/*
rm -rf /home/USERNAME/.thumbnails/fail/gnome-thumbnail-factory/*

Place this script in the /etc/init.d/ directory and make sure that it is executable by root by issuing chmod 755.  Then, create symbolic links to the correct run levels (0 and 6):

sudo ln -s /etc/init.d/delete-USERNAME-thumbs /etc/rc0.d/K10delete-USERNAME-thumbs

sudo ln -s /etc/init.d/delete-USERNAME-thumbs /etc/rc6.d/K10delete-USERNAME-thumbs

Starting Conky with Gnome

Conky is an awesome way to add some nerd bling to your Linux desktop.  Conky can be started by adding it to System->Preferences->Startup Applications.  But in some cases, mine included, Conky won’t draw properly.  In my case, Conky was appearing as a window over the desktop, blocking part of the panel.  To correct this, you simply need to create a script that delays Conky startup until after the other Gnome components are loaded.  The script below will delay starting Conky for 20 seconds:

#!/bin/sh
#Delay conky start for windows to be drawn
sleep 20s
conky &

Get the Windows 7 Aero Snap Feature in Ubuntu

http://www.omgubuntu.co.uk/2009/11/aero-snap-ubuntu-linux.html

 

July 2010
M T W T F S S
« Jun    
 1234
567891011
12131415161718
19202122232425
262728293031