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

Last change on this file since 1169 was 1169, checked in by joergs, on Feb 4, 2014 at 6:15:32 PM

executable

  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#!/bin/bash
2
3# dasscm_remote_update is intended for systems
4# where a local dasscm installation is not possible
5# but ssh and rsync is available.
6# In this case,
7# the files from the local repository checkout
8# are updated to the current content.
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
51DASSCM_RSYNC_OPTIONS=${DASSCM_RSYNC_OPTIONS:-""}
52DASSCM_RSYNC_OPTIONS="$DASSCM_RSYNC_OPTIONS --dry-run --checksum --out-format CHANGED:%n%L"
53CHANGES=`dasscm_remote_update.sh "$@" | sed -n 's/CHANGED://p'`
54if [ -z "$CHANGES" ]; then
55 myexit $NAGIOS_OK
56else
57 myexit $NAGIOS_WARN $CHANGES
58fi
Note: See TracBrowser for help on using the repository browser.