Created
June 4, 2015 14:11
-
-
Save CTimmerman/0016fc26f784e5ad640c to your computer and use it in GitHub Desktop.
Get and check local and remote (Tomcat) memory usage
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
"""Checks memory percentage of first process by user name. | |
2015-06-04 v1.0 by Cees.Timmerman@nospam | |
Run with `python -m doctest mem_perc.py`. | |
>>> ps_tomcat = ['ps', 'u', '-U', 'tomcat6'] | |
>>> mem_perc(ps_tomcat) < 20 | |
True | |
>>> mem_perc(['ssh', 'other.host'] + ps_tomcat) < 20 | |
True | |
""" | |
import re, subprocess as sub | |
def mem_perc(cmd_list): return float(re.split('\s+', sub.check_output(cmd_list, stderr=sub.STDOUT).split('\n')[1])[3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment