Quantcast
Channel: openSUSE Planet - Global
Viewing all articles
Browse latest Browse all 23330

Fred Blaise: Get desktop notification for filesystem usage

$
0
0

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/alert_fs.sh in my case.

#!/bin/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
PCT_THRESHOLD=80
ALERT_TITLE="WARNING: Filesystem almost full"
(
df -h |grep ^/dev |awk {'print $1,$5,$6'} | \
while read devfs pctused mntpoint; do                                                                               
        pctnum=${pctused%\%}
        if [[ "${pctnum}" -ge "${PCT_THRESHOLD}" ]]; then
                kdialog --title "${ALERT_TITLE}" --passivepopup "${devfs} mounted on ${mntpoint} is at ${pctused}."
        fi     
done

Don’t forget to make this shell script executable.

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

-*/10  * * * *	fblaise /home/fblaise/bin/alert_fs.sh

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:

FS passive notification

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!

Share


Viewing all articles
Browse latest Browse all 23330


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>