Created
July 13, 2016 00:37
-
-
Save coreyti/430f7225b508084781f24a58758900bd to your computer and use it in GitHub Desktop.
`watch` with diff/logging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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