mgparser 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/mgparser +2 -5
- data/lib/call.rb +29 -103
- data/lib/version.rb +1 -1
- metadata +8 -8
data/bin/mgparser
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), ".", "../lib"))
|
3
3
|
require 'rubygems'
|
4
|
-
require 'bundler/setup'
|
5
4
|
require 'eventmachine'
|
6
5
|
require 'snmp'
|
7
6
|
require 'optparse'
|
@@ -116,13 +115,11 @@ else
|
|
116
115
|
begin
|
117
116
|
EventMachine::open_datagram_socket host, port, SyslogServer
|
118
117
|
rescue RuntimeError, Interrupt
|
119
|
-
puts "
|
118
|
+
puts "Are you root?"
|
120
119
|
abort ""
|
121
120
|
end
|
122
121
|
end
|
123
|
-
rescue Interrupt
|
122
|
+
rescue RuntimeError,Interrupt
|
124
123
|
puts "Interrupted"
|
125
|
-
rescue RuntimeError
|
126
|
-
puts "Are you root?"
|
127
124
|
end
|
128
125
|
end
|
data/lib/call.rb
CHANGED
@@ -2,10 +2,7 @@ class Call
|
|
2
2
|
attr_accessor :data
|
3
3
|
|
4
4
|
def analyze(data,is_file)
|
5
|
-
|
6
|
-
@callprogr_counter = 0
|
7
|
-
@matched = 0
|
8
|
-
|
5
|
+
|
9
6
|
if is_file == true
|
10
7
|
data.each do |line|
|
11
8
|
parse(line)
|
@@ -17,107 +14,36 @@ attr_accessor :data
|
|
17
14
|
end
|
18
15
|
|
19
16
|
def parse(line)
|
20
|
-
if line =~ /
|
21
|
-
@
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@
|
28
|
-
|
29
|
-
|
30
|
-
elsif line =~ /UseNextDestination - Call \d{1,}-\d{1,}/
|
31
|
-
id = line.scan(/UseNextDestination - Call \d{1,}-(\d{1,})/).flatten!.first
|
32
|
-
if @matched < 1
|
33
|
-
if @inbound == true
|
34
|
-
@matched += 1
|
35
|
-
else
|
36
|
-
puts "Call ID: #{id} - Caller: #{@caller}"
|
37
|
-
puts "Call ID: #{id} - Called: #{@called}"
|
38
|
-
end
|
39
|
-
else
|
40
|
-
puts "Call ID: #{id} - Caller: #{@caller}"
|
41
|
-
puts "Call ID: #{id} - Called: #{@called}"
|
42
|
-
@matched = 0
|
43
|
-
end
|
44
|
-
|
45
|
-
elsif line =~ /CallManager \[.*\] C\d{1,} - Send CallSetupA/
|
46
|
-
id = line.scan(/C(\d{1,}) -/).flatten!.first
|
47
|
-
if @inbound == true
|
48
|
-
puts "Call ID: #{id} - <== ISDN setup received"
|
49
|
-
else
|
50
|
-
puts "Call ID: #{id} - ==> ISDN setup sent"
|
17
|
+
if line =~ /IsdnStackL3Msg.*Call \d{1,}-(In|Out)bound/
|
18
|
+
@id, @direction, @content = line.scan(/IsdnStackL3Msg.*Call (\d{1,})-.*(RECV|SEND) (\w{1,}.*) \(/).flatten!
|
19
|
+
|
20
|
+
if @direction == "SEND" and @content != "Disconnect" and @content != "Release"
|
21
|
+
puts "Call #{@id} - ==> Sent \"#{@content}\""
|
22
|
+
elsif @direction == "RECV" and @content == "Notify"
|
23
|
+
nil
|
24
|
+
elsif @direction == "RECV" and @content != "Disconnect" and @content != "Release"
|
25
|
+
puts "Call #{@id} - <== Received \"#{@content}\""
|
51
26
|
end
|
52
|
-
@inbound = false
|
53
|
-
|
54
|
-
elsif line =~ /"Proceeding Indication" .* for state CallSetup./
|
55
|
-
@progress_indication = true
|
56
|
-
|
57
|
-
elsif line =~ /CallManager \[.*\] C\d{1,} - CallProgressA\(2\)/
|
58
|
-
@callprogr_counter += 1
|
59
|
-
id = line.scan(/C(\d{1,}) -/).flatten!.first
|
60
|
-
|
61
|
-
if @progress_indication == true
|
62
|
-
#puts "Call ID: #{id} - <== \"Proceeding indication\" received from operator"
|
63
|
-
@progress_indication = false
|
64
|
-
else
|
65
|
-
if @callprogr_counter >= 3
|
66
|
-
puts "Call ID: #{id} - <== The call will be probably answered by operator\'s voicemail or is being forwarded"
|
67
|
-
@callprogr_counter = 0
|
68
|
-
else
|
69
|
-
puts "Call ID: #{id} - <== \"Call Progress\" received from operator"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
elsif line =~ /CallManager \[.*\] C\d{1,} - CallProgressA\(3\)/
|
74
|
-
id = line.scan(/C(\d{1,}) -/).flatten!.first
|
75
|
-
puts "Call ID: #{id} - ==> \"Call Progress\" sent to the operator"
|
76
|
-
|
77
|
-
|
78
|
-
elsif line =~ /CallManager \[.*\] C\d{1,} - CallProgressA\(1\)/
|
79
|
-
id = line.scan(/C(\d{1,}) -/).flatten!.first
|
80
|
-
puts "Call ID: #{id} - <== Destination number is ringing"
|
81
|
-
|
82
|
-
|
83
|
-
elsif line =~ /CallManager \[.*\] C\d{1,} - CallConnectA/
|
84
|
-
id = line.scan(/C(\d{1,}) -/).flatten!.first
|
85
|
-
puts "Call ID: #{id} - Call has been answered!"
|
86
|
-
|
87
|
-
|
88
|
-
elsif line =~ /CallManager \[.*\] C\d{1,} - CallMessageA\(2\)/
|
89
|
-
id = line.scan(/C(\d{1,}) -/).flatten!.first
|
90
|
-
@isdn_inbound_disconnect = true
|
91
|
-
|
92
|
-
elsif line =~ /CallManager.* Call is not allowed/
|
93
|
-
@resource_unavailable = true
|
94
|
-
@resource_unavailable_id = line.scan(/CallManager \[.*\] C\d{1,}-(\d{1,})/).flatten!.first
|
95
27
|
|
96
|
-
elsif line =~ /
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
if @resource_unavailable == true
|
103
|
-
id = @resource_unavailable_id
|
104
|
-
@resource_unavailable = false
|
105
|
-
elsif @abnormal_hangup == true
|
106
|
-
id = @abnormal_hangup_id
|
107
|
-
@abnormal_hangup = false
|
108
|
-
else
|
109
|
-
id = line.scan(/C(\d{1,}) -/).flatten!.first
|
28
|
+
elsif line =~ /IsdnStackL3Msg.*IE (Called|Calling) Party Number/
|
29
|
+
origin, number = line.scan(/IsdnStackL3Msg.*IE (Called|Calling) Party Number.*'(\d{1,})'/).flatten!
|
30
|
+
if origin == "Called"
|
31
|
+
puts "Call #{@id} - Called number: #{number}"
|
32
|
+
elsif origin == "Calling"
|
33
|
+
puts "Call #{@id} - Calling number: #{number}"
|
110
34
|
end
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
35
|
+
|
36
|
+
elsif line =~ /IsdnStackL3Msg.*IE Notification Indicator/
|
37
|
+
notification = line.scan(/IsdnStackL3Msg.*IE Notification Indicator.*Description: (.*) \(/).flatten!.first
|
38
|
+
puts "Call #{@id} - <== Received Notify: \"#{notification}\" (if you called a mobile number it could be the VoiceMail)"
|
39
|
+
|
40
|
+
elsif line =~ /IsdnStackL3Msg.*IE Cause/
|
41
|
+
cause = line.scan(/IsdnStackL3Msg.*IE Cause.* Cause.*\((.*)\)/).flatten!.first
|
42
|
+
if @direction == "RECV"
|
43
|
+
puts "Call #{@id} - <== Received \"#{@content}\" with cause: \"#{$causes[cause]}\""
|
44
|
+
elsif @direction == "SEND"
|
45
|
+
puts "Call #{@id} - ==> Sent \"#{@content}\" with cause: \"#{$causes[cause]}\""
|
118
46
|
end
|
119
|
-
|
120
47
|
end
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|
48
|
+
end #parse
|
49
|
+
end # Call
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mgparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-05-15 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &2151832240 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.10
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2151832240
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: eventmachine
|
27
|
-
requirement: &
|
27
|
+
requirement: &2151830620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2151830620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: snmp
|
38
|
-
requirement: &
|
38
|
+
requirement: &2151829400 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2151829400
|
47
47
|
description: MGParser (MGP) is a tool which makes analysis of Mediatrix ISDN gateways
|
48
48
|
debug a much simpler task
|
49
49
|
email: dawid.pogorzelski@mybushido.com
|