observer_bgtwrap.sh 1.35 KB
Newer Older
thomas.forbriger's avatar
thomas.forbriger committed
1
2
3
#!/bin/sh
# this is <observer_bgtwrap.sh>
# ----------------------------------------------------------------------------
thomas.forbriger's avatar
thomas.forbriger committed
4
# $Id: observer_bgtwrap.sh,v 1.3 2008-11-27 21:28:44 tforb Exp $
thomas.forbriger's avatar
thomas.forbriger committed
5
6
7
8
9
10
11
12
13
14
15
# 
# Copyright (c) 2008 by Thomas Forbriger (BFO Schiltach) 
# 
# call twrap in true background
# 
# REVISIONS and CHANGES 
#    27/11/2008   V1.0   Thomas Forbriger
# 
# ============================================================================
#

thomas.forbriger's avatar
thomas.forbriger committed
16
17
18
19
OBS_WRAP_LOGDIR=$HOME/tmp/observer
mkdir -pv $OBS_WRAP_LOGDIR
LOGFILE=$OBS_WRAP_LOGDIR/bgwrapper.log

thomas.forbriger's avatar
thomas.forbriger committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
if test $# -lt 1 
then
  echo "Usage; $0 wrapper plugin [plugin ...]"
  echo
  echo "wrapper   path to observer_twrap.sh"
  echo "plugin    path to observer plugin to execute"
  exit 2
fi

WRAPPER=$1
shift

if test ! -x $WRAPPER
then
  echo $WRAPPER is not executable!
  exit 3
fi

thomas.forbriger's avatar
thomas.forbriger committed
38
while test -n "$1"
thomas.forbriger's avatar
thomas.forbriger committed
39
40
do
  PLUGIN=$1
thomas.forbriger's avatar
thomas.forbriger committed
41
42
43
44
45
46
47
48
49
50
51
52
53
  if test -x $PLUGIN
  then
    $WRAPPER $PLUGIN 2>&1 >$LOGFILE
    ( echo ; \
      echo "-------------------------------"; \
      echo "output interpreted by observer:"; \
      echo "-------------------------------"; \
      echo ; \
      /bin/cat $LOGFILE | egrep "^(status|message): "; \
      cat $LOGFILE ) | mail -s "$(basename $0) $(basename $PLUGIN)" $USER
  else
    echo $PLUGIN | mail -s "ERROR: plugin $(basename $PLUGIN) not executable" $USER
  fi
thomas.forbriger's avatar
thomas.forbriger committed
54
  shift
thomas.forbriger's avatar
thomas.forbriger committed
55
  exit
thomas.forbriger's avatar
thomas.forbriger committed
56
57
58
done

# ----- END OF observer_bgtwrap.sh -----