source: repoman/bin/opengnsys.cron @ 5bfead0

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
Last change on this file since 5bfead0 was cafc669, checked in by ramon <ramongomez@…>, 11 years ago

#616: Añadir variable RUN_CRONJOB a fichero /etc/default/opengnsys para elegir si no se desea ejecutar en el Cron el fichero de comprobación de servicios ejecutados.

git-svn-id: https://opengnsys.es/svn/branches/version1.0@4228 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 1.5 KB
RevLine 
[89a8208]1#!/bin/bash
[0b3fc2d]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
[24f5516]7# Variables.
8OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
9LOGDIR="$OPENGNSYS/log"
[57cf15b]10DEFAULTFILE=/etc/default/opengnsys
[0b3fc2d]11typeset -i OGCPU        # % uso CPU
[24f5516]12
[57cf15b]13# Comprobar servicios que deben estar activos.
14[ -f $DEFAULTFILE ] && source $DEFAULTFILE
[24f5516]15
[cafc669]16# Salir si no se debe ejecutar la revisión en el cron.
17[ "$RUN_CRONJOB" == "no" ] && exit
18
[0b3fc2d]19# Comprobar si está activo el servidor OpenGnSys.
20if [ "$RUN_OGADMSERVER" == "yes" ]; then
21        # Parar procesos ogAdmServer si consume más de 90% de CPU.
22        OGPID=$(pgrep ogAdmServer)
[a36fbae]23        OGCPU=$(top -b -n 1 -p $OGPID 2>/dev/null | awk -v p=$OGPID '$1~p {printf "%d",$9}')
[0b3fc2d]24        if [ $OGCPU -gt 90 ]; then
[a36fbae]25                date +"%d/%m/%Y %H:%M AVISO: ogAdmServer (PID=$OGPID) parado, consumiendo $OGCPU % de CPU" >> $LOGDIR/ogAdmServer.log
[0b3fc2d]26                kill -9 $OGPID
27        fi
28        # Reiniciar servicios si proceso ogAdmServer está caído.
29        if ! pgrep ogAdmServer >/dev/null; then
[a36fbae]30                date +"%d/%m/%Y %H:%M ERROR: El servicio ogAdmServer  estaba caido, se reinicia" >> $LOGDIR/ogAdmServer.log
[0b3fc2d]31                /etc/init.d/opengnsys restart
32        fi
[24f5516]33fi
[0b3fc2d]34# Reiniciar servicios si es repositorio y proceso ogAdmRepo está caído.
[55477d2]35if [ "$RUN_OGADMREPO" == "yes" -a $(pgrep ogAdmRepo | wc -w) == 0 ]; then
[a36fbae]36        date +"%d/%m/%Y %H:%M ERROR: El servicio ogAdmRepo estaba caido, se reinicia" >> $LOGDIR/ogAdmRepo.log
[24f5516]37        /etc/init.d/opengnsys restart
38fi
39
Note: See TracBrowser for help on using the repository browser.