Created
February 19, 2012 13:43
-
-
Save marcellmars/1863906 to your computer and use it in GitHub Desktop.
Check total memory and if used more than 3.0GB and make desktop notification with programs which use more than 2.0GB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
import commands, pynotify, sys, os, time | |
while 1: | |
lines = commands.getoutput('sudo ps_mem.py').split('\n') | |
total = [float(str(l).split(" ")[-2]) for l in lines if l.startswith(" ") and l.find("GiB")] | |
progs = [str(l).split("=")[1].strip().split(" ") for l in lines if l.find("GiB") != -1 and not l.startswith(" ")] | |
for prog in progs: | |
if float(prog[0]) > 2.0 and total[0] > 3.0: | |
pynotify.init("Memory usage notification") | |
notification = pynotify.Notification(prog[0] + " " + prog[1].replace('\t', ' '), "") | |
notification.show() | |
time.sleep(300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i will never learn how to use web broswer with just few tabs. this is a little daemon which notifies me when things get close to screwed up ;)