Index: /trunk/Monitoring/libIGCM_mock/libIGCM_mock.sh
===================================================================
--- /trunk/Monitoring/libIGCM_mock/libIGCM_mock.sh	(revision 867)
+++ /trunk/Monitoring/libIGCM_mock/libIGCM_mock.sh	(revision 867)
@@ -0,0 +1,177 @@
+#!/bin/bash
+
+##################################
+#  @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)
+##################################
+
+# Notes
+#   - bash required version: 3+
+#   - "=" and " " are used as delimiter in scenario file (be sure note to use it in fields data)
+
+# init
+
+stack_file=$1
+send_msg_cmd="/home/jripsl/snapshot/Monitoring/CNClient/sendAMQPMsg"
+scenario_dir=scenario
+g__mode="scenario"
+g__stackfile=
+g__scenario_file=
+
+# func
+
+curdate ()
+{
+    date '+%F %T'
+}
+
+msg ()
+{
+    l__code="$1"
+    l__msg="$2"
+
+    echo "$(curdate) - $l__code - $l__msg"
+}
+
+usage ()
+{
+	cat >&1 << EOF
+
+USAGE: $(basename $0) [-m mode] [-s scenario] [-l] [-t file]
+
+OPTIONS:
+   -f              set stack file
+   -l              print scenarios list 
+   -m              set mode (if missing, "scenario" mode is used)
+   -s              set scenario
+
+EXAMPLES:
+
+   To parse a stack file and send corressponding messages, do:
+
+   $0 -m stackfile -f ../sample/stack_light
+
+   To list scenarios, do:
+
+   $0 -l
+
+   To run scenario <scenario>, do:
+
+   $0 -s <scenario>
+EOF
+	exit 2
+}
+
+list_scenarios ()
+{
+	echo ""
+	echo "Scenarios list:"
+	echo ""
+	ls -1 $scenario_dir
+	echo ""
+	exit 2
+}
+
+# check
+
+if [ $# -eq 0 ]; then
+	usage
+fi
+
+# parse args
+
+while getopts 'f:hlm:s:' OPTION
+do
+  case $OPTION in
+  f)    g__stackfile="$OPTARG"
+        ;;
+  h)    usage
+        ;;
+  l)    list_scenarios
+        ;;
+  m)    g__mode="$OPTARG"
+        ;;
+  s)    l__scenario_file="$OPTARG"
+
+		if [[ "$l__scenario_file" =~ "*/*" ]]; then
+			# full/relative path was given with the filename
+
+			g__scenario_file="$l__scenario_file"
+		else
+			# only the filename was given
+
+			g__scenario_file="$scenario_dir/$l__scenario_file"
+		fi
+
+		;;
+  ?)    exit 1 # we come here when a required option argument is missing (bash getopts mecanism)
+        ;;
+  esac
+done
+
+# mode switch
+if [ "$g__mode" = "scenario" ]; then
+
+	# check
+	if [ ! -f "$g__scenario_file" ]; then
+		msg "LIBIGCM-MOCK-ERR003" "scenario file not found"
+		exit 1
+	fi
+
+	N=0
+	while read LINE ; do
+
+		N=$((N+1))
+
+		l__JSON_msg_buf=
+
+		# process fields (split on " " delimiter)
+		for field in "$LINE"; do
+			arr=(${LINE//=/ }) # process key/value (split on "=" delimiter)
+			key=${arr[0]}
+			val=${arr[1]}
+
+			# base64 encoding
+
+			# append to JSON message buffer
+			l__JSON_msg_buf=$l__JSON_msg_buf
+
+		done
+
+		# message base64 encoding
+
+
+		#callname=$(echo $line | awk -F" " '{print $4}' )
+
+		# send AMQP message
+		#$send_msg_cmd localhost 5672 string "$callname"
+		echo
+
+	done < $g__scenario_file
+
+elif [ "$g__mode" = "stackfile" ]; then
+
+	# check
+	if [ ! -f $stack_file ]; then
+		msg "LIBIGCM-MOCK-ERR001" "file not found"
+		exit 1
+	fi
+
+	IFS=$'\n'
+	for line in $(cat $stack_file); do
+		#echo $line | awk -F" " '{print $4}'
+		callname=$(echo $line | awk -F" " '{print $4}' )
+		$send_msg_cmd localhost 5672 string "$callname"
+	done
+else
+	msg "LIBIGCM-MOCK-ERR002" "incorrect mode"
+	exit 1
+fi
+
+exit 0
Index: /trunk/Monitoring/libIGCM_mock/scenario/start_simu__fatal_error__stop_simu
===================================================================
--- /trunk/Monitoring/libIGCM_mock/scenario/start_simu__fatal_error__stop_simu	(revision 867)
+++ /trunk/Monitoring/libIGCM_mock/scenario/start_simu__fatal_error__stop_simu	(revision 867)
@@ -0,0 +1,6 @@
+simuid=simu-001 jobid=job-001 code=0000 file=./sample/config.card.base64
+simuid=simu-001 jobid=job-001 code=1000
+simuid=simu-001 jobid=job-001 code=2000
+simuid=simu-001 jobid=job-001 code=3000
+simuid=simu-001 jobid=job-001 code=1100
+simuid=simu-001 jobid=job-001 code=0100
Index: /trunk/Monitoring/libIGCM_mock/scenario/start_simu__nonfatal_errors__stop_simu
===================================================================
--- /trunk/Monitoring/libIGCM_mock/scenario/start_simu__nonfatal_errors__stop_simu	(revision 867)
+++ /trunk/Monitoring/libIGCM_mock/scenario/start_simu__nonfatal_errors__stop_simu	(revision 867)
@@ -0,0 +1,6 @@
+simuid=simu-001 jobid=job-001 code=0000 file=./sample/config.card.base64
+simuid=simu-001 jobid=job-001 code=1000
+simuid=simu-001 jobid=job-001 code=2000
+simuid=simu-001 jobid=job-001 code=3000
+simuid=simu-001 jobid=job-001 code=1100
+simuid=simu-001 jobid=job-001 code=0100
Index: /trunk/Monitoring/libIGCM_mock/scenario/start_simu__simu_killed
===================================================================
--- /trunk/Monitoring/libIGCM_mock/scenario/start_simu__simu_killed	(revision 867)
+++ /trunk/Monitoring/libIGCM_mock/scenario/start_simu__simu_killed	(revision 867)
@@ -0,0 +1,6 @@
+simuid=simu-001 jobid=job-001 code=0000 file=./sample/config.card.base64
+simuid=simu-001 jobid=job-001 code=1000
+simuid=simu-001 jobid=job-001 code=2000
+simuid=simu-001 jobid=job-001 code=3000
+simuid=simu-001 jobid=job-001 code=1100
+simuid=simu-001 jobid=job-001 code=0100
Index: /trunk/Monitoring/libIGCM_mock/scenario/start_simu__simu_segfault
===================================================================
--- /trunk/Monitoring/libIGCM_mock/scenario/start_simu__simu_segfault	(revision 867)
+++ /trunk/Monitoring/libIGCM_mock/scenario/start_simu__simu_segfault	(revision 867)
@@ -0,0 +1,6 @@
+simuid=simu-001 jobid=job-001 code=0000 file=./sample/config.card.base64
+simuid=simu-001 jobid=job-001 code=1000
+simuid=simu-001 jobid=job-001 code=2000
+simuid=simu-001 jobid=job-001 code=3000
+simuid=simu-001 jobid=job-001 code=1100
+simuid=simu-001 jobid=job-001 code=0100
Index: /trunk/Monitoring/libIGCM_mock/scenario/start_simu__start_second_simu_with_same_name
===================================================================
--- /trunk/Monitoring/libIGCM_mock/scenario/start_simu__start_second_simu_with_same_name	(revision 867)
+++ /trunk/Monitoring/libIGCM_mock/scenario/start_simu__start_second_simu_with_same_name	(revision 867)
@@ -0,0 +1,6 @@
+simuid=simu-001 jobid=job-001 code=0000 file=./sample/config.card.base64
+simuid=simu-001 jobid=job-001 code=1000
+simuid=simu-001 jobid=job-001 code=2000
+simuid=simu-001 jobid=job-001 code=3000
+simuid=simu-001 jobid=job-001 code=1100
+simuid=simu-001 jobid=job-001 code=0100
Index: /trunk/Monitoring/libIGCM_mock/scenario/start_simu__stop_simu
===================================================================
--- /trunk/Monitoring/libIGCM_mock/scenario/start_simu__stop_simu	(revision 867)
+++ /trunk/Monitoring/libIGCM_mock/scenario/start_simu__stop_simu	(revision 867)
@@ -0,0 +1,6 @@
+simuid=simu-001 jobid=job-001 code=0000 file=./sample/config.card.base64
+simuid=simu-001 jobid=job-001 code=1000
+simuid=simu-001 jobid=job-001 code=2000
+simuid=simu-001 jobid=job-001 code=3000
+simuid=simu-001 jobid=job-001 code=1100
+simuid=simu-001 jobid=job-001 code=0100
