Index: /trunk/Monitoring/Failover/failover
===================================================================
--- /trunk/Monitoring/Failover/failover	(revision 840)
+++ /trunk/Monitoring/Failover/failover	(revision 840)
@@ -0,0 +1,51 @@
+#!/usr/bin/python -u
+# -*- coding: ISO-8859-1 -*-
+
+##################################
+#  @program        smon
+#  @description    simulation monitor
+#  @copyright      Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. 
+#                             All Rights Reservedâ
+#  @svn_file       $Id: failover 2545 2013-02-01 09:58:10Z jripsl $
+#  @version        $Rev: 2545 $
+#  @lastrevision   $Date: 2013-02-01 10:58:10 +0100 (Fri, 01 Feb 2013) $
+#  @license        CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE)
+##################################
+
+from smon import dao
+
+class Failover():
+	pass
+ 
+def main():
+
+	# parse args
+	parser = argparse.ArgumentParser(prog='failover')
+	parser.add_argument('-v', dest='verbose',required=False,action='store_true')
+	args = parser.parse_args()
+
+	# check
+	if not os.path.exists(SMON.smon_home):
+		sys.exit(1)
+
+	# open DB connections
+	
+	# initialize logger
+
+	# 
+
+
+	# close DB connections
+
+
+if __name__ == '__main__':
+	try:
+		main()
+
+		sys.exit(0)
+
+	except Exception, e:
+
+		#traceback.print_exc()
+
+		sys.exit(1)
Index: /trunk/Monitoring/README
===================================================================
--- /trunk/Monitoring/README	(revision 840)
+++ /trunk/Monitoring/README	(revision 840)
@@ -0,0 +1,7 @@
+Broker      Message transfer system
+CNClient    AMQP client running on the computing node ("CNClient" stands for Computing Node client)
+Failover    Failover daemon
+smon        Python package with common code ("smon" stands for Simulation MONitoring)
+Watch       Watch daemon
+RunChecker  Running simulation checker
+README      This file
Index: /trunk/Monitoring/RunChecker/runchecker
===================================================================
--- /trunk/Monitoring/RunChecker/runchecker	(revision 840)
+++ /trunk/Monitoring/RunChecker/runchecker	(revision 840)
@@ -0,0 +1,54 @@
+#!/usr/bin/python -u
+# -*- coding: ISO-8859-1 -*-
+
+##################################
+#  @program        smon
+#  @description    simulation monitor
+#  @copyright      Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. 
+#                             All Rights Reservedâ
+#  @svn_file       $Id: runchecker 2545 2013-02-01 09:58:10Z jripsl $
+#  @version        $Rev: 2545 $
+#  @lastrevision   $Date: 2013-02-01 10:58:10 +0100 (Fri, 01 Feb 2013) $
+#  @license        CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE)
+##################################
+
+from smon import dao
+
+class RunChecker():
+
+	@classmethod
+	def check(cls):
+		simulation=dao.getSimulation()
+ 
+def main():
+
+	# parse args
+	parser = argparse.ArgumentParser(prog='runchecker')
+	parser.add_argument('-v', dest='verbose',required=False,action='store_true')
+	args = parser.parse_args()
+
+	# check
+	if not os.path.exists(SMON.smon_home):
+		sys.exit(1)
+
+	# open DB connections
+	
+	# initialize logger
+
+	# 
+
+
+	# close DB connections
+
+
+if __name__ == '__main__':
+	try:
+		main()
+
+		sys.exit(0)
+
+	except Exception, e:
+
+		#traceback.print_exc()
+
+		sys.exit(1)
Index: /trunk/Monitoring/Watch/watch
===================================================================
--- /trunk/Monitoring/Watch/watch	(revision 840)
+++ /trunk/Monitoring/Watch/watch	(revision 840)
@@ -0,0 +1,62 @@
+#!/usr/bin/python -u
+# -*- coding: ISO-8859-1 -*-
+
+##################################
+#  @program        smon
+#  @description    simulation monitor
+#  @copyright      Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. 
+#                             All Rights Reservedâ
+#  @svn_file       $Id: watcher 2545 2013-02-01 09:58:10Z jripsl $
+#  @version        $Rev: 2545 $
+#  @lastrevision   $Date: 2013-02-01 10:58:10 +0100 (Fri, 01 Feb 2013) $
+#  @license        CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE)
+##################################
+
+from smon import dao
+
+class Watcher():
+
+	@classmethod
+	def get_fake_progress_messages(cls):
+		pass
+
+	@classmethod
+	def start(cls):
+		dao.insert_progress_messages(cls.get_fake_progress_messages())
+
+	@classmethod
+	def stop(cls):
+		pass
+ 
+def main():
+
+	# parse args
+	parser = argparse.ArgumentParser(prog='watcher')
+	parser.add_argument('-v', dest='verbose',required=False,action='store_true')
+	args = parser.parse_args()
+
+	# check
+	if not os.path.exists(SMON.smon_home):
+		sys.exit(1)
+
+	# open DB connections
+	
+	# initialize logger
+
+	# 
+
+
+	# close DB connections
+
+
+if __name__ == '__main__':
+	try:
+		main()
+
+		sys.exit(0)
+
+	except Exception, e:
+
+		#traceback.print_exc()
+
+		sys.exit(1)
Index: /trunk/Monitoring/smon/__init__.py
===================================================================
--- /trunk/Monitoring/smon/__init__.py	(revision 840)
+++ /trunk/Monitoring/smon/__init__.py	(revision 840)
@@ -0,0 +1,12 @@
+# -*- coding: ISO-8859-1 -*-
+
+##################################
+# @program        smon
+# @description    simulation monitor
+# @copyright      Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. 
+# 						 All Rights Reservedâ
+# @svn_file       $Id: __init__.py 1112 2011-12-15 05:03:44Z jripsl $
+# @version        $Rev: 1112 $
+# @lastrevision   $Date: 2011-12-15 06:03:44 +0100 (jeu. 15 dÃ©c. 2011) $
+# @license        CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE)
+##################################
Index: /trunk/Monitoring/smon/dao.py
===================================================================
--- /trunk/Monitoring/smon/dao.py	(revision 840)
+++ /trunk/Monitoring/smon/dao.py	(revision 840)
@@ -0,0 +1,49 @@
+# -*- coding: ISO-8859-1 -*-
+
+##################################
+#  @program        smon
+#  @description    simulation monitor
+#  @copyright      Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. 
+#                             All Rights Reservedâ
+#  @svn_file       $Id: dao.py 2585 2013-03-24 04:09:22Z jripsl $
+#  @version        $Rev: 2585 $
+#  @lastrevision   $Date: 2013-03-24 05:09:22 +0100 (Sun, 24 Mar 2013) $
+#  @license        CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE)
+##################################
+
+from logger import *
+
+class DAO(Database,Logger):
+	message_columns="id,name,timestamp,nested_level,simulation_id"
+
+	@classmethod
+	def getMessageFromResultSet(self,rs):
+		return Message(id=rs[0],name=rs[1],timestamp=rs[2],nested_level=rs[3],simulation_id=rs[4])
+
+	@classmethod
+	def addMessage(self,message,con):
+		c = con.cursor()
+
+		c.execute("insert into message (id,name,timestamp,nested_level,simulation_id) values (?,?,?,?,?)",(m.name,m.timestamp,m.nested_level,m.simulation_id))
+
+		m.id=c.lastrowid
+
+		c.close()
+
+	@classmethod
+	def getMessages(self):
+		messages=[]
+
+		c = self._conn.cursor()
+
+		q="select %s from message order by timestamp asc" % (self.message_columns)
+		c.execute(q)
+
+		rs=c.fetchone()
+		while rs!=None:
+			messages.append(self.getMessageFromResultSet(rs))
+			rs=c.fetchone()
+
+		c.close()
+
+		return messages
Index: /trunk/Monitoring/smon/db.py
===================================================================
--- /trunk/Monitoring/smon/db.py	(revision 840)
+++ /trunk/Monitoring/smon/db.py	(revision 840)
@@ -0,0 +1,73 @@
+# -*- coding: ISO-8859-1 -*-
+
+##################################
+#  @program        smon
+#  @description    simulation monitor
+#  @copyright      Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. 
+#                             All Rights Reservedâ
+#  @svn_file       $Id: db.py 2585 2013-03-24 04:09:22Z jripsl $
+#  @version        $Rev: 2585 $
+#  @lastrevision   $Date: 2013-03-24 05:09:22 +0100 (Sun, 24 Mar 2013) $
+#  @license        CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE)
+##################################
+
+from logger import *
+
+class CDatabase():
+	_conn=None
+
+	@classmethod
+	def connect(self):
+
+		# When a database is accessed by multiple connections, and one of the processes
+		# modifies the database, the SQLite database is locked until that transaction is
+		# committed. The timeout parameter specifies how long the connection should wait
+		# for the lock to go away until raising an exception. The default for the timeout
+		# parameter is 5.0 (five seconds).
+		#
+		# more info here => http://www.sqlite.org/faq.html#q5
+		#
+		# we increase the timeout so we are able to use sqlite3 to run manual
+		# query without stopping the daemon
+		#
+		l__timeout=120 # 2 mn
+
+		# Note
+		#  by default, sqlite is in autocommit mode,
+		#  but the sqlite3 python module is *not* in autocommit mode by default
+		#  we don't want autocommit mode, so we leave it at its default, which will result in a plain "BEGIN" statement
+		#  (If you want autocommit mode, then set isolation_level to None)
+
+		# open connection
+		self._conn=sqlite3.connect(self.getDBName(),l__timeout)
+		self._conn.row_factory=sqlite3.Row # this is for "by name" colums indexing
+
+		self.createTables()
+
+	@classmethod
+	def getDBName(self):
+		return SMON.dbfile
+
+	@classmethod
+	def disconnect(self):
+		if self.isConnected():
+			self._conn.close()
+
+		self._conn=None
+
+	@classmethod
+	def isConnected(self):
+		if (self._conn==None):
+			return False
+		else:
+			return True
+
+	@classmethod
+	def createTables(self):
+		c=self._conn.cursor()
+
+		c.execute("create table if not exists message (id INTEGER PRIMARY KEY, name TEXT, timestamp TEXT, nested_level INT, simulation_id INT")
+		c.execute("create index if not exists idx_message_1 on message (timestamp)")
+
+		self._conn.commit()
+		c.close()
Index: /trunk/Monitoring/smon/logger.py
===================================================================
--- /trunk/Monitoring/smon/logger.py	(revision 840)
+++ /trunk/Monitoring/smon/logger.py	(revision 840)
@@ -0,0 +1,58 @@
+# -*- coding: ISO-8859-1 -*-
+
+##################################
+#  @program        smon
+#  @description    simulation monitor
+#  @copyright      Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. 
+#                             All Rights Reservedâ
+#  @svn_file       $Id: logger.py 2010 2012-06-18 14:00:35Z jripsl $
+#  @version        $Rev: 2010 $
+#  @lastrevision   $Date: 2012-06-18 16:00:35 +0200 (lun. 18 juin 2012) $
+#  @license        CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE)
+##################################
+
+import logging
+
+def createLogger(name,fullpath_filename):
+
+	# new logger instance
+	logger = logging.getLogger(name)
+	logger.setLevel(logging.DEBUG)
+
+	# create associated file
+	fh = logging.FileHandler(fullpath_filename)
+	fh.setLevel(logging.DEBUG)
+
+	# create formatter
+	formatter = logging.Formatter('%(asctime)-15s %(code)s - %(message)s')
+	fh.setFormatter(formatter)
+
+	# binding
+	logger.addHandler(fh)
+
+	return logger
+
+# this class must be inherited by classes which need logging feature
+class Logger():
+	_logger=None
+
+	@classmethod
+	def logAndStdout(cls,errcode,errmsg):
+		cls.stdout(errcode,errmsg)
+		cls.log(errcode,errmsg)
+
+	@classmethod
+	def stdout(cls,errcode,errmsg):
+		print "%s - %s"%(errcode,errmsg)
+
+	@classmethod
+	def log(cls,errcode,errmsg):
+		cls._logger.info(errmsg,extra={'code' : errcode})
+
+	@classmethod
+	def getLogger(cls):
+		return cls._logger
+
+	@classmethod
+	def setLogger(cls,logger):
+		cls._logger=logger
Index: /trunk/Monitoring/smon/smon.py
===================================================================
--- /trunk/Monitoring/smon/smon.py	(revision 840)
+++ /trunk/Monitoring/smon/smon.py	(revision 840)
@@ -0,0 +1,20 @@
+# -*- coding: ISO-8859-1 -*-
+
+##################################
+#  @program        smon
+#  @description    simulation monitor
+#  @copyright      Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. 
+#                             All Rights Reservedâ
+#  @svn_file       $Id: smon.py 2599 2013-03-24 19:01:23Z jripsl $
+#  @version        $Rev: 2599 $
+#  @lastrevision   $Date: 2013-03-24 20:01:23 +0100 (Sun, 24 Mar 2013) $
+#  @license        CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE)
+##################################
+
+class SMON():
+
+	@classmethod
+	def init(self):
+		self.smon_home=os.environ['SMON_HOME']
+		self.log_dir="%s/log"%self.smon_home
+		self.dbfile="%s/db/smon.db"%self.smon_home
Index: /trunk/Monitoring/smon/types.py
===================================================================
--- /trunk/Monitoring/smon/types.py	(revision 840)
+++ /trunk/Monitoring/smon/types.py	(revision 840)
@@ -0,0 +1,49 @@
+# -*- coding: ISO-8859-1 -*-
+
+##################################
+#  @program        smon
+#  @description    simulation monitor
+#  @copyright      Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. 
+#                             All Rights Reservedâ
+#  @svn_file       $Id: types.py 2599 2013-03-24 19:01:23Z jripsl $
+#  @version        $Rev: 2599 $
+#  @lastrevision   $Date: 2013-03-24 20:01:23 +0100 (Sun, 24 Mar 2013) $
+#  @license        CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE)
+##################################
+
+CSTE_SAMPLE="2.2"
+
+class SMONException(Exception):
+	code=None
+	msg=None
+
+	def __init__(self, code=None,msg=None):
+		self.code=code
+		self.msg=msg
+
+    def __str__(self):
+        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+
+class Tree():
+
+    def __init__(self,**kw):
+		pass
+
+    def __str__(self):
+        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+
+class SimulationTree(Tree):
+
+    def __init__(self,**kw):
+		pass
+
+    def __str__(self):
+        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+
+class SimulationTrees():
+
+    def __init__(self,**kw):
+        self.sample=kw.get("sample",[])
+
+    def __str__(self):
+        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
