diff --git a/icinga-cli.sh b/icinga-cli.sh index 5748e41b78b34d6468d0dad5a17792ef434d6e88..ce521bad631acae048f6e9eb26ef01684ebf3588 100755 --- a/icinga-cli.sh +++ b/icinga-cli.sh @@ -14,7 +14,7 @@ _product="ICINGA PASSIVE CLIENT" -_version="0.5" +_version="0.6" _license="GNU GPL 3.0" _copyright='(c) 2020 Institute for Medical Education * University of Bern' @@ -113,7 +113,18 @@ function loopChecks(){ _log "---------- starting in a permanent loop" echo "Serviceloop started `date` - process id $$" > "${lockfile}" - _getFileSnapshot>$snapShotStart + if [ $? -ne 0 ]; then + _log "ABORT: Lock file is not writable ${lockfile}." + ls -l "${lockfile}" + exit 1 + fi + + _getFileSnapshot>${snapShotStart} + if [ $? -ne 0 ]; then + _log "ABORT: Snapshot file is not writable ${snapShotStart}." + ls -l "${snapShotStart}" + exit 1 + fi while true; do # typeset -i local iSleep=$(($RANDOM%$sleeptime)) # sleep minimum is half of $sleeptime @@ -123,6 +134,11 @@ function loopChecks(){ _log "______________________________________________________________________" _log "" _getFileSnapshot>$snapShotCurrent + if [ $? -ne 0 ]; then + _log "ABORT: Snapshot file is not writable ${snapShotCurrent}." + ls -l "${snapShotCurrent}" + exit 1 + fi diff $snapShotStart $snapShotCurrent >/dev/null if [ $? -ne 0 ]; then _log "ABORT: Files were updated / overwritten. The loop must be restarted.\n`diff $snapShotStart $snapShotCurrent`"