- getting a weird exception very occasionally while parsing vps output,
authorMark Huang <mlhuang@cs.princeton.edu>
Tue, 2 May 2006 17:23:14 +0000 (17:23 +0000)
committerMark Huang <mlhuang@cs.princeton.edu>
Tue, 2 May 2006 17:23:14 +0000 (17:23 +0000)
  print it

swapmon.py

index af89ef9..655ff47 100755 (executable)
@@ -9,7 +9,7 @@
 # Andy Bavier <acb@cs.princeton.edu>
 # Copyright (C) 2004-2006 The Trustees of Princeton University
 #
-# $Id: swapmon.py,v 1.2 2006/04/28 19:32:18 mlhuang Exp $
+# $Id: swapmon.py,v 1.3 2006/05/01 18:28:01 mlhuang Exp $
 #
 
 import syslog
@@ -187,10 +187,14 @@ def slicestat(names = None):
             if xid is not None:
                 proc['xid'] = xid
 
-        name = bwlimit.get_slice(proc['xid'])
-        if name is None:
-            # Orphaned (not associated with a slice) class
-            name = "%d?" % proc['xid']
+        try:
+            name = bwlimit.get_slice(proc['xid'])
+            if name is None:
+                # Orphaned (not associated with a slice) class
+                name = "%d?" % proc['xid']
+        except Exception, err:
+            print "Warning: Exception received while parsing vps output", err
+            print proc
 
         # Monitor only the specified slices
         if names and name not in names:
@@ -343,7 +347,7 @@ def main():
         (version, slices) = pickle.load(f)
         f.close()
         # Check version of data file
-        if version != "$Id: swapmon.py,v 1.2 2006/04/28 19:32:18 mlhuang Exp $":
+        if version != "$Id: swapmon.py,v 1.3 2006/05/01 18:28:01 mlhuang Exp $":
             print "Not using old version '%s' data file %s" % (version, datafile)
             raise Exception
 
@@ -360,7 +364,7 @@ def main():
         # Delete data file
         os.unlink(datafile)
     except Exception:
-        version = "$Id: swapmon.py,v 1.2 2006/04/28 19:32:18 mlhuang Exp $"
+        version = "$Id: swapmon.py,v 1.3 2006/05/01 18:28:01 mlhuang Exp $"
         slices = {}
 
     # Query process table every 30 seconds, or when a large change in