954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Shell Script to Analyze Zimbra Sync.log

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

aamitrhce
Newbie Poster
1 post since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

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
L7Sqr
Practically a Master Poster
657 posts since Feb 2011
Reputation Points: 201
Solved Threads: 124
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: