source: dasscm/trunk/usr/bin/dasscm_remote_check.sh@ 1188

Last change on this file since 1188 was 1171, checked in by joergs, on Jun 2, 2014 at 10:40:07 AM

adapted comment

  • Property svn:executable set to *
File size: 1.6 KB
Line 
1#!/bin/bash
2
3# dasscm_remote_check is intended for systems
4# where a local dasscm installation is not possible
5# but ssh and rsync is available.
6# Use dasscm_remote_update to update the configuration files,
7# and the corresponding dasscm_remote_check to perform the
8# related nagios check.
9# Use only, if a local dasscm installation is not possbile!
10
11DIR="$1"
12
13set -o errexit -o nounset
14
15NAGIOS_OK=0
16NAGIOS_WARN=1
17NAGIOS_CRIT=2
18NAGIOS_UNKNOWN=3
19
20myexit()
21{
22 local RC="$1"
23 shift
24 local MESSAGE
25 case "$RC" in
26 $NAGIOS_OK)
27 MESSAGE="OK: no modified files"
28 ;;
29 $NAGIOS_WARN)
30 MESSAGE="Warning: changed: $*"
31 ;;
32 $NAGIOS_CRIT)
33 MESSAGE="Critical: $*"
34 ;;
35 $NAGIOS_UNKNOWN|*)
36 MESSAGE="an unknown error has occured: $*"
37 ;;
38 esac
39 printf "$MESSAGE\n"
40 exit $RC
41}
42
43if [ -z "$DIR" ]; then
44 myexit $NAGIOS_CRIT "no file path given"
45fi
46
47if [ ! -d "$DIR" ]; then
48 myexit $NAGIOS_CRIT "failed to access directory $DIR"
49fi
50
51LOCALCHANGES=`svn status "$DIR"`
52if [ $? -ne 0 ]; then
53 myexit $NAGIOS_CRIT "failed to retrieve local subversion info of directory $DIR"
54fi
55
56DASSCM_RSYNC_OPTIONS=${DASSCM_RSYNC_OPTIONS:-""}
57export DASSCM_RSYNC_OPTIONS="$DASSCM_RSYNC_OPTIONS --dry-run --checksum --out-format CHANGED:%n%L"
58CHANGES=`dasscm_remote_update.sh "$@" | sed -n 's/CHANGED://p'`
59if [ "$CHANGES" ]; then
60 myexit $NAGIOS_WARN $CHANGES
61else
62 LOCALCHANGES=`svn status "$DIR"`
63 if [ "$LOCALCHANGES" ]; then
64 myexit $NAGIOS_WARN " (local) " $LOCALCHANGES
65 else
66 myexit $NAGIOS_OK
67 fi
68fi
Note: See TracBrowser for help on using the repository browser.