#!/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin # 1 hour lock_delay=3600 [[ ! -x `which check_hw_resources` ]] && echo deploy check_hw_resources first && exit 1 [[ ! -x `which dos2unix` ]] && echo install dos2unix first && exit 1 [[ ! -x `which slack_webhook5.bash` ]] && echo deploy slack_webhook5.bash first && exit 1 time=`date +%s` output=`check_hw_resources` if (( $? != 0 )); then if [[ -f /tmp/check_hw_resources.lock ]]; then previous_time=`cat /tmp/check_hw_resources.lock` # lock delay has not been reached yet (( seconds_passed = time - previous_time )) if (( seconds_passed < lock_delay )); then (( seconds_left = lock_delay - seconds_passed )) echo previous lock is still active for $seconds_left seconds exit 0 fi unset previous_time fi echo -n writing new lock /tmp/check_hw_resources.lock ... echo $time > /tmp/check_hw_resources.lock && echo done # self-verbose slack_webhook5.bash check_hw_resources@$HOSTNAME "$output" fi