# Defaults
debug = False
verbose = 0
-datafile = "/var/lib/misc/swapmon.dat"
-
+DATAFILE = "/var/lib/misc/swapmon.dat"
+VERSION = "$Id$"
# Seconds between process analysis
period = 30
--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))
+""".lstrip() % (sys.argv[0], debug, verbose, DATAFILE, format_period(period))
def slicestat(names = None):
"""
pl_mom@pl.
'''
try:
- f = open(datafile, "r+")
+ f = open(DATAFILE, "r+")
if verbose:
- print "Loading %s" % datafile
- (version, slices) = pickle.load(f)
+ print "Loading %s" % DATAFILE
+ (v, slices) = pickle.load(f)
f.close()
# Check version of data file
- if version != "$Id$":
- print "Not using old version '%s' data file %s" % (version, datafile)
+ if v != VERSION:
+ print "Not using old version '%s' data file %s" % (v, DATAFILE)
raise Exception
params = {'hostname': socket.gethostname(),
slicemail(None, rebooted_subject % params, rebooted_body % params)
# Delete data file
- os.unlink(datafile)
+ os.unlink(DATAFILE)
except Exception:
- version = "$Id$"
slices = slicestat()
return slices
"""
Write (slices) to pickled datfile.
"""
- if verbose: print "Saving %s" % datafile
- f = open(datafile, "w")
- pickle.dump((version, slices), f)
+ if verbose: print "Saving %s" % DATAFILE
+ f = open(DATAFILE, "w")
+ pickle.dump((VERSION, slices), f)
f.close()
def main():
# Defaults
- global debug, verbose, datafile
+ global debug, verbose, DATAFILE, VERSION
global period, change_thresh, reset_thresh, reboot_thresh, rss_min, system_slices
# All slices
names = []
elif opt == "-v" or opt == "--verbose":
verbose += 1
elif opt == "-f" or opt == "--file":
- datafile = optval
+ DATAFILE = optval
elif opt == "-s" or opt == "--slice":
names.append(optval)
elif opt == "-p" or opt == "--period":