aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunk@stsci.edu>2014-04-13 22:42:30 -0400
committerJoseph Hunkeler <jhunk@stsci.edu>2014-04-13 22:42:30 -0400
commit562cc4cfcd00e65b06c01bd143e6d3b886eca4b0 (patch)
tree5bdf2709fd0cd003ee2df8c440216263c8b4c94f
parentc3babbce22b80b399194d1c3edf3f4179c52b6d4 (diff)
downloadaprio-562cc4cfcd00e65b06c01bd143e6d3b886eca4b0.tar.gz
Add CPU_THRESHOLD uses time_scale_convert function, fixup typos and short attribute names
-rwxr-xr-xaprio.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/aprio.py b/aprio.py
index 097cb73..6af601e 100755
--- a/aprio.py
+++ b/aprio.py
@@ -61,12 +61,12 @@ CONFIG['LOAD_THRESHOLD'] = psutil.cpu_count() / 2
if CONFIG['LOAD_THRESHOLD'] < 1:
CONFIG['LOAD_THRESHOLD'] = psutil.cpu_count()
CONFIG['CPU_THRESHOLD'] = 50.0
-CONFIG['CPUTIME_THRESHOLD'] = ELAPSED.second
+CONFIG['CPUTIME_THRESHOLD'] = '30m'
CONFIG['TIME_SCALE'] = '1w'
CONFIG['POLL'] = 3
CONFIG['TEST_MODE'] = False
CONFIG['VERBOSE'] = False
-CONFIG['QUITE'] = False
+CONFIG['QUIET'] = False
def time_scale_convert(scale_fmt):
"""Converts simple string format to POSIX time
@@ -102,10 +102,10 @@ def time_scale_convert(scale_fmt):
factor = scale_fmt[0:-1]
decimals = 0
- for ch in factor:
- if ch is '.':
+ for char in factor:
+ if char is '.':
decimals += 1
- if ch not in _digits or decimals > 1:
+ if char not in _digits or decimals > 1:
raise ValueError("Invalid time factor: {0}".format(scale_fmt))
if scale not in modifiers.keys():
@@ -267,7 +267,8 @@ def main(args):
continue
for bad in filter_processes(CONFIG['CPU_THRESHOLD'],
- CONFIG['CPUTIME_THRESHOLD'],
+ time_scale_convert(
+ CONFIG['CPUTIME_THRESHOLD']),
user=user):
try:
nice = convert_nice(bad,
@@ -318,8 +319,8 @@ if __name__ == "__main__":
PARSER.add_argument('--cputime-threshold',
'-t',
default=CONFIG['CPUTIME_THRESHOLD'],
- type=float,
- help='Trigger after n seconds')
+ type=str,
+ help='Trigger after {n}{smdwMy} Ex: 1d == 1 day')
PARSER.add_argument('--load-threshold',
'-l',