-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
35 additions
and
25 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,7 @@ | |
memmon.py -p program1=200MB -p theprog:thegroup=100MB -g thegroup=100MB -a 1GB -s "/usr/sbin/sendmail -t -i" -m [email protected] -n "Project 1" | ||
""" | ||
|
||
import getopt | ||
import os | ||
import sys | ||
import time | ||
|
@@ -90,9 +91,9 @@ | |
from supervisor import childutils | ||
from supervisor.datatypes import byte_size, SuffixMultiplier | ||
|
||
def usage(): | ||
def usage(exitstatus=255): | ||
print(doc) | ||
sys.exit(255) | ||
sys.exit(exitstatus) | ||
|
||
def shell(cmd): | ||
with os.popen(cmd) as f: | ||
|
@@ -333,8 +334,9 @@ def parse_seconds(option, value): | |
usage() | ||
return seconds | ||
|
||
help_request = object() # returned from memmon_from_args to indicate --help | ||
|
||
def memmon_from_args(arguments): | ||
import getopt | ||
short_args = "hcp:g:a:s:m:n:u:" | ||
long_args = [ | ||
"help", | ||
|
@@ -367,7 +369,7 @@ def memmon_from_args(arguments): | |
for option, value in opts: | ||
|
||
if option in ('-h', '--help'): | ||
return None | ||
return help_request | ||
|
||
if option in ('-c', '--cumulative'): | ||
cumulative = True | ||
|
@@ -408,8 +410,9 @@ def memmon_from_args(arguments): | |
|
||
def main(): | ||
memmon = memmon_from_args(sys.argv[1:]) | ||
if memmon is None: | ||
# something went wrong or -h has been given | ||
if memmon is help_request: # --help | ||
usage(exitstatus=0) | ||
elif memmon is None: # something went wrong | ||
usage() | ||
memmon.rpc = childutils.getRPCInterface(os.environ) | ||
memmon.runforever() | ||
|
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
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