Hi All,

Need to Analyze Zimbra Mail server sync.log through shell script

Required output from sync.log

Total Number of Users :
Total Number of Device ID:
Total Number of Device Type with Version :


Below is Sample of Log File :


2009-12-16 00:00:43,970 INFO [btpool0-12194://webmail.amit.com/Microsoft-Server-ActiveSync?Cmd=Ping&User=rahul%40kke.amit.com&DeviceId=androidc986729649&DeviceType=Android] [] sync - POST Microsoft-Server-ActiveSync?Cmd=Ping&User=ritesh%40kke.amit.com&DeviceId=androidc986729649&DeviceType=Android

2009-12-16 00:00:43,971 INFO [btpool0-12194://webmail.amit.com/Microsoft-Server-ActiveSync?Cmd=Ping&User=mohan%40kke.amit.com&DeviceId=androidc986729649&DeviceType=Android] [] sync - DeviceID=androidc986729649; DeviceType=Android; UA=Android/0.3; Protocol=12.0; PolicyKey=null

2009-12-16 00:00:43,971 INFO [btpool0-12194://webmail.amit.com/Microsoft-Server-ActiveSync?Cmd=Ping&User=rahul%40kke.amit.com&DeviceId=androidc986729649&DeviceType=Android] [name=rahul@kke.amit.com;mid=3041;Cmd=Ping;DeviceID=androidc986729649;Version=12.0;] sync - Response size 13 bytes

2009-12-16 00:00:43,971 INFO [btpool0-12194://webmail.amit.com/Microsoft-Server-ActiveSync?Cmd=Ping&User=rahul%40kke.amit.com&DeviceId=androidc986729649&DeviceType=Android] [name=rahul@kke.amit.com;mid=3041;Cmd=Ping;DeviceID=androidc986729649;Version=12.0;] sync - HTTP/1.1 200 OK

2009-12-16 00:00:47,278 INFO [btpool0-12161://webmail.amit.com/Microsoft-Server-ActiveSync?Cmd=Ping&User=hotblast%40amit.com&DeviceId=Moxier359496033451946&DeviceType=MoxierAndroid] [] sync - POST Microsoft-Server-ActiveSync?Cmd=Ping&User=hotblast%40amit.com&DeviceId=Moxier359496033451946&DeviceType=MoxierAndroid

Thanks in Advance

Amit

Doing this in pure shell is a poor approach IMHO. My suggestion would be to use something such as Perl, Python or Ruby to parse the input. In Ruby you might use something like:

#!/usr/bin/env ruby

require 'cgi'

line = "2009-12-16 00:00:43,970 INFO [btpool0-12194://webmail.amit.com/Microsoft-Server-ActiveSync?Cmd=Ping&User=rahul%40kke.amit.com&DeviceId=androidc986729649&DeviceType=Android] [] sync - POST Microsoft-Server-ActiveSync?Cmd=Ping&User=ritesh%40kke.amit.com&DeviceId=androidc986729649&DeviceType=Android"

if line =~ /User=([^&]+)/
    user = CGI.unescape($1)
    puts "Found User: #{user}"
end

if line =~ /DeviceId=([^&]+)/
    id = CGI.unescape($1)
    puts "Found Device ID: #{id}"
end
# Output:
Found User: rahul@kke.amit.com
Found Device ID: androidc986729649
This article has been dead for over six months. Start a new discussion instead.