Skip to content

Instantly share code, notes, and snippets.

@marcanuy
Last active April 1, 2024 15:25
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save marcanuy/a08d5f2d9c19ba621399 to your computer and use it in GitHub Desktop.
Save marcanuy/a08d5f2d9c19ba621399 to your computer and use it in GitHub Desktop.
Apache error log list ordered by most common errors
#!/bin/bash
sed 's^\[.*\]^^g' error.log | sed 's^\, referer: [^\n]*^^g' | sort | uniq -c | sort -n
Based in http://strictcoder.blogspot.com/2012/02/linux-count-unique-error-log-entries.html
1 AH00126: Invalid URI in request GET HTTP/1.1
1 PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 32 bytes) in /var/www/con/libraries/joomla/database/driver/mysql.php on line 425
108 PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 512 bytes) in /var/www/es/libraries/joomla/database/driver/mysql.php on line 425
156 PHP Notice: Undefined index: select in /var/www/con/cli/form_output.php on line 3
156 PHP Notice: Undefined index: inputfrom_value in /var/www/con/cli/form_output.php on line 2
157 PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 83 bytes) in /var/www/es/libraries/joomla/database/driver/mysql.php on line 425
202 PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 32 bytes) in /var/www/es/libraries/joomla/database/driver/mysql.php on line 425
218 PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 80 bytes) in /var/www/es/libraries/joomla/database/driver/mysql.php on line 425
316 PHP Notice: Undefined index: in /var/www/conven/cli/units.php on line 513
520 PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 81 bytes) in /var/www/es/libraries/joomla/database/driver/mysql.php on line 425
@zanhsieh
Copy link

thanks for wonderful script. below is for compressed log file (e.g. error.log.gz):

!/bin/bash

zcat error.log.gz | sed 's^[.]^^g' | sed 's^, referer: [^\n]^^g' | sort | uniq -c | sort -n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment