git://git.onelab.eu
/
mom.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6a8f86e
)
Made DATAFILE global. Same for VERSION.
author
Faiyaz Ahmed
<faiyaza@cs.princeton.edu>
Tue, 19 Feb 2008 22:54:43 +0000
(22:54 +0000)
committer
Faiyaz Ahmed
<faiyaza@cs.princeton.edu>
Tue, 19 Feb 2008 22:54:43 +0000
(22:54 +0000)
swapmon.py
patch
|
blob
|
history
diff --git
a/swapmon.py
b/swapmon.py
index
da8f3a0
..
b0c3bb3
100755
(executable)
--- a/
swapmon.py
+++ b/
swapmon.py
@@
-35,8
+35,8
@@
from pl_mom import *
# Defaults
debug = False
verbose = 0
# 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
# Seconds between process analysis
period = 30
@@
-263,7
+263,7
@@
Options:
--system-slice=SLICE System slice that should not be reset
--status Print memory usage statistics and exit
-h, --help This message
--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):
"""
def slicestat(names = None):
"""
@@
-465,14
+465,14
@@
def readdat():
pl_mom@pl.
'''
try:
pl_mom@pl.
'''
try:
- f = open(
datafile
, "r+")
+ f = open(
DATAFILE
, "r+")
if verbose:
if verbose:
- print "Loading %s" %
datafile
- (v
ersion
, slices) = pickle.load(f)
+ print "Loading %s" %
DATAFILE
+ (v, slices) = pickle.load(f)
f.close()
# Check version of data file
f.close()
# Check version of data file
- if v
ersion != "$Id$"
:
- print "Not using old version '%s' data file %s" % (v
ersion, datafile
)
+ if v
!= VERSION
:
+ print "Not using old version '%s' data file %s" % (v
, DATAFILE
)
raise Exception
params = {'hostname': socket.gethostname(),
raise Exception
params = {'hostname': socket.gethostname(),
@@
-485,9
+485,8
@@
def readdat():
slicemail(None, rebooted_subject % params, rebooted_body % params)
# Delete data file
slicemail(None, rebooted_subject % params, rebooted_body % params)
# Delete data file
- os.unlink(
datafile
)
+ os.unlink(
DATAFILE
)
except Exception:
except Exception:
- version = "$Id$"
slices = slicestat()
return slices
slices = slicestat()
return slices
@@
-497,15
+496,15
@@
def writedat(slices):
"""
Write (slices) to pickled datfile.
"""
"""
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
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 = []
global period, change_thresh, reset_thresh, reboot_thresh, rss_min, system_slices
# All slices
names = []
@@
-525,7
+524,7
@@
def main():
elif opt == "-v" or opt == "--verbose":
verbose += 1
elif opt == "-f" or opt == "--file":
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":
elif opt == "-s" or opt == "--slice":
names.append(optval)
elif opt == "-p" or opt == "--period":