Yesterday I had to extract some data from a CDR report for a client, namely call start time, its duration and the called number. And while I am sure Google has zillion scripts to be found, it was much faster to hack this one-liner in AWK .
The script extracts the following fields from the CDR report in this order:
dateTimeOrigination - for outgoing calls it is the time the device goes off hook
callingPartyNumber - initiator of the call
finalCalledPartyNumber - the reached/dialed number (after forwarding if any)
duration - duration of the call
The extracted data is placed in CSV format to be easily imported into Microsoft Excel.Enjoy. Any questions - feel free to ask.
awk -F, 'BEGIN {OFS=","} {print strftime("%c",$5),$9,$31,$56}' report_cdr
Output:
Sun 04 May 2014 01:54:37 PM IDT,0555555555,2988,41Sun 04 May 2014 01:55:07 PM IDT,2908,0555555555,25
In case you want to extract some other fields from CDR , here is the full list of available values and their position. For explanation you can look here - Cisco Call Detail Records Field Descriptions
1 cdrRecordType2 globalCallID_callManagerId3 globalCallID_callId4 origLegCallIdentifier5 dateTimeOrigination6 origNodeId7 origSpan8 origIpAddr9 callingPartyNumber10 callingPartyUnicodeLoginUserID11 origCause_location12 origCause_value13 origPrecedenceLevel14 origMediaTransportAddress_IP15 origMediaTransportAddress_Port16 origMediaCap_payloadCapability17 origMediaCap_maxFramesPerPacket18 origMediaCap_g723BitRate19 origVideoCap_Codec20 origVideoCap_Bandwidth21 origVideoCap_Resolution22 origVideoTransportAddress_IP23 origVideoTransportAddress_Port24 origRSVPAudioStat25 origRSVPVideoStat26 destLegIdentifier27 destNodeId28 destSpan29 destIpAddr30 originalCalledPartyNumber31 finalCalledPartyNumber32 finalCalledPartyUnicodeLoginUserID33 destCause_location34 destCause_value35 destPrecedenceLevel36 destMediaTransportAddress_IP37 destMediaTransportAddress_Port38 destMediaCap_payloadCapability39 destMediaCap_maxFramesPerPacket40 destMediaCap_g723BitRate41 destVideoCap_Codec42 destVideoCap_Bandwidth43 destVideoCap_Resolution44 destVideoTransportAddress_IP45 destVideoTransportAddress_Port46 destRSVPAudioStat47 destRSVPVideoStat48 dateTimeConnect49 dateTimeDisconnect50 lastRedirectDn51 pkid52 originalCalledPartyNumberPartition53 callingPartyNumberPartition54 finalCalledPartyNumberPartition55 lastRedirectDnPartition56 duration57 origDeviceName58 destDeviceName59 origCallTerminationOnBehalfOf60 destCallTerminationOnBehalfOf61 origCalledPartyRedirectOnBehalfOf62 lastRedirectRedirectOnBehalfOf63 origCalledPartyRedirectReason64 lastRedirectRedirectReason65 destConversationId66 globalCallId_ClusterID67 joinOnBehalfOf68 comment69 authCodeDescription70 authorizationLevel71 clientMatterCode72 origDTMFMethod73 destDTMFMethod74 callSecuredStatus75 origConversationId76 origMediaCap_Bandwidth77 destMediaCap_Bandwidth78 authorizationCodeValue79 outpulsedCallingPartyNumber80 outpulsedCalledPartyNumber81 origIpv4v6Addr82 destIpv4v6Addr83 origVideoCap_Codec_Channel284 origVideoCap_Bandwidth_Channel285 origVideoCap_Resolution_Channel286 origVideoTransportAddress_IP_Channel287 origVideoTransportAddress_Port_Channel288 origVideoChannel_Role_Channel289 destVideoCap_Codec_Channel290 destVideoCap_Bandwidth_Channel291 destVideoCap_Resolution_Channel292 destVideoTransportAddress_IP_Channel293 destVideoTransportAddress_Port_Channel294 destVideoChannel_Role_Channel295 incomingProtocolID96 incomingProtocolCallRef97 outgoingProtocolID98 outgoingProtocolCallRef99 currentRoutingReason100 origRoutingReason101 lastRedirectingRoutingReason102 huntPilotDN103 huntPilotPartition104 calledPartyPatternUsage105 outpulsedOriginalCalledPartyNumber106 outpulsedLastRedirectingNumber107 wasCallQueued108 totalWaitTimeInQueue109 callingPartyNumber_uri110 originalCalledPartyNumber_uri111 finalCalledPartyNumber_uri112 lastRedirectDn_uri113 mobileCallingPartyNumber114 finalMobileCalledPartyNumber115 origMobileDeviceName116 destMobileDeviceName117 origMobileCallDuration118 destMobileCallDuration119 mobileCallType120 originalCalledPartyPattern121 finalCalledPartyPattern122 lastRedirectingPartyPattern123 huntPilotPattern
Additional Resources
Follow me on https://www.linkedin.com/in/yurislobodyanyuk/ not to miss what I publish on Linkedin, Github, blog, and more.