How to examine the reports files for Magento (and not burn your eyes)
Magento

How to examine the reports files for Magento (and not burn your eyes)

I was recently asked by a client for a snippet of Linux CLI that I use to get a summary of Magento reports files under var/reports.  I don’t guarantee that this is the best CLI command, but this is what I use

head -n 1 * | grep -v == | grep -v -e '^$' | awk -F \" '{ print $2 }' | sort | uniq -c | sort -n
 1 SQLSTATE[HY000] [1049] Unknown database 'magento19'
 1 SQLSTATE[HY000] [2002] Connection refused
 2 Cannot send headers; headers already sent in , line 0
 3 SQLSTATE[HY000] [2002] No such file or directory

If you want to format it so you can copy and paste into Excel (for charting)

head -n 1 * | grep -v == | grep -v -e '^$' | awk -F \" '{ print $2 }' | sort  | uniq -c | sort -n | sed 's/^ *//;s/ *$//' | awk '{ a=$1;sub("[^"FS"]+["FS"]+",""); printf "\"%s\",%d\n", $0, a}'

If you only want to check the last 1000 reports

head -n 1 `ls -t | head -n 1000`  | grep -v == | grep -v -e '^$' | awk -F \" '{ print $2 }' | sort | uniq -c | sort -n

Feel free to post corrections or other useful CLI commands in the comments if you like.

1 thought on “How to examine the reports files for Magento (and not burn your eyes)”

Leave a Reply

Your email address will not be published. Required fields are marked *