--min-thresh=PERCENT Minimum physical memory utilization to be considered a hog
--system-slice=SLICE System slice that should not be reset
--status Print memory usage statistics and exit
--min-thresh=PERCENT Minimum physical memory utilization to be considered a hog
--system-slice=SLICE System slice that should not be reset
--status Print memory usage statistics and exit
-h, --help This message
""".lstrip() % (sys.argv[0], debug, verbose, DATAFILE, format_period(period))
-h, --help This message
""".lstrip() % (sys.argv[0], debug, verbose, DATAFILE, format_period(period))
# Mandatory fields. xid is a virtual field inserted by vps. Make
# sure cmd is last so that it does not get truncated
# automatically.
# Mandatory fields. xid is a virtual field inserted by vps. Make
# sure cmd is last so that it does not get truncated
# automatically.
- fields = ['pid', 'xid', 'vsize', 'sz', 'rss', 'pmem', 'cmd']
+ fields = ['pid', 'xid', 'vsname', 'vsize', 'sz', 'rss', 'pmem', 'cmd']
- # Replace "0 MAIN" and "1 ALL_PROC" (the special monikers that
- # vps uses to denote the root context and the "all contexts"
- # context) with "0" so that we can just split() on whitespace.
- line = line.replace("0 MAIN", "0").replace("1 ALL_PROC", "0")
-
# Represent process as a dict of fields
values = line.split(None, len(fields) - 1)
if len(values) != len(fields):
# Represent process as a dict of fields
values = line.split(None, len(fields) - 1)
if len(values) != len(fields):
# cannot identify the context of an orphaned (usually dying)
# process. Skip these processes.
if (type(proc['xid']) != int) or (type(proc['vsize']) !=int):
# cannot identify the context of an orphaned (usually dying)
# process. Skip these processes.
if (type(proc['xid']) != int) or (type(proc['vsize']) !=int):
- longopts = ["debug", "verbose", "file=", "slice=", "status", "help"]
+ longopts = ["debug", "verbose", "file=", "slice=", "status", "memstatus", "help"]
longopts += ["period=", "reset-thresh=", "reboot-thresh=", "min-thresh=", "system-slice="]
(opts, argv) = getopt.getopt(sys.argv[1:], "dvf:s:ph", longopts)
except getopt.GetoptError, err:
longopts += ["period=", "reset-thresh=", "reboot-thresh=", "min-thresh=", "system-slice="]
(opts, argv) = getopt.getopt(sys.argv[1:], "dvf:s:ph", longopts)
except getopt.GetoptError, err:
+ elif opt == "--memstatus":
+ (mem, swap) = memtotal()
+ swap_pct = swap_used()
+ print "memory total:", mem
+ print "swap total:", swap
+ print "swap used:", swap_pct
+ sys.exit(0)