Skip to content

Instantly share code, notes, and snippets.

@SamJUK
Last active November 30, 2021 16:12
Show Gist options
  • Save SamJUK/ff953fa7b8055491f190dbb97e590a7c to your computer and use it in GitHub Desktop.
Save SamJUK/ff953fa7b8055491f190dbb97e590a7c to your computer and use it in GitHub Desktop.
Fetch and count all Magento reports (fatal error) exception messages from stack traces.
// Fetch and count all Magento reports (fatal error) exception messages from stack traces.
find /var/www/vhosts/prod.site.com/htdocs/var/report -type f -exec python -m json.tool {} \; | grep -i '"0":' | awk -F\" '{print $4}' | sort | uniq -c | sort -h
// Delete reports over 30 days old
find /var/www/vhosts/prod.site.com/htdocs/var/report -mindepth 1 -maxdepth 1 -type f -mtime +30 -delete
#!/usr/bin/env sh
#
# Place & execute from within the Magento root.
#
CNT_WEB_REPORTS=$(find ./var/report -maxdepth 1 -type f | wc -l)
CNT_API_REPORTS=$(find ./var/report/api -maxdepth 1 -type f | wc -l)
CNT_TOT_REPORTS=$(expr "$CNT_WEB_REPORTS" + "$CNT_API_REPORTS")
echo "Web Reports:"
echo ""
find ./var/report -maxdepth 1 -type f -exec python -m json.tool {} \; | grep -i '"0":' | awk -F\" '{print $4}' | sort | uniq -c | sort -h
echo ""
echo "API Reports:"
echo ""
find ./var/report/api -maxdepth 1 -type f -exec python -m json.tool {} \; | grep -i '"0":' | awk -F\" '{print $4}' | sort | uniq -c | sort -h
echo ""
echo ""
echo "Count:"
echo " - Web: $CNT_WEB_REPORTS"
echo " - API: $CNT_API_REPORTS"
echo " - Total: $CNT_TOT_REPORTS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment