I was surprised when I saw the length of the Chrome user agent string last week:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.X.Y.Z Safari/525.13
And in our logs:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.29 Safari/525.13
a user agent string of 119 characters. It looks quite a waste of space but is Google Chrome the only one? Surprisingly, Chrome is far from the worst.
Best of one of our log file:
awk -F\" '{print length($6)" "$6}' access.log
awk -F\" '{if ($6 > 200) print length($6)" "$6}' access.log
In those examples, the access.log file has this log format:
xxx.xxx.xxx.xxx \ www.domain.com - \ [15/Sep/2008:00:00:00 +0200] \ "GET / HTTP/1.1" 200 4242 \ "http://www.domain.com/" \ "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1"
If you take an average user agent string likes the Firefox one, you have a 91 charaters string.
awk -F\" '{if (length($6) > 120) print length($6)}' access.log | wc -l
awk -F\" '{if (length($6) > 120) SUM += length($6)-120} END {print SUM/1024/1024" Mo"}' access.log
This entry was written by , posted on September 22, 2008 at 7:48 am, filed under Logs, Web and tagged awk, bandwidth, user agent. Leave a comment or view the discussion at the permalink.
Logcheck is a tool to parse system logs and send summaries by email. It filters out logs with a regular expressions database to suppress common/normal entries.
Are you reading / checking your log files? Too many servers? logcheck will help you in this task and eliminates the noise.
# apt-get install logcheck Reading package lists... Done Building dependency tree... Done The following extra packages will be installed: lockfile-progs logtail Suggested packages: syslog-summary Recommended packages: logcheck-database The following NEW packages will be installed: lockfile-progs logcheck logtail 0 upgraded, 3 newly installed, 0 to remove and 6 not upgraded. Need to get 110kB of archives. After unpacking 428kB of additional disk space will be used. Do you want to continue [Y/n]?
Also install logcheck-database which contains lots of rules
# apt-get install logcheck-database
You can try it by executing the following command:
# su -s /bin/bash -c "/usr/sbin/logcheck" logcheck
Your mailbox should now contains a report from logcheck if some unusual log entries have been found.
This entry was written by , posted on September 16, 2008 at 11:22 am, filed under Logs and tagged logcheck. Leave a comment or view the discussion at the permalink.
This post is a quick ref on the linux touch command. All the examples have been tested on Linux.
This command is used to update the access and modification times of files.
touch [option] file_name(s) touch file1 file2 file3
# touch /tmp/file # ls -l /tmp/file rw-r--r-- 1 charlybr charlybr 0 Sep 10 16:13 /tmp/file
# ls -l /tmp/file rw-r--r-- 1 charlybr charlybr 0 Sep 10 16:13 /tmp/file # touch /tmp/file # ls -l /tmp/file rw-r--r-- 1 charlybr charlybr 0 Sep 10 16:14 /tmp/file
# touch -t 09091842 /tmp/file # ls -l /tmp/file -rw-r--r-- 1 charlybr charlybr 0 Sep 9 18:42 /tmp/file
# touch -d '9 Sep' /tmp/file # ls -l /tmp/file -rw-r--r-- 1 charlybr charlybr 0 Sep 9 00:00 /tmp/file # touch -d '9 Sep 2008 13:14' /tmp/file # ls -l /tmp/file -rw-r--r-- 1 charlybr charlybr 0 Sep 9 13:14 /tmp/file
This entry was written by , posted on September 11, 2008 at 7:30 am, filed under Command line and tagged coretutils, shell. Leave a comment or view the discussion at the permalink.