Get desktop notification for filesystem usage

Here is a little un-intrusive script that will alert you whenever your filesystem is going above a certain percentage threshold.
This was tested under opensuse 12.3, but should really work on any linux running KDE (or at least having the kdialog binary installed).

You can save it under your user’s bin directory, for example /home/fblaise/bin/ in my case.

[sourcecode language=’bash’]

# Fred Blaise
# Cron this script in order to receive passive alerts about filesystem getting full.
# Set PCT_THRESHOLD to your liking

export DISPLAY=:0

ALERT_TITLE=”WARNING: Filesystem almost full”

df -h |grep ^/dev |awk {‘print $1,$5,$6′} |
while read devfs pctused mntpoint; do
if [[ “${pctnum}” -ge “${PCT_THRESHOLD}” ]]; then
kdialog –title “${ALERT_TITLE}” –passivepopup “${devfs} mounted on ${mntpoint} is at ${pctused}.”

Don’t forget to make this shell script executable.

We could then imagine a crontab looking like this, for checking every 10 minutes:

[sourcecode language=’bash’]-*/10 * * * * fblaise /home/fblaise/bin/[/sourcecode]

Whenever one of your filesystem crosses the threshold, a passive box will be displayed. I have my bar on the right side of the screen, and the result is the following:


It is a very basic script. One could add support for choosing what FS types should be monitored, how often to receive notifications. If you do make this better, please share!

Fed up of re-opening your ssh sessions after suspend?

Every morning, when I come to work, there are a set of machines I need to get connected to. Of course, since I s2d or s2r my laptop overnight, the previous day ssh sessions are lost. Even worse, they take time to actually kick me out to my local prompt.

If you’re using gnome-terminal, you can write a small shell script that will open up these sessions for you. All my servers use private/public keys as login method, so with the help of the ssh-agent, it is a straight through login for all servers.

[sourcecode language=’bash’]

GT=`which gnome-terminal`

$GT –window –maximize –profile=prod –title=”serverprod” -e “ssh server1″
–tab –profile=prod –title=”serverprod2” -e “ssh server1″
–tab –profile=dev –title=”serverdev1” -e “ssh server2″
–tab –profile=dev –title=”serverdev2” -e “ssh server2″
–tab –title=”servertest1” -e “ssh server3″
–tab –title=”servertest2” -e “ssh server3”

Looking at splitting your PDF on white pages?

I am scanning PDF using my HP Photosmart premium, but HP software (which provides OCR) doesn’t allow you to create different PDF documents, by separating your docs using a white sheet for example.

What this script does is take a PDF file, search for white sheets (act as separator), and create several PDFs if there are any.

It works on both Windows and Linux, and is written in perl. It is currently a version 0.2. Version 0.3 will be soon to come to fix a couple bugs and make it more reliable.

Style and coding are a little messy, this is quick coding for home use. Bug reports or feature requests welcome!