Skip to content

Instantly share code, notes, and snippets.

@coreyti
Created July 13, 2016 00:37
Show Gist options
  • Save coreyti/430f7225b508084781f24a58758900bd to your computer and use it in GitHub Desktop.
Save coreyti/430f7225b508084781f24a58758900bd to your computer and use it in GitHub Desktop.
`watch` with diff/logging
#!/usr/bin/env bash
LAST_OUTPUT=""
echo > dwatch.log
while true ; do
result="$(monit summary)"
if [ "${result}" != "${LAST_OUTPUT}" ] ; then
compare=$(diff <(echo "${LAST_OUTPUT}") <(echo "${result}"))
message="
$(date)
${compare}
"
echo "${message}
$(cat dwatch.log)" > dwatch.log
clear
echo "${result}
Last change...
${message}
"
LAST_OUTPUT="${result}"
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment