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 |
|
---|
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 |
|
---|
51 | DASSCM_RSYNC_OPTIONS=${DASSCM_RSYNC_OPTIONS:-""}
|
---|
52 | DASSCM_RSYNC_OPTIONS="$DASSCM_RSYNC_OPTIONS --dry-run --checksum --out-format CHANGED:%n%L"
|
---|
53 | CHANGES=`dasscm_remote_update.sh "$@" | sed -n 's/CHANGED://p'`
|
---|
54 | if [ -z "$CHANGES" ]; then
|
---|
55 | myexit $NAGIOS_OK
|
---|
56 | else
|
---|
57 | myexit $NAGIOS_WARN $CHANGES
|
---|
58 | fi
|
---|
Note:
See
TracBrowser
for help on using the repository browser.