DaffyDuke
3/4/2017 - 2:02 PM

check_hsm

check_hsm

#!/bin/ksh
# usage  check_hsm_stat_simple <server> <service>
# retourne  stat du service
LISTE_SERVICE=/etc/init_services.hsm
status_soap="APP_STATUS NB_BUSY_DISPATCHERS NB_BUSY_WORKERS NB_BUSY_CONNECTIONS NB_CONNECTED_SESSIONS NB_DISPATCHERS NB_BROKEN_WORKE
RS NB_CONNECTIONS NB_BROKEN_MESSAGERIES NB_CONTEXTS NB_MESSAGERIES NB_TREATMENT NB_BROKEN_DISPATCHERS NB_CONSECUTIVE_ERRORS NB_WORKE
RS"
soap=0
PORT="2010"
SORTIE="1"
tmp_fic_TMP=/tmp
tmp_fic_SK=check_hsm_stat.tmp.$1
tmp_fic=$tmp_fic_TMP/$tmp_fic_SK.$$
function usage
{
echo " Usage: check_hsm_stat_simple server"
echo " Usage: <server> <service> retourne les stats  de ce service sur ce server  "
echo " et en code retour le APP_STATUS "
exit 1
}
# LOCK !
typeset -i i=0
while ! mkdir /$tmp_fic_TMP/LOCK.$tmp_fic_SK 2>/dev/null
do
        sleep 1
        let i++
        [[ $i -gt 10 ]] && {
                [[ -w /tmp/check_hsm_stat_simple.DEBUG.log ]] && echo LOCK TimeOut: SKIP $1 $2 PID=$$ $(date) >> /tmp/check_hsm_
stat_simple.DEBUG.log
                exit 0
        }
        [[ -w /tmp/check_hsm_stat_simple.DEBUG.log ]] && echo LOCK Looping: PID=$$ $1 $2 $(date) >> /tmp/check_hsm_stat_simple.D
EBUG.log
done
function port_manager
{
case "$1" in
"sts08"|"sts09")
PORT="2010";
;;
"sts10"|"sts11")
PORT="2010";
;;
"stx01"|"stx02")
PORT="2018";
;;
*)
PORT="2010";
;;
esac
}
# Optimised run: find the result file younger than 2 min
typeset -i try=0
found_fic=$(find $tmp_fic_TMP -maxdepth 1 -name $tmp_fic_SK.\* -a -cmin -2 2>/dev/null | tail -1)
case $found_fic in
$tmp_fic_TMP/$tmp_fic_SK.*)
        use_fic=$found_fic
        [[ -w /tmp/check_hsm_stat_simple.DEBUG.log ]] && echo FOUND $found_fic PID=$$ $(date) >> /tmp/check_hsm_stat_simple.DEBU
G.log
        ;;
'')
        use_fic=$tmp_fic
        touch $use_fic
        [[ -w /tmp/check_hsm_stat_simple.DEBUG.log ]] && echo MAKENEW $tmp_fic PID=$$ $(date) >> /tmp/check_hsm_stat_simple.DEBU
G.log
        port_manager $1
        python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1 >> $use_fic
esac
# 3 tries to get a result file containing the stats lines for the req. instances (server not BUSY)
while [[ $try -lt 3 ]]
do
{
        REPONSE=$(grep :${2}: $use_fic | tail -1 | cut -d ":" -f 5)
        if [[ ! -n "$REPONSE" ]]
        then
             sleep 5
             use_fic=$tmp_fic
             touch $use_fic
             port_manager $1
             python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1 >> $use_fic
             let try=try+1
        else
             break
        fi
}
done
MSG_OUT="$2 |"
for j in $status_soap
do
MSG_OUT="${MSG_OUT} $j="
case $j in
"APP_STATUS")
REPONSE=`grep :${2}: $use_fic | tail -1 | cut -d ":" -f 5`
  if [ -n "$REPONSE" ]
  then
     SORTIE=$REPONSE
  else
     SORTIE=7
  fi
;;
"NB_BUSY_DISPATCHERS")
REPONSE=`grep $2 $use_fic|tail -1|cut -d ":" -f 6`
;;
"NB_BUSY_WORKERS")
REPONSE=`grep $2 $use_fic|tail -1|cut -d ":" -f 7`
;;
"NB_BUSY_CONNECTIONS")
REPONSE=`grep $2 $use_fic|tail -1|cut -d ":" -f 8`
;;
"NB_CONNECTED_SESSIONS")
REPONSE=`grep $2 $use_fic|tail -1|cut -d ":" -f 9`
;;
"NB_DISPATCHERS")
REPONSE=`grep $2 $use_fic|tail -1|cut -d ":" -f 10`
;;
"NB_BROKEN_WORKERS")
REPONSE=`grep $2 $use_fic|tail -1|cut -d ":" -f 11`
;;
"NB_CONNECTIONS")
REPONSE=`grep $2 $use_fic|tail -1|cut -d ":" -f 12`
;;
"NB_BROKEN_MESSAGERIES")
REPONSE=`grep $2 $use_fic|tail -1|cut -d ":" -f 13`
;;
"NB_CONTEXTS")
REPONSE=`grep $2 $use_fic|tail -1|cut -d ":" -f 14`
;;
"NB_MESSAGERIES")
REPONSE=`grep $2 $use_fic|tail -1|cut -d ":" -f 15`
;;
"NB_TREATMENT")
REPONSE=`grep $2 $use_fic|tail -1|cut -d ":" -f 16`
;;
"NB_BROKEN_DISPATCHERS")
REPONSE=`grep $2 $use_fic|tail -1|cut -d ":" -f 17`
;;
"NB_CONSECUTIVE_ERRORS")
REPONSE=`grep $2 $use_fic|tail -1|cut -d ":" -f 18`
;;
"NB_WORKERS")
REPONSE=`grep $2 $use_fic|tail -1|cut -d ":" -f 19`
;;
?)
REPONSE="NaN"
;;
esac
MSG_OUT="${MSG_OUT}$REPONSE;"
done
# purge files older than 15 min to keep $tmp_fic_TMP clean
find $tmp_fic_TMP -maxdepth 1 -name $tmp_fic_SK.\* -a -cmin +15 2>/dev/null | xargs 2>/dev/null rm -f
case $SORTIE in
0)
        echo "OK: $MSG_OUT"
        rm -rf /$tmp_fic_TMP/LOCK.$tmp_fic_SK
        exit 0
        ;;
1)
        echo "WARNING: No Answer $MSG_OUT"
        rm -rf /$tmp_fic_TMP/LOCK.$tmp_fic_SK
        exit 1
        ;;
*)
        echo "ERROR: Code=$SORTIE $MSG_OUT"
        rm -rf /$tmp_fic_TMP/LOCK.$tmp_fic_SK
        exit 1
esac
#!/bin/ksh
# usage  check_hsm_stat.ksh <server> <service> <parametre>
# retourne  stat du service
LISTE_SERVICE=/etc/init_services.hsm
status="appStatus nbBusyDispatcher nbBusyWorkers nbConnectedSessions nbContexts nbDispatchers nbMessageries nbTreatment nbWorkers nb
Connections nbBusyConnections"
status_soap="APP_STATUS NB_BUSY_DISPATCHERS NB_BUSY_WORKERS NB_BUSY_CONNECTIONS NB_CONNECTED_SESSIONS NB_DISPATCHERS NB_BROKEN_WORKE
RS NB_CONNECTIONS NB_BROKEN_MESSAGERIES NB_CONTEXTS NB_MESSAGERIES NB_TREATMENT NB_BROKEN_DISPATCHERS NB_CONSECUTIVE_ERRORS NB_WORKE
RS"
soap=0
PORT="2010"
tmp_fic=/tmp/check_hsm_stat.tmp.$$
function usage
{
    echo " Usage: check_stat.ksh [-h] [server [service [param]]]"
    echo " Usage: -h : this help"
    echo " Usage: -s/S  pour une reponse bas� sur soap ou SNMP"
    echo " Usage: retourne toutes les stats de chaque service de tout les serveurs hsm "
    echo " Usage: <server>  retourne les stats de tout les services de ce server "
    echo " Usage: <server> <service>  retourne les stat de ce service sur ce server "
    echo " Usage: <server> <service> <param> retourne cette stat de ce service sur ce server "
    exit 1
}

function port_manager
{
    case "$1" in
        "machine08"|"machine09")
        PORT="2010";
    ;;
        "machine10"|"machine11")
        PORT="2010";
    ;;
        "machine01"|"machine02")
        PORT="2018";
    ;;
    *)
        PORT="2010";
    ;;
    esac
}

function status_hsm_stat
{
    port_manager $1
    if [ $soap -ne 0 ]
    then
    #python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1 > $tmp_fic
        case $3 in
        # TIMESTAMP:CLIENT:INSTANCE:PID:APP_STATUS:NB_BUSY_DISPATCHERS:NB_BUSY_WORKERS:NB_BUSY_CONNECTIONS:NB_CONNECTED_SESSIONS:NB_DISPATCH
        ERS:NB_BROKEN_WORKERS:NB_CONNECTIONS:NB_BROKEN_MESSAGERIES:NB_CONTEXTS:NB_MESSAGERIES:NB_TREATMENT:NB_BROKEN_DISPATCHERS:NB_CONSECUT
        IVE_ERRORS:NB_WORKERS
        "APP_STATUS")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 5`
        ;;
        "NB_BUSY_DISPATCHERS")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 6`
        ;;
        "NB_BUSY_WORKERS")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 7`
        ;;
        "NB_BUSY_CONNECTIONS")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 8`
        ;;
        "NB_CONNECTED_SESSIONS")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 9`
        ;;
        "NB_DISPATCHERS")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 10`
        ;;
        "NB_BROKEN_WORKERS")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 11`
        ;;
        "NB_CONNECTIONS")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 12`
        ;;
        "NB_BROKEN_MESSAGERIES")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 13`
        ;;
        "NB_CONTEXTS")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 14`
        ;;
        "NB_MESSAGERIES")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 15`
        ;;
        "NB_TREATMENT")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 16`
        ;;
        "NB_BROKEN_DISPATCHERS")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 17`
        ;;
        "NB_CONSECUTIVE_ERRORS")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 18`
        ;;
        "NB_WORKERS")
            REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 19`
        ;;
        ?)
            REPONSE="NaN"
        ;;
        esac
        echo -n $REPONSE
        else
            REPONSE=`snmpget -v 1 -c desp -t 20 ${1}:1161 FACIL-MIB::manager.managementTable.1.${3}.\"${2}\" |cut -d":" -f4`
            echo -n $REPONSE
    fi
}

function status_hsm_stat_service_soap
{
    port_manager $1
    python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1 > $tmp_fic
    for j in $status_soap
    do
        echo -n "$j="
        case $j in
            # TIMESTAMP:CLIENT:INSTANCE:PID:APP_STATUS:NB_BUSY_DISPATCHERS:NB_BUSY_WORKERS:NB_BUSY_CONNECTIONS:NB_CONNECTED_SESSIONS:NB_DISPATCH
            ERS:NB_BROKEN_WORKERS:NB_CONNECTIONS:NB_BROKEN_MESSAGERIES:NB_CONTEXTS:NB_MESSAGERIES:NB_TREATMENT:NB_BROKEN_DISPATCHERS:NB_CONSECUT
            IVE_ERRORS:NB_WORKERS
            "APP_STATUS")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 5`
            ;;
            "NB_BUSY_DISPATCHERS")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 6`
            ;;
            "NB_BUSY_WORKERS")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 7`
            ;;
            "NB_BUSY_CONNECTIONS")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 8`
            ;;
            "NB_CONNECTED_SESSIONS")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 9`
            ;;
            "NB_DISPATCHERS")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 10`
            ;;
            "NB_BROKEN_WORKERS")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 11`
            ;;
            "NB_CONNECTIONS")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 12`
            ;;
            "NB_BROKEN_MESSAGERIES")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 13`
            ;;
            "NB_CONTEXTS")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 14`
            ;;
            "NB_MESSAGERIES")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 15`
            ;;
            "NB_TREATMENT")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 16`
            ;;
            "NB_BROKEN_DISPATCHERS")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 17`
            ;;
            "NB_CONSECUTIVE_ERRORS")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 18`
            ;;
            "NB_WORKERS")
                REPONSE=`grep $2 $tmp_fic|cut -d ":" -f 19`
            ;;
            ?)
                REPONSE="NaN"
            ;;
        esac
        echo -n $REPONSE
        echo -n "; "
    done
}

function status_hsm_stat_all
{
    for i in `cat $LISTE_SERVICE|cut -d"=" -f1`
    do
        echo "---------  $i  ----------"
        if [ $soap -ne 0 ]
        then
            /applis/monitoring/libexec/check_hsm_stat -s $i
        else
            /applis/monitoring/libexec/check_hsm_stat $i
        fi
        done
}

function status_hsm_stat_server
{
    for j in `grep $1 $LISTE_SERVICE|cut -d"=" -f2|sed "s/,/ /g"`
    do
        echo "##   $j  ##"
        if [ $soap -ne 0 ]
        then
            /applis/monitoring/libexec/check_hsm_stat -s $1 ${j}
        else
            /applis/monitoring/libexec/check_hsm_stat $1 ${j}
        fi
    done
}

function status_hsm_stat_service
{
    if [ $soap -ne 0 ]
    then
        status_hsm_stat_service_soap $1 $2
        echo
    else
        for j in $status
        do
            echo -n "$j \t\t"
            /applis/monitoring/libexec/check_hsm_stat $1 $2 ${j}
            echo
        done
    fi
}

function status_hsm_stat_service_nagios
{
    echo -n "$2 | "
    if [ $soap -ne 0 ]
    then
        status_hsm_stat_service_soap $1 $2
    else
        for j in $status
        do
            echo -n "$j="
            /applis/monitoring/libexec/check_hsm_stat $1 $2 ${j}
            echo -n "; "
        done
    fi
}

# options
while getopts :hsS option
do
    case $option in
        h)
            usage
        ;;
        s)
            soap=1
        ;;
        S)
            soap=0
        ;;
        ?)
            echo "Option inconnue ..."
            exit 1
        ;;
    esac
done

shift `expr $OPTIND - 1`
# nb arg
touch $tmp_fic
if [ $# -eq 0 ]
then
    status_hsm_stat_all
    elif [ $# -eq 1 ]
    then
        status_hsm_stat_server $1
        elif [ $# -eq 2 ]
        then
            status_hsm_stat_service_nagios $1 $2
        elif [ $# -eq 3 ]
            # options
            while getopts :hsS option
            do
                case $option in
                h)
                    usage
                ;;
                s)
                    soap=1
                ;;
                S)
                    soap=0
                ;;
                ?)
                    echo "Option inconnue ..."
                    exit 1
                ;;
                esac
            done
        shift `expr $OPTIND - 1`
        # nb arg
        touch $tmp_fic
        if [ $# -eq 0 ]
        then
            status_hsm_stat_all
        elif [ $# -eq 1 ]
        then
            status_hsm_stat_server $1
        elif [ $# -eq 2 ]
        then
            status_hsm_stat_service_nagios $1 $2
        elif [ $# -eq 3 ]
        then
            status_hsm_stat $1 $2 $3
else
        usage
fi
rm $tmp_fic
#!/bin/ksh
# usage  check_hsm_service <server> <port du service>
# retourne  status du service
# PMD 20090928
#

#/usr/bin/python /applis/monitoring/libexec/AppStatus.py $1 $2
REPONSE=`/usr/bin/python /applis/monitoring/libexec/AppStatus.py $1 $2 |tail -1|cut -d ":" -f 4`
if [ -n "$REPONSE" ]
then
    return $REPONSE
else
    return 7
fi
#!/bin/ksh
# usage  check_hsm.ksh [-v ] <server> <service>
# retourne  status du service
# PMD 20090918
verbose=0
soap=0
PORT="2010"
#par defaut on fait du snmp
LISTE_SERVICE=/etc/init_services.hsm

function usage
{
echo " Usage: check_hsm.ksh [-h] [-v] [server [service]]"
echo " Usage: -h : this help"
echo " Usage: -v : return colored string status, else exit with status code"
echo " Usage: -s : check with SOAP method rather than SNMP"
echo " Usage: retourne une chaine-status de chaque service de tout les serveurs hsm "
echo " Usage: <server>  retourne une chaine-status de tout les services de ce server "
echo " Usage: <server> <service>  retourne le code de status de ce service sur ce server "
exit 1
}

function port_manager
{
case "$1" in
    "machine08"|"machine09")
    PORT="2010";
    ;;
    "machine10"|"machine11")
    PORT="2010";
    ;;
    "machine01"|"machine02")
    PORT="2018";
    ;;
    *)
    PORT="2010";
    ;;
esac
}

function status_hsm
{
if [ $soap -ne 0 ]
        then
                port_manager $1
                REPONSE=`/usr/bin/python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 5`
                if [ -n "$REPONSE" ]
                        then
                                return $REPONSE
                        else
                                return 7
                        fi
        else
                REPONSE=`snmpget -v 1 -c desp -t 5 $1:1161 FACIL-MIB::manager.managementTable.1.appStatus.\"$2\" |cut -d ":" -f4|tr
-d " "`
                if [ -n "$REPONSE" ]
                        then
                                return $REPONSE
                        else
                                return 7
                        fi
        fi
}

function status_hsm_verbose
{
if [ $soap -ne 0 ]
        then
                port_manager $1
                #echo test SOAP : python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1\|grep $2\|cut -d \":\" -f 5
                REPONSE=`python /applis/monitoring/libexec/ManagerStatistics.py $1 $PORT 1|grep $2|cut -d ":" -f 5`
                #echo $REPONSE
        else
                #echo test SNMP : snmpget -v 1 -c desp -t 5 $1:1161 FACIL-MIB::manager.managementTable.1.appStatus.\"$2\" \|cut -d \
":\" -f4\|tr -d \" \"
                REPONSE=`snmpget -v 1 -c desp -t 5 $1:1161 FACIL-MIB::manager.managementTable.1.appStatus.\"$2\" |cut -d ":" -f4|tr
-d " "`
                #echo $REPONSE
fi
case "$REPONSE" in
'0')
tput setaf 2
echo "READY";
tput sgr0
;;
1)
tput setaf 1
echo "STOPPED";
tput sgr0
;;
2)
tput setaf 3
echo "STARTING";
tput sgr0
;;
3)
tput setaf 1
echo "STOPPING";
tput sgr0
;;
4)
tput setaf 1
echo "SHUTDOWN";
tput sgr0
;;
5)
tput setaf 3
echo "DISABLED";
tput sgr0
;;
6)
tput setaf 3
echo "LAUNCHING";
tput sgr0
;;
6)
tput setaf 1
echo "SHUTTING DOWN";
tput sgr0
;;
*)
tput setaf 1
echo "UNKNOWN";
tput sgr0
;;
esac
}
function status_hsm_all
{
for i in `cat $LISTE_SERVICE|cut -d"=" -f1`
do
echo "------------------------------------"
if [ $soap -ne 0 ]
        then
/applis/monitoring/libexec/check_hsm -s $i
else
/applis/monitoring/libexec/check_hsm $i
fi
#echo $i
#for j in `grep $i $LISTE_SERVICE|cut -d"=" -f2|sed "s/,/ /g"`
#do
#echo -n "$j \t\t"
#/applis/monitoring/libexec/check_hsm -v ${i} ${j}
#done
done
}
function status_hsm_server
{
for j in `grep $1 $LISTE_SERVICE|cut -d"=" -f2|sed "s/,/ /g"`
do
echo -n "$j \t\t"
if [ $soap -ne 0 ]
        then
/applis/monitoring/libexec/check_hsm -v -s $1 ${j}
else
/applis/monitoring/libexec/check_hsm -v $1 ${j}
fi
done
}
# options
while getopts :hvsS option
do
case $option in
h)
usage
;;
v)
verbose=1
;;
s)
soap=1
;;
S)
soap=0
;;
?)
echo "Option inconnue ..."
exit 1
;;
esac
done
shift `expr $OPTIND - 1`
# nb arg
if [ $# -eq 0 ]
        then
        status_hsm_all
elif [ $# -eq 1 ]
        then
        status_hsm_server $1
elif [ $# -eq 2 ]
        then
        if [ $verbose -ne 0 ]
        then
                status_hsm_verbose $1 $2
        else
                status_hsm $1 $2
        fi
else
        usage
fi
#!/bin/env python
#
# Envoi d'une boucle de demandes de statistiques au manager
# mise en forme des resultats avec separateur :
# param 1 : IP de destination
# param 2 : port de destination
# param 3 : nom de l'application a interroger
#
# 2007/11/22    M. GAUTHIER     Creation
# 2008/02/18    V. PAGNON       Utilisation de Requests.py
# 2009/09/17    V. PAGNON       Mise a jour pour get statistics
#
# ____________________________BEGIN_IMPORT__________________________________
import time
import os, os.path
import shutil
import sys
from Requests import *
# _____________________________IMPORT_END___________________________________
# ____________________________BEGIN_CONSTANTS_______________________________
# Constant to modify
kHostPath       = ""
kOperatorId     = "user_system_id"
kTestNumber     = 2
# _____________________________CONSTANTS_END________________________________
# param 1 : IP de destination
# param 2 : nombre d'iteration (1 toutes les 10s)
if __name__ == '__main__':
    requestCount = 0;
    errorCount = 0;
    timeSleep = 0
    max_time_auth = 0
    max_time_gbr = 0
    min_time_auth = 999
    min_time_gbr = 999
    total_time_auth = 0
    total_time_gbr = 0
    requester = Requests()
    requester.initialise(sys.argv[1],sys.argv[2],kHostPath, kOperatorId)
    headersLine = "TIMESTAMP:CLIENT:INSTANCE:PID:APP_STATUS:NB_BUSY_DISPATCHERS:NB_BUSY_WORKERS:NB_BUSY_CONNECTIONS:NB_CONNECTED_SES
SIONS:NB_DISPATCHERS:NB_BROKEN_WORKERS:NB_CONNECTIONS:NB_BROKEN_MESSAGERIES:NB_CONTEXTS:NB_MESSAGERIES:NB_TREATMENT:NB_BROKEN_DISPAT
CHERS:NB_CONSECUTIVE_ERRORS:NB_WORKERS\n"
    sys.stdout.write( headersLine )
    debut = time.time()
    request, response = requester.do_ManagerStatistics()
    duree = time.time()-debut
    total_time_gbr += duree
    if duree > max_time_gbr: max_time_gbr=duree
    if duree < min_time_gbr: min_time_gbr=duree
    requestCount = requestCount + 1
    if response != 'connection_error' and response.status == 200:
        code,statTable = Show_ManagerStatistics_Response(debut,response)
        if code != 0:
            errorCount += 1
        sys.stdout.write( str(debut)+statTable )
    else :
        errorCount += 1
        sys.stdout.write ( str(debut)+' connection_error\n' )
    sys.stdout.flush()
    sys.stdout.write( '\nManagerStatistics:\nTemps total %fs\nTemps requete max %fs\nTemps requete min %fs\nTemps requete moy. %fs'
% (total_time_gbr,max_time_gbr,min_time_gbr,total_time_gbr/requestCount) )
    sys.stdout.write( '\nError count %d\n ' % (errorCount) )
#!/bin/env python
#
# Envoi une demande de statistiques a une application
# mise en forme des resultats avec separateur :
# param 1 : IP de destination
# param 2 : port de destination
#
# 2009/09/21    V. PAGNON       Creation
#
# ____________________________BEGIN_IMPORT__________________________________
import time
import os, os.path
import shutil
import sys
from Requests import *
# _____________________________IMPORT_END___________________________________
# ____________________________BEGIN_CONSTANTS_______________________________
# Constant to modify
kHostPath       = ""
kOperatorId     = "user_system_id"
kTestNumber     = 2
# _____________________________CONSTANTS_END________________________________
# param 1 : IP de destination
# param 2 : nombre d'iteration (1 toutes les 10s)
if __name__ == '__main__':
    requestCount = 0;
    errorCount = 0;
    timeSleep = 0
    max_time_auth = 0
    max_time_gbr = 0
    min_time_auth = 999
    min_time_gbr = 999
    total_time_auth = 0
    total_time_gbr = 0
    requester = Requests()
    requester.initialise(sys.argv[1],sys.argv[2],kHostPath, kOperatorId)
    headersLine = "TIMESTAMP:INSTANCE:PID:APP_STATUS\n"
    sys.stdout.write( headersLine )
    debut = time.time()
    request, response = requester.do_AppStatus()
    if response != 'connection_error' and response.status == 200:
        code,statTable = Show_AppStatus_Response(response)
        sys.stdout.write( str(debut)+statTable )
    else :
        sys.stdout.write ( str(debut)+':connection_error\n' )
    sys.stdout.flush()