Last active
August 29, 2015 14:13
-
-
Save adionditsak/46a6064b17de7347fbac to your computer and use it in GitHub Desktop.
Count files appended last 10 seconds for access logs and errors logs...
This file contains 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
#!/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