script to check and trigger the alarm