check_salt 613 B

1234567891011121314151617181920
  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. # List all IDs and exclude ffho-repo
  7. CHANGES_IDS=$(grep "ID:" /var/cache/salt/state_apply | grep -v "ID: .*-repo$")
  8. if [ -n "$CHANGES_IDS" ] ; then
  9. echo "IDs with changes:"
  10. echo "$CHANGES_IDS"
  11. exit 1 # warning
  12. fi
  13. echo "Nothing to do"
  14. exit 0 # ok