check_salt 553 B

12345678910111213141516
  1. #!/bin/sh
  2. # Check if state-file exists, otherwise exit with unknown
  3. if [ ! -f /var/cache/salt/state_apply ] ; then echo "Statefile does not exist" ; exit 3 ; fi
  4. # Check age of statefile. If it's older than 2 hours, exit with unknown
  5. if [ $(($(date +%s) - $(date -r /var/cache/salt/state_apply +%s))) -gt 25200 ] ; then echo "Statefile too old" ; exit 3 ; fi
  6. if egrep "Succeeded:.*changed=[^0]\)|Failed: [^0]" /var/cache/salt/state_apply > /dev/null ; then
  7. cat /var/cache/salt/state_apply
  8. exit 1 # warning
  9. fi
  10. echo "Nothing to do"
  11. exit 0 # ok