Parse compressed apache error log file and show top errors

zcat error.log.gz | sed 's^\[.*\]^^g' | sed 's^\, referer: [^\n]*^^g' | sort | uniq -c | sort -n
credit shall fall to this for non-gzipped version: https://gist.github.com/marcanuy/a08d5f2d9c19ba621399
Sample Output
   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

1
By: zanhsieh
2014-09-24 05:26:24

These Might Interest You

  • This searches the Apache error_log for each of the 5 most significant Apache error levels, if any are found the date is then cut from the output in order to sort then print the most common occurrence of each error. Show Sample Output


    4
    for i in emerg alert crit error warn ; do awk '$6 ~ /^\['$i'/ {print substr($0, index($0,$6)) }' error_log | sort | uniq -c | sort -n | tail -1; done
    zlemini · 2010-04-15 21:47:18 0
  • Simply add this to whatever apache startup script you have, or if you are on a MAC, create a new automator application. This will show a pretty growl notification whenever theres a new Apache error log entry. Useful for local development


    0
    /usr/bin/tail -fn0 /path/to/apache_error.log | while read line; do /usr/local/bin/growlnotify --title "Apache Notice" --message "$line"; done &
    jhyland87 · 2013-01-22 05:25:41 0
  • btrfs checksum errors console report. Show Sample Output


    0
    echo "btrfs checksum error(s) on: " && grep "btrfs: checksum error at logical" /var/log/messages | sed -e 's/^.*\( dev .*\)\(, sector.*\)\(path\: .*\))/\t\1, \3/' | sort | uniq
    jcoll · 2014-07-01 08:56:05 0
  • If you follow my other posting regarding "vipw" and "vigr' then no explanation required.It has done the same thing as did with those two command.Open the /etc/sudoers file and attach a lock with it. Once you are done with it ,the lock gets released and the changes reflected to the original file.It will open a tmp file in vi editor to give you the chance to edit the sudoers file securely.visudo parses the sudoers file after the edit and will not save the changes if there is a syntax error. Upon finding an error, visudo will print a message stating the line number(s) where the error occurred and the user will receive the "What now?" prompt. At this point the user may enter "e" to re-edit the sudoers file, "x" to exit without saving the changes, or "Q" to quit and save changes. The "Q" option should be used with extreme care because if visudo believes there to be a parse error, so will sudo and no one will be able to sudo again until the error is fixed. If "e" is typed to edit the sudoers file after a parse error has been detected, the cursor will be placed on the line where the error occurred (if the editor supports this feature). PS: Although I have had experienced myself and few people shown to me that it behaves badly in some distribution ,noteably SLES.But the problem can be rectified with little caution. Show Sample Output


    -3
    visudo
    unixbhaskar · 2009-08-29 04:06:11 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: