918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Line | |
---|
1 | #!/bin/bash |
---|
2 | # opengnsys.cron - Script para comprobar si los servicios de OpenGnSys están levantados |
---|
3 | # e iniciarlos automáticamente. |
---|
4 | # Nota: este script debe ser lanzado por Cron cada minuto. |
---|
5 | |
---|
6 | |
---|
7 | # Variables. |
---|
8 | OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"} |
---|
9 | LOGDIR="$OPENGNSYS/log" |
---|
10 | DEFAULTFILE=/etc/default/opengnsys |
---|
11 | typeset -i OGCPU # % uso CPU |
---|
12 | |
---|
13 | # Comprobar servicios que deben estar activos. |
---|
14 | [ -f $DEFAULTFILE ] && source $DEFAULTFILE |
---|
15 | |
---|
16 | # Comprobar si está activo el servidor OpenGnSys. |
---|
17 | if [ "$RUN_OGADMSERVER" == "yes" ]; then |
---|
18 | # Parar procesos ogAdmServer si consume más de 90% de CPU. |
---|
19 | OGPID=$(pgrep ogAdmServer) |
---|
20 | OGCPU=$(printf "%d" $(ps -p $OGPID -o %cpu= 2>/dev/null) 2>/dev/null) |
---|
21 | if [ $OGCPU -gt 90 ]; then |
---|
22 | date +"%d/%m/%Y %T AVISO: ogAdmServer (PID=$OGPID) parado, consumiendo $OGCPU % de CPU" >> $LOGDIR/ogAdmServer.log |
---|
23 | kill -9 $OGPID |
---|
24 | fi |
---|
25 | # Reiniciar servicios si proceso ogAdmServer está caído. |
---|
26 | if ! pgrep ogAdmServer >/dev/null; then |
---|
27 | date +"%d/%m/%Y %T ERROR: El servicio ogAdmServer estaba caido, se reinicia" >> $LOGDIR/ogAdmServer.log |
---|
28 | /etc/init.d/opengnsys restart |
---|
29 | fi |
---|
30 | fi |
---|
31 | # Reiniciar servicios si es repositorio y proceso ogAdmRepo está caído. |
---|
32 | if [ "$RUN_OGADMREPO" == "yes" -a $(pgrep ogAdmRepo | wc -w) == 0 ]; then |
---|
33 | date +"%d/%m/%Y %T ERROR: El servicio ogAdmRepo estaba caido, se reinicia" >> $LOGDIR/ogAdmRepo.log |
---|
34 | /etc/init.d/opengnsys restart |
---|
35 | fi |
---|
36 | |
---|
Note: See
TracBrowser
for help on using the repository browser.