- Home
- Contact
-
Articles / Code
- HTML/CSS (2)
-
Scripts (17)
- Twitter & bash
- Generate sitemaps
- random floating point in bash
- Gmail script
- Python http POST requests
- Bashrc enhancements
- commandline <> nautilus
- Word Definitions
- Synonyms
- mysqld monitor
- remote server
- links and emailaddresses
- Apache Analyser
- remote ipaddress
- OOP Python
- mysql tuning
- diskspace notification
- Server Configuration (6)
- ICT-security (2)
notification if disk is (almost) full
» Articles / Code » Scripts » notification if disk is (almost) full
Notify when running out of diskspace
I wanted to have a nice little application that would notify me when I'm running low on resources and my diskspace is getting less then 100Mb.
so I made this little Python script that runs in the background and shows a popup whenever my disk is getting full again.
#!/usr/bin/env python
try:
import gtk, pygtk, os, os.path, pynotify
pygtk.require('2.0')
except:
print "Error: need python-notify, python-gtk2 and gtk"
import time
def freespace(p):
s = os.statvfs(p)
a = (s.f_bsize * s.f_bavail) / 1048576
return a
while True:
while freespace("/") < 100:
freespace_ = str(freespace("/"))
pynotify.init('test')
msg = pynotify.Notification("Running out of resources \nCurrently available diskspace", freespace_+"MB" )
msg.show()
time.sleep(60)
time.sleep(60)