Rev | Line | |
---|
[1168] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
[1171] | 3 | # dasscm_remote_check is intended for systems
|
---|
[1168] | 4 | # where a local dasscm installation is not possible
|
---|
| 5 | # but ssh and rsync is available.
|
---|
[1171] | 6 | # Use dasscm_remote_update to update the configuration files,
|
---|
| 7 | # and the corresponding dasscm_remote_check to perform the
|
---|
| 8 | # related nagios check.
|
---|
[1168] | 9 | # Use only, if a local dasscm installation is not possbile!
|
---|
| 10 |
|
---|
| 11 | DIR="$1"
|
---|
| 12 |
|
---|
| 13 | set -o errexit -o nounset
|
---|
| 14 |
|
---|
| 15 | NAGIOS_OK=0
|
---|
| 16 | NAGIOS_WARN=1
|
---|
| 17 | NAGIOS_CRIT=2
|
---|
| 18 | NAGIOS_UNKNOWN=3
|
---|
| 19 |
|
---|
| 20 | myexit()
|
---|
| 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 |
|
---|
| 43 | if [ -z "$DIR" ]; then
|
---|
| 44 | myexit $NAGIOS_CRIT "no file path given"
|
---|
| 45 | fi
|
---|
| 46 |
|
---|
| 47 | if [ ! -d "$DIR" ]; then
|
---|
| 48 | myexit $NAGIOS_CRIT "failed to access directory $DIR"
|
---|
| 49 | fi
|
---|
| 50 |
|
---|
[1170] | 51 | LOCALCHANGES=`svn status "$DIR"`
|
---|
| 52 | if [ $? -ne 0 ]; then
|
---|
| 53 | myexit $NAGIOS_CRIT "failed to retrieve local subversion info of directory $DIR"
|
---|
| 54 | fi
|
---|
| 55 |
|
---|
[1168] | 56 | DASSCM_RSYNC_OPTIONS=${DASSCM_RSYNC_OPTIONS:-""}
|
---|
[1170] | 57 | export DASSCM_RSYNC_OPTIONS="$DASSCM_RSYNC_OPTIONS --dry-run --checksum --out-format CHANGED:%n%L"
|
---|
[1168] | 58 | CHANGES=`dasscm_remote_update.sh "$@" | sed -n 's/CHANGED://p'`
|
---|
[1170] | 59 | if [ "$CHANGES" ]; then
|
---|
| 60 | myexit $NAGIOS_WARN $CHANGES
|
---|
[1168] | 61 | else
|
---|
[1170] | 62 | LOCALCHANGES=`svn status "$DIR"`
|
---|
| 63 | if [ "$LOCALCHANGES" ]; then
|
---|
| 64 | myexit $NAGIOS_WARN " (local) " $LOCALCHANGES
|
---|
| 65 | else
|
---|
| 66 | myexit $NAGIOS_OK
|
---|
| 67 | fi
|
---|
[1168] | 68 | fi
|
---|
Note:
See
TracBrowser
for help on using the repository browser.