Ubuntu - Large external USB drive slow to unmount, eject or sync

When using a USB HDD (probably a stick as well), there can be large delays when using a Ubuntu machine while waiting for data to be synced to the disk. After much googling, trying different filesystems and tweaking mount options, the solution that worked was:

echo $((16*1024*1024)) > /proc/sys/vm/dirty_background_bytes
echo $((48*1024*1024)) > /proc/sys/vm/dirty_bytes

Which i found here: http://unix.stackexchange.com/questions/107703/why-is-my-pc-freezing-while-im-copying-a-file-to-a-pendrive/107722#107722 http://lwn.net/Articles/572911/

 

Find all email that a user sent via postfix mail.log

I needed to find all the email that a user sent with only the postfix mail.log. This simple script does that. There is probably an easier way :-)

#!/bin/bash USERNAME=$1 for i in `grep -A2 $USERNAME mail.log | \
grep message-id | cut -d'<' -f2 | cut -d'>' -f1`; \
do grep "$i" /var/log/mail.log | grep "to=" | awk '{ print $7 }' | \
cut -d'<' -f2 | cut -d'>' -f1; done | sort | uniq -c

 

How to get CallerID via http and CDR records working with asterisknow 1.7

We've been using Trixbox for many years as our PABX at iseek computing, but I wasn't happy that it was moving forward nicely as a project, so last time we rebuilt the PABX using AsteriskNOW instead.

It all worked fine, slightly easier that Trixbox perhaps, and no weird forum registration required, and its pretty clean with FreePABX being the main interface.

Monitor per station traffic on local LAN

 

Ever wonder what traffic is eating up all your downloads?

If you have a linux server, you can install a couple of tools to do this.

I initially found vnstat - http://humdi.net/vnstat/ but it doesn't do per ip, so thats no good.

Next I found ntop - http://www.ntop.org/ but it looks quite complicated

I decided to use darkstat - http://dmr.ath.cx/net/darkstat/

It was dead simple to install, has a built in web interface, and works a treat, and uses absolutely minimal cpu.

Wallpaper scaling

I had a whole bunch of wallpapers lying around, but they were all different sizes, which really looks screwy on a dual screen setup.

The attached perl script reads through all images in $HOME/Pictures.original/ and creates new copies in $HOME/Pictures/ as the specified image size in the file.

By setting the image size to exactly the size of one of the dual screen monitors (this assumes identical resolutions on both screens), and running the script, the backgrounds then work nicely.

WD Raptor failure ;-(

Got into the office this morning, and the core vmware host server is down, the mirror for the boot drive barfed at around 60% when synchronising after a power failure.

Oh well, thats what mirroring is for after all, disconnected it and rebooted. nothing. no Grub nada. After running around getting a boot disk organised, making sure grub was installed etc, it STILL didn't work.

WTF!

After a bit more hair tearing, I realised the BIOS had promoted the wrong drive when i removed the dud one. Doh. Of course the data drives dont have grub on them at all.

Web filtering

Recently on a mailing list, somone asked about setting up web filtering for children.

While nothing beats supervision, som fairly effective and simple webfiltering can be setup on a linux based pc by combining squid with the jesred redirector.

Basically, create the jesred files as follows in /etc/squid and add the lines from the bottom file into your squid.conf. This plus std tranparent proxying does quite a good job. Yes, I know theres very easy ways around it, but by the time the kids figure that out, you're not going to stop them anymore ;-)