[prev in list] [next in list] [prev in thread] [next in thread] 

List:       os-sim-commits
Subject:    [Os-sim-commits] agent/ossim_agent Monitor.py,1.24,1.25
From:       David Gil <dvgil () users ! sourceforge ! net>
Date:       2007-01-23 17:16:51
Message-ID: E1H9PGR-0000PQ-Bm () mail ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/os-sim/agent/ossim_agent
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21091

Modified Files:
	Monitor.py 
Log Message:
really fixed monitor expresions


Index: Monitor.py
===================================================================
RCS file: /cvsroot/os-sim/agent/ossim_agent/Monitor.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- Monitor.py	23 Jan 2007 16:30:11 -0000	1.24
+++ Monitor.py	23 Jan 2007 17:16:48 -0000	1.25
@@ -84,21 +84,22 @@
                     str(value))
                 return False
 
-        logger.debug("Monitor expresion evaluation: %s + %s <%s> %s?" %\
-            (str(value), str(arg1), str(cond), str(arg2)))
+        logger.debug("Monitor expresion evaluation: " +\
+            "%s(arg2) <%s> %s(arg1) + %s(value)?" %\
+            (str(arg2), str(cond), str(arg1), str(value)))
 
         if cond == "eq":
             return (int(arg2) == int(arg1) + int(value))
         elif cond == "ne":
             return (int(arg2) != int(arg1) + int(value))
         elif cond == "gt":
-            return (int(arg2) < int(arg1) + int(value))
+            return (int(arg2) > int(arg1) + int(value))
         elif cond == "ge":
-            return (int(arg2) <= int(arg1) + int(value))
-        elif cond == "le":
             return (int(arg2) >= int(arg1) + int(value))
+        elif cond == "le":
+            return (int(arg2) <= int(arg1) + int(value))
         elif cond == "lt":
-            return (int(arg2) > int(arg1) + int(value))
+            return (int(arg2) < int(arg1) + int(value))
         else:
             return False
  
@@ -166,26 +167,20 @@
     # returns True if the condition apply, False in the other case
     def evaluate(self, rule_name):
         
-        if not self.first_value:
+        if self.first_value is None:
             logger.warning("Can not extract value (arg1) from monitor response")
             return True
 
-        # no interval specified, no need to get a second value
-        if not self.watch_rule.dict().has_key('interval'):
-            value = self.first_value
-
-        else:
-            value = None
-            monitor_response = self.get_data(rule_name)
-            if not monitor_response:
-                logger.warning("No data received from monitor")
-                return True
+        value = None
+        monitor_response = self.get_data(rule_name)
+        if not monitor_response:
+            logger.warning("No data received from monitor")
+            return True
 
-            value = self.get_value(monitor_response, rule_name)
-            if not value:
-                logger.warning("Can not extract value (arg2) " +\
-                               "from monitor response")
-                return True
+        value = self.get_value(monitor_response, rule_name)
+        if not value:
+            logger.warning("Can not extract value (arg2) from monitor response")
+            return True
 
         if self.eval_condition(cond = self.watch_rule["condition"],
                                arg1 = self.first_value,
@@ -208,7 +203,8 @@
 
         # get data from plugin (first time)
             if self.first_value is None:
-                if self.watch_rule['absolute'] in ('yes', 'true'):
+                if self.watch_rule['absolute'] in ('yes', 'true') or\
+                   not self.watch_rule['interval']:
                     self.first_value = 0
                 else:
                     monitor_response = self.get_data(rule_name)


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Os-sim-commits mailing list
Os-sim-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/os-sim-commits
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic