Created
March 23, 2012 01:28
-
-
Save meunierd/2166040 to your computer and use it in GitHub Desktop.
vmstat 1 | python watcher.py 12 5000 5
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 python | |
import sys | |
col = int(sys.argv[1]) | |
val = int(sys.argv[2]) | |
limit = int(sys.argv[3]) | |
count = 0 | |
def get_l(): | |
l = sys.stdin.readline().strip() | |
while l.startswith('procs') or l.startswith('r'): | |
l = sys.stdin.readline().strip() | |
return l | |
l = get_l() | |
while l is not None: | |
tokens = l.split() | |
if val < int(tokens[col - 1]): | |
count += 1 | |
if limit <= count: | |
print "Hit Limit." | |
count = 0 | |
else: | |
count = 0 | |
l = get_l() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment