I have an atypical use for SEC, in which I'm parsing Asterisk log files to
produce CSV peg counts for downstream usage reporting.
This is working well and I'm loving this tool!
However, I've run into a problem that I cannot seem to find a way around.
The log file produces events that are tied to a unique ID for each channel/call
( C-00000000 ), and using that, plus the timestamp, I can produce output that
is correlated with a call, and chronological. So far so good.
However, there's one event that is difficult to work with, because it can
happen more than once on a typical phone call, needs to correlate with an event
that happens a few lines prior, but carries no identifying correlation.
Here's an example of the output I'm working with (curated for brevity and
relevance, and specific to a single unique ID; there are actually hundreds of
lines of output per-call):
[2022-02-08-06:17:53:] VERBOSE[24858][C-00004037] pbx.c: Executing
[8005551234@ivr-welcome:9] Read("SIP/CHANNELNAME-000138ac",
"EarlyChoice,prompts/001,1,,0,0.01") in new stack
[2022-02-08-06:17:53:] VERBOSE[24858][C-00004037] app_read.c: Accepting a
maximum of 1 digits.
[2022-02-08-06:17:53:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/001.slin' (language 'en')
[2022-02-08-06:17:55:] VERBOSE[24858][C-00004037] app_read.c: User entered
nothing.
--
[2022-02-08-06:17:55:] VERBOSE[24858][C-00004037] pbx.c: Executing
[8005551234@ivr-welcome:13] Read("SIP/CHANNELNAME-000138ac",
"EarlyChoice,prompts/001,1,,0,0.01") in new stack
[2022-02-08-06:17:55:] VERBOSE[24858][C-00004037] app_read.c: Accepting a
maximum of 1 digits.
[2022-02-08-06:17:55:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/001.slin' (language 'fr')
[2022-02-08-06:17:58:] VERBOSE[24858][C-00004037] app_read.c: User entered
nothing.
--
[2022-02-08-06:17:58:] VERBOSE[24858][C-00004037] pbx.c: Executing
[8005551234@ivr-welcome:17] Read("SIP/CHANNELNAME-000138ac",
"LanguageChoice,prompts/002,1,,,0.01") in new stack
[2022-02-08-06:17:58:] VERBOSE[24858][C-00004037] app_read.c: Accepting a
maximum of 1 digits.
[2022-02-08-06:17:58:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/002.slin' (language 'en')
[2022-02-08-06:18:01:] VERBOSE[24858][C-00004037] app_read.c: User entered
nothing.
--
[2022-02-08-06:18:01:] VERBOSE[24858][C-00004037] pbx.c: Executing
[8005551234@ivr-welcome:21] Read("SIP/CHANNELNAME-000138ac",
"LanguageChoice,prompts/002,1,,1,15") in new stack
[2022-02-08-06:18:01:] VERBOSE[24858][C-00004037] app_read.c: Accepting a
maximum of 1 digits.
[2022-02-08-06:18:01:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/002.slin' (language 'fr')
[2022-02-08-06:18:01:] VERBOSE[24858][C-00004037] app_read.c: User entered '1'
--
[2022-02-08-06:18:01:] VERBOSE[24858][C-00004037] pbx.c: Executing
[8005551234@ivr-welcome:34] Read("SIP/CHANNELNAME-000138ac",
"ActivationHelp,prompts/902&prompts/063,1,,,15,") in new stack
[2022-02-08-06:18:01:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/902.slin' (language 'en')
[2022-02-08-06:18:16:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/063.slin' (language 'en')
[2022-02-08-06:18:32:] VERBOSE[24858][C-00004037] app_read.c: User entered '3'
--
[2022-02-08-06:19:36:] VERBOSE[24858][C-00004037] pbx.c: Executing
[8005551234@ivr-MainMenu:2] Read("SIP/CHANNELNAME-000138ac",
"ListenForZero,prompts/044,1,,,0.01") in new stack
[2022-02-08-06:19:36:] VERBOSE[24858][C-00004037] app_read.c: Accepting a
maximum of 1 digits.
[2022-02-08-06:19:36:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/044.slin' (language 'en')
[2022-02-08-06:19:46:] VERBOSE[24858][C-00004037] app_read.c: User entered
nothing.
--
[2022-02-08-06:19:55:] VERBOSE[24858][C-00004037] pbx.c: Executing
[8005551234@ivr-MainMenu:8] Read("SIP/CHANNELNAME-000138ac",
"ListenForZero,prompts/045,1,,,0.01") in new stack
[2022-02-08-06:19:55:] VERBOSE[24858][C-00004037] app_read.c: Accepting a
maximum of 1 digits.
[2022-02-08-06:19:55:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/045.slin' (language 'en')
[2022-02-08-06:19:57:] VERBOSE[24858][C-00004037] app_read.c: User entered
nothing.
--
[2022-02-08-06:20:02:] VERBOSE[24858][C-00004037] pbx.c: Executing
[8005551234@ivr-MainMenu:11] Read("SIP/CHANNELNAME-000138ac",
"ListenForZero,prompts/045a,1,,,0.01") in new stack
[2022-02-08-06:20:02:] VERBOSE[24858][C-00004037] app_read.c: Accepting a
maximum of 1 digits.
[2022-02-08-06:20:02:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/045a.slin' (language 'en')
[2022-02-08-06:20:04:] VERBOSE[24858][C-00004037] app_read.c: User entered
nothing.
--
[2022-02-08-06:20:07:] VERBOSE[24858][C-00004037] pbx.c: Executing
[8005551234@ivr-MainMenu:15] Read("SIP/CHANNELNAME-000138ac",
"ListenForZero,prompts/046,1,,,0.01") in new stack
[2022-02-08-06:20:07:] VERBOSE[24858][C-00004037] app_read.c: Accepting a
maximum of 1 digits.
[2022-02-08-06:20:07:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/046.slin' (language 'en')
[2022-02-08-06:20:09:] VERBOSE[24858][C-00004037] app_read.c: User entered
nothing.
--
[2022-02-08-06:20:18:] VERBOSE[24858][C-00004037] pbx.c: Executing
[8005551234@ivr-MainMenu:39] Read("SIP/CHANNELNAME-000138ac",
"ListenForZero,prompts/049,1,,,0.01") in new stack
[2022-02-08-06:20:18:] VERBOSE[24858][C-00004037] app_read.c: Accepting a
maximum of 1 digits.
[2022-02-08-06:20:18:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/049.slin' (language 'en')
[2022-02-08-06:20:21:] VERBOSE[24858][C-00004037] app_read.c: User entered
nothing.
--
[2022-02-08-06:20:26:] VERBOSE[24858][C-00004037] pbx.c: Executing
[8005551234@ivr-MainMenu:45] Read("SIP/CHANNELNAME-000138ac",
"BalanceRepeatPressed,prompts/004h&prompts/004i&prompts/043,1,,,15") in new
stack
[2022-02-08-06:20:26:] VERBOSE[24858][C-00004037] app_read.c: Accepting a
maximum of 1 digits.
[2022-02-08-06:20:26:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/004h.slin' (language 'en')
[2022-02-08-06:20:29:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/004i.slin' (language 'en')
[2022-02-08-06:20:32:] VERBOSE[24858][C-00004037] app_read.c: User entered '1'
--
[2022-02-08-06:20:32:] VERBOSE[24858][C-00004037] pbx.c: Executing
[8005551234@ivr-MainMenu:2] Read("SIP/CHANNELNAME-000138ac",
"ListenForZero,prompts/044,1,,,0.01") in new stack
[2022-02-08-06:20:32:] VERBOSE[24858][C-00004037] app_read.c: Accepting a
maximum of 1 digits.
[2022-02-08-06:20:32:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/044.slin' (language 'en')
[2022-02-08-06:20:42:] VERBOSE[24858][C-00004037] app_read.c: User entered
nothing.
--
[2022-02-08-06:20:51:] VERBOSE[24858][C-00004037] pbx.c: Executing
[8005551234@ivr-MainMenu:8] Read("SIP/CHANNELNAME-000138ac",
"ListenForZero,prompts/045,1,,,0.01") in new stack
[2022-02-08-06:20:51:] VERBOSE[24858][C-00004037] app_read.c: Accepting a
maximum of 1 digits.
[2022-02-08-06:20:51:] VERBOSE[24858][C-00004037] file.c:
<SIP/CHANNELNAME-000138ac> Playing 'prompts/045.slin' (language 'en')
[2022-02-08-06:20:53:] VERBOSE[24858][C-00004037] app_read.c: User entered
nothing.
The event I want to peg is each of the ' app_read.c: User entered ' events, but
they each need to correlate with the Read("SIP/CHANNELNAME ... event that
precedes them.
Here is a rule I've written specifically to attempt to catch a line containing
Read("SIP/CHANNELNAME-000138ac",
"ActivationHelp,prompts/902&prompts/063,1,,,15,") :
(it's a bit of a mess because I've been trying differnt things to get it to
work the way I need it to)
(the regexp is probably overly elaborate, but regex101.com makes it too fun not
to!)
type=PAIR
desc=IVR caller offered activation or statement inquiry
ptype=RegExp
action=create IVR_activation_offered_$4 ; \
write - $4 activation or statement inquiry offered
pattern=^.*\[(20[234][0-9]-[0-9]{2}-[0-3][0-9])-([0-2][0-9]:[0-5][0-9]:[0-5][0-9]).*VERBOSE\[([0-9]{3,6})\]\[(C-[0-9a-f]{8})\].*Executing
\[(.+)\@(flexiti-ivr-welcome:[0-9]{1,3})\] (.+)\(\"([A-Z]{3,10})\/(.+)\",
\"ActivationHelp,prompts.*
ptype2=regexp
pattern2=^.*\[(20[234][0-9]-[0-9]{2}-[0-3][0-9])-([0-2][0-9]:[0-5][0-9]:[0-5][0-9]).*VERBOSE\[([0-9]{3,6})\]\[(C-[0-9a-f]{8})\].*
app_read.c: User entered '?(nothing|[0-9]*)'?.*
desc2=Flexiti IVR - caller selection at activation or statement inquiry
action2=assign %i -ivr ; \
write %p%i.csv $1,$2,$4,,,,,,,,,$5 ; closef %p%i.csv ; \
write - $4 ACTIVATION_STATEMENT %p %i $1 User entered: $5
This works, but then keeps matching the pattern2 throughout the call, whereas
what I want is to match the ActivationHelp, then match the very first 'User
entered' following that, and then stop matching for this rule. There will be
other similar matches too (but not ' ActivationHelp '), and those too need to
correlate with one and only the first ' User entered ' that follows them.
I'm sure it's something simple I'm missing, but I've been banging my head
against the wall on this and I just can't see where my error is.
I'm still learning SEC, so there's a lot I just don't get, and this is right at
the limits of my skills.
Any and all advice would be gratefully appreciated.
Jim
--
Jim Van Meggelen
ClearlyCore Inc.
+1-416-639-6001 (DID)
+1-877-253-2716 (Canada)
+1-866-644-7729 (USA)
+1-416-425-6111 x6001
[email protected]
[ http://www.clearlycore.com/ | http://www.clearlycore.com ]
Asterisk: The Definitive Guide
FIFTH EDITION NOW AVAILABLE TO DOWNLOAD:
[ https://cdn.oreillystatic.com/pdf/Asterisk_The_Definitive_Guide.pdf |
https://cdn.oreillystatic.com/pdf/Asterisk_The_Definitive_Guide.pdf ]
_______________________________________________
Simple-evcorr-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users