Skip to content

Instantly share code, notes, and snippets.

@adionditsak
Last active August 29, 2015 14:13
Show Gist options
  • Save adionditsak/46a6064b17de7347fbac to your computer and use it in GitHub Desktop.
Save adionditsak/46a6064b17de7347fbac to your computer and use it in GitHub Desktop.
Count files appended last 10 seconds for access logs and errors logs...
#!/bin/bash
# Count appended lines last 10 seconds simultanously
# CentOS/RHEL
LOGPATH="/var/log/httpd/"
# Ubuntu/Debian
# LOGPATH="/var/log/apache2/"
main() {
echo ""
echo "access + error log activity last 10 seconds"
echo "- Ignoring logs with 0 activity"
echo ""
echo "Processing..."
looplogs
read
}
looplogs() {
for i in ${LOGPATH}*access_log*; do
(
before=$(wc -l < $i)
sleep 10
after=$(wc -l < $i)
let dif=after-before
if [[ $dif -ne 0 ]]; then
echo "ACCESS LOG: $i - $dif"
fi
) &
done
for i in ${LOGPATH}*error_log*; do
(
before=$(wc -l < $i)
sleep 10
after=$(wc -l < $i)
let dif=after-before
if [[ $dif -ne 0 ]]; then
echo "ERROR LOG: $i - $dif"
fi
) &
done
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment