Changeset 6053


Ignore:
Timestamp:
Oct 19, 2017, 8:49:46 AM (2 years ago)
Author:
daduve
Message:

Optimize epoptes-client to start control in slowly starting services

File:
1 edited

Legend:

Unmodified
Added
Removed
  • epoptes/trunk/fuentes/epoptes-client/epoptes-client

    r6030 r6053  
    3737if [ ! -f $log_file ]; then
    3838        touch $log_file
     39        chmod 777 $log_file
     40else
    3941        chmod 777 $log_file
    4042fi
     
    245247echo "Presesion Lightdm.........."  >> $log_file
    246248echo "">> $log_file
     249name_aux=$(date | awk '{print $4}')
     250file_socat="/tmp/.epoptes_socat_$name_aux"
     251file_socat_post="/tmp/.epoptes_socat_post_$name_aux"
    247252ps aux | grep /usr/sbin/epoptes | grep -v root | grep -v "grep" >> $log_file
    248 USERS_SOCAT=`ps aux | grep /usr/sbin/epoptes | grep -v root | grep -v "grep" | awk '{print $2}' | uniq | wc -l `
     253ps aux | grep /usr/sbin/epoptes | grep -v root | grep -v "grep"  | awk '{print $2}' | uniq > $file_socat
     254cat $file_socat >> $log_file
     255USERS_SOCAT=$(wc -l < $file_socat)
     256#USERS_SOCAT=$(ps aux | grep /usr/sbin/epoptes | grep -v "root" | grep -v "grep" | awk '{print $2}' | uniq | wc -l)
    249257echo "USERS_SOCAT = $USERS_SOCAT">> $log_file;
    250258if [[ "$MATCH" != ligero  ]]; then
    251259        if (("$USERS_SOCAT" > 2 )); then
    252260                echo "Estoy dentro del if matando procesos.......">> $log_file
    253                 for i in `ps aux | grep /usr/sbin/epoptes | grep -v root | grep -v grep | awk '{print $2}' | uniq`; do
     261                for i in $(ps aux | grep /usr/sbin/epoptes | grep -v "root" | grep -v "grep" | awk '{print $2}' | uniq); do
    254262                        echo "Dentro del FOR para .......">> $log_file
    255263                        ps -aux | grep $i >> $log_file
     
    330338log_begin_msg "Epoptes-client connecting to $SERVER:$PORT..."
    331339echo "Epoptes-client connecting to $SERVER:$PORT..."
     340echo "Epoptes-client connecting to $SERVER:$PORT...">>$log_file
    332341# Call chain:
    333342#  * if-up.d executes /usr/sbin/epoptes-client
     
    342351# The current epoptes-client is excluded because it starts with /bin/sh.
    343352echo "pkill de $UID"
     353echo "pkill de $UID">>$lof_file
    344354pkill -U $UID -f '^epoptes-client$'
    345355
     
    374384echo "RUN = $RUN"
    375385test_conn(){
     386    echo "Testeando la funcion CONN $USER">> $log_file
    376387    if [ -z ${LTSP_CLIENT} ]; then
    377         echo "Testeando la funcion CONN $USER">> $log_file
     388        echo "No es cliente LTSP">> $log_file
    378389        #exit 0
    379390        #RUN=0
     
    386397        return 0
    387398    fi
    388     echo "vamos a salida">> $log_file
     399    echo "Vamos a salida -- No detecte nada en funcion CONN">> $log_file
    389400    salida
    390401}
    391402
    392403trap salida KILL TERM QUIT INT STOP EXIT
    393 
     404echo "__________________________________________________">>$log_file
     405echo "">>$log_file
    394406echo "-- Funcion Principal para abrir el SOCAT --" >> $log_file
    395407if [ -s /etc/epoptes/server.crt ] || [ "$cert_param" = "verify=0" ]; then
     
    398410        ALIVE=$(ps ax|grep $PPID|grep -v grep|wc -l)
    399411        echo "Dentro del While porque el RUN es $RUN para usuario $USER">> $log_file
    400         USERS_SOCAT_POST=`ps aux | grep /usr/sbin/epoptes | grep -v root | grep -v "grep" | awk '{print $2}' | uniq | wc -l `
     412        ps aux | grep /usr/sbin/epoptes | grep -v root | grep -v "grep"  | awk '{print $2}' | uniq > $file_socat_post
     413        echo "   - USERS_SOCAT_POST - ">>$log_file
     414        cat $file_socat_post >> $log_file
     415        USERS_SOCAT_POST=$(wc -l < $file_socat_post)
     416        #USERS_SOCAT_POST=`ps aux | grep /usr/sbin/epoptes | grep -v root | grep -v "grep" | awk '{print $2}' | uniq | wc -l `
    401417        echo "Calculando el USERS_SOCAT_POST: $USERS_SOCAT_POST" >> $log_file
    402         if (("$USERS_SOCAT_POST" < 3 )) || [[ "$MATCH" == "ligero" ]]; then
     418        if (( $USERS_SOCAT_POST < 3 )) || [[ "$MATCH" == "ligero" ]]; then
    403419                echo "-----SOCAT se va a ejecutar para el usuario: $USER -----">> $log_file
    404420                sleep 20
     421                date_create=$(date)
    405422                echo 'socat openssl-connect:$SERVER:$PORT,$cert_param,interval=60,forever EXEC:"$cmdline",sigint,sigquit,sigterm' >> $log_file
    406423                socat openssl-connect:$SERVER:$PORT,$cert_param,interval=60,forever EXEC:"$cmdline",sigint,sigquit
    407                 echo "Muere el SOCAT de $USER: ">> $log_file
     424                echo "-------------------------------------" $log_file
     425                echo "Muere el SOCAT del usuario: $USER creado: $date_create">> $log_file
    408426                date >> $log_file
     427                echo "-------------------------------------" $log_file
    409428        fi
    410429       
     
    415434        echo "Paso del ALIVE y continuo porque RUN: $RUN del usuario $USER">> $log_file
    416435        test_conn
    417         SESSION_GNOME=`ps aux | grep gnome-session | wc -l `
    418         if (("$SESSION_GNOME" < 2 )); then
     436        SESSION_GNOME=`ps aux | grep mate-session | wc -l `
     437        if (( $SESSION_GNOME < 2 )); then
    419438                date >> $log_file
    420                 echo "La sesion no esta activa me quedo en la sesion SESSION_GNOME: $SESSION_GNOME modifico el RUN" >> $log_file
     439                echo "La sesion no esta activa me quedo en la sesion MATE-SESSION: $SESSION_GNOME modifico el RUN" >> $log_file
    421440                RUN=0
    422441        fi
Note: See TracChangeset for help on using the changeset viewer.