itrp 0.1.0 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +4 -5
- data/Gemfile.lock +80 -63
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/itrp.gemspec +93 -0
- data/lib/cmd_base.rb +4 -0
- data/lib/cmd_root.rb +4 -3
- data/lib/handlers/agg_flow.rb +91 -0
- data/lib/handlers/alert.rb +11 -6
- data/lib/handlers/delete_alerts.rb +2 -2
- data/lib/handlers/edges.rb +60 -0
- data/lib/handlers/grep.rb +47 -0
- data/lib/handlers/keyspace.rb +51 -0
- data/lib/handlers/list_counters.rb +12 -3
- data/lib/handlers/metric_summ.rb +38 -0
- data/lib/handlers/options.rb +1 -1
- data/lib/handlers/pcap.rb +41 -0
- data/lib/handlers/probe.rb +26 -0
- data/lib/handlers/query_flow.rb +8 -15
- data/lib/handlers/query_fts.rb +2 -2
- data/lib/handlers/query_resource.rb +2 -6
- data/lib/handlers/searchkey.rb +61 -0
- data/lib/handlers/setlabel.rb +37 -0
- data/lib/handlers/timeslices.rb +29 -4
- data/lib/handlers/toppers.rb +7 -2
- data/lib/handlers/toptrend.rb +51 -0
- data/lib/handlers/trackers.rb +12 -4
- data/lib/handlers/traffic.rb +36 -21
- data/lib/handlers/volume.rb +54 -0
- data/lib/itrp.rb +31 -9
- metadata +27 -32
- data/lib/handlers/getkey.rb +0 -38
- data/lib/handlers/resolve.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3ffff7019757ae2b6033b49cf1c54aa1b54ca1ac10047cb6834ef0803e2c3e47
|
4
|
+
data.tar.gz: d78afca17d762a712ff0b2e7f61ee35c025ceb42e0a99d1b24b1f99ab18128c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc5c42293f99045c833b0706b64664194ffd381305a7926d7acfd667bea2f152f5a17e78673c77ec74b1b1adbba95555aceda9bdf4b55d495bc03ba742a4fc75
|
7
|
+
data.tar.gz: 389a0ac9c3106132373288b947cec78e9f60104664508a2c5072f1ceaf939b14ac144dc284f4c35b74747278f7d34622df47f8718872ff5b7bdabac3f608117a
|
data/Gemfile
CHANGED
@@ -11,9 +11,8 @@ gem "terminal-table"
|
|
11
11
|
# Add dependencies to develop your gem here.
|
12
12
|
# Include everything needed to run rake, tests, features, etc.
|
13
13
|
group :development do
|
14
|
-
gem "shoulda"
|
15
|
-
gem "
|
16
|
-
gem "
|
17
|
-
gem "
|
18
|
-
gem "simplecov", ">= 0"
|
14
|
+
gem "shoulda"
|
15
|
+
gem "bundler"
|
16
|
+
gem "juwelier"
|
17
|
+
gem "simplecov"
|
19
18
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,86 +1,103 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (
|
5
|
-
|
6
|
-
|
7
|
-
minitest (
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
builder (3.2.
|
4
|
+
activesupport (7.0.2.2)
|
5
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
+
i18n (>= 1.6, < 2)
|
7
|
+
minitest (>= 5.1)
|
8
|
+
tzinfo (~> 2.0)
|
9
|
+
addressable (2.8.0)
|
10
|
+
public_suffix (>= 2.0.2, < 5.0)
|
11
|
+
builder (3.2.4)
|
12
|
+
concurrent-ruby (1.1.9)
|
12
13
|
descendants_tracker (0.0.4)
|
13
14
|
thread_safe (~> 0.3, >= 0.3.1)
|
14
|
-
docile (1.
|
15
|
-
faraday (0.
|
15
|
+
docile (1.3.2)
|
16
|
+
faraday (0.15.4)
|
16
17
|
multipart-post (>= 1.2, < 3)
|
17
|
-
git (1.
|
18
|
-
github_api (0.
|
19
|
-
addressable (~> 2.
|
18
|
+
git (1.5.0)
|
19
|
+
github_api (0.18.2)
|
20
|
+
addressable (~> 2.4)
|
20
21
|
descendants_tracker (~> 0.0.4)
|
21
|
-
faraday (~> 0.8
|
22
|
-
hashie (>= 3.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
faraday (~> 0.8)
|
23
|
+
hashie (~> 3.5, >= 3.5.2)
|
24
|
+
oauth2 (~> 1.0)
|
25
|
+
hashie (3.6.0)
|
26
|
+
highline (2.0.2)
|
27
|
+
i18n (1.10.0)
|
28
|
+
concurrent-ruby (~> 1.0)
|
29
|
+
json (2.5.1)
|
30
|
+
juwelier (2.4.9)
|
30
31
|
builder
|
31
|
-
bundler
|
32
|
-
git
|
32
|
+
bundler
|
33
|
+
git
|
33
34
|
github_api
|
34
|
-
highline
|
35
|
-
|
35
|
+
highline
|
36
|
+
kamelcase (~> 0)
|
37
|
+
nokogiri
|
38
|
+
psych
|
36
39
|
rake
|
37
40
|
rdoc
|
38
|
-
|
39
|
-
jwt (
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
41
|
+
semver2
|
42
|
+
jwt (2.2.1)
|
43
|
+
kamelcase (0.0.2)
|
44
|
+
semver2 (~> 3)
|
45
|
+
middleware (0.1.0)
|
46
|
+
minitest (5.15.0)
|
47
|
+
multi_json (1.15.0)
|
48
|
+
multi_xml (0.6.0)
|
49
|
+
multipart-post (2.1.1)
|
50
|
+
nokogiri (1.13.3-x86_64-linux)
|
51
|
+
racc (~> 1.4)
|
52
|
+
oauth2 (1.4.1)
|
53
|
+
faraday (>= 0.8, < 0.16.0)
|
54
|
+
jwt (>= 1.0, < 3.0)
|
50
55
|
multi_json (~> 1.3)
|
51
56
|
multi_xml (~> 0.5)
|
52
|
-
rack (
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
rack (>= 1.2, < 3)
|
58
|
+
protobuf (3.10.5)
|
59
|
+
activesupport (>= 3.2)
|
60
|
+
middleware
|
61
|
+
thor
|
62
|
+
thread_safe
|
63
|
+
psych (3.3.2)
|
64
|
+
public_suffix (4.0.6)
|
65
|
+
racc (1.6.0)
|
66
|
+
rack (2.2.3)
|
67
|
+
rake (13.0.6)
|
68
|
+
rdoc (6.3.3)
|
69
|
+
semver2 (3.4.2)
|
70
|
+
shoulda (3.6.0)
|
59
71
|
shoulda-context (~> 1.0, >= 1.0.1)
|
60
|
-
shoulda-matchers (
|
61
|
-
shoulda-context (1.2.
|
62
|
-
shoulda-matchers (
|
63
|
-
activesupport (>=
|
64
|
-
simplecov (0.
|
65
|
-
docile (~> 1.1
|
66
|
-
json (
|
72
|
+
shoulda-matchers (~> 3.0)
|
73
|
+
shoulda-context (1.2.2)
|
74
|
+
shoulda-matchers (3.1.3)
|
75
|
+
activesupport (>= 4.0.0)
|
76
|
+
simplecov (0.17.0)
|
77
|
+
docile (~> 1.1)
|
78
|
+
json (>= 1.8, < 3)
|
67
79
|
simplecov-html (~> 0.10.0)
|
68
|
-
simplecov-html (0.10.
|
69
|
-
terminal-table (
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
80
|
+
simplecov-html (0.10.2)
|
81
|
+
terminal-table (3.0.2)
|
82
|
+
unicode-display_width (>= 1.1.1, < 3)
|
83
|
+
thor (1.2.1)
|
84
|
+
thread_safe (0.3.6)
|
85
|
+
trisulrp (3.2.32)
|
86
|
+
protobuf
|
87
|
+
tzinfo (2.0.4)
|
88
|
+
concurrent-ruby (~> 1.0)
|
89
|
+
unicode-display_width (2.1.0)
|
75
90
|
|
76
91
|
PLATFORMS
|
77
|
-
|
92
|
+
x86_64-linux
|
78
93
|
|
79
94
|
DEPENDENCIES
|
80
|
-
bundler
|
81
|
-
|
82
|
-
rdoc (~> 3.12)
|
95
|
+
bundler
|
96
|
+
juwelier
|
83
97
|
shoulda
|
84
98
|
simplecov
|
85
99
|
terminal-table
|
86
100
|
trisulrp
|
101
|
+
|
102
|
+
BUNDLED WITH
|
103
|
+
2.3.7
|
data/Rakefile
CHANGED
@@ -11,8 +11,8 @@ rescue Bundler::BundlerError => e
|
|
11
11
|
end
|
12
12
|
require 'rake'
|
13
13
|
|
14
|
-
require '
|
15
|
-
|
14
|
+
require 'juwelier'
|
15
|
+
Juwelier::Tasks.new do |gem|
|
16
16
|
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
17
|
gem.name = "itrp"
|
18
18
|
gem.homepage = "http://github.com/vivekrajan/itrp"
|
@@ -23,7 +23,7 @@ Jeweler::Tasks.new do |gem|
|
|
23
23
|
gem.authors = ["vivekrajan"]
|
24
24
|
# dependencies defined in Gemfile
|
25
25
|
end
|
26
|
-
|
26
|
+
Juwelier::RubygemsDotOrgTasks.new
|
27
27
|
|
28
28
|
require 'rake/testtask'
|
29
29
|
Rake::TestTask.new(:test) do |test|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/itrp.gemspec
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# Generated by juwelier
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: itrp 0.1.5 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "itrp".freeze
|
9
|
+
s.version = "0.1.5"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["vivekrajan".freeze]
|
14
|
+
s.date = "2022-06-02"
|
15
|
+
s.description = "iTRP is an extensible CLI app with tab completion for Network Security and Traffic Monitoring (NSM)".freeze
|
16
|
+
s.email = "vivek@unleashnetworks.com".freeze
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"itrp.gemspec",
|
30
|
+
"lib/cmd_base.rb",
|
31
|
+
"lib/cmd_root.rb",
|
32
|
+
"lib/handlers/agg_flow.rb",
|
33
|
+
"lib/handlers/alert.rb",
|
34
|
+
"lib/handlers/counter.rb",
|
35
|
+
"lib/handlers/delete_alerts.rb",
|
36
|
+
"lib/handlers/edges.rb",
|
37
|
+
"lib/handlers/flow.rb",
|
38
|
+
"lib/handlers/fts.rb",
|
39
|
+
"lib/handlers/getlabel.rb",
|
40
|
+
"lib/handlers/grep.rb",
|
41
|
+
"lib/handlers/help.rb",
|
42
|
+
"lib/handlers/keyspace.rb",
|
43
|
+
"lib/handlers/list.rb",
|
44
|
+
"lib/handlers/list_counters.rb",
|
45
|
+
"lib/handlers/meters.rb",
|
46
|
+
"lib/handlers/metric_summ.rb",
|
47
|
+
"lib/handlers/options.rb",
|
48
|
+
"lib/handlers/pcap.rb",
|
49
|
+
"lib/handlers/probe.rb",
|
50
|
+
"lib/handlers/query_alerts.rb",
|
51
|
+
"lib/handlers/query_flow.rb",
|
52
|
+
"lib/handlers/query_fts.rb",
|
53
|
+
"lib/handlers/query_resource.rb",
|
54
|
+
"lib/handlers/resource.rb",
|
55
|
+
"lib/handlers/searchkey.rb",
|
56
|
+
"lib/handlers/set.rb",
|
57
|
+
"lib/handlers/setlabel.rb",
|
58
|
+
"lib/handlers/timeslices.rb",
|
59
|
+
"lib/handlers/toppers.rb",
|
60
|
+
"lib/handlers/toptrend.rb",
|
61
|
+
"lib/handlers/trackers.rb",
|
62
|
+
"lib/handlers/traffic.rb",
|
63
|
+
"lib/handlers/volume.rb",
|
64
|
+
"lib/itrp.rb",
|
65
|
+
"test/helper.rb",
|
66
|
+
"test/test_itrp.rb"
|
67
|
+
]
|
68
|
+
s.homepage = "http://github.com/vivekrajan/itrp".freeze
|
69
|
+
s.licenses = ["MIT".freeze]
|
70
|
+
s.rubygems_version = "3.2.32".freeze
|
71
|
+
s.summary = "iTRP - Command Line Interface to Trisul Network Analytics".freeze
|
72
|
+
|
73
|
+
if s.respond_to? :specification_version then
|
74
|
+
s.specification_version = 4
|
75
|
+
end
|
76
|
+
|
77
|
+
if s.respond_to? :add_runtime_dependency then
|
78
|
+
s.add_runtime_dependency(%q<trisulrp>.freeze, [">= 0"])
|
79
|
+
s.add_runtime_dependency(%q<terminal-table>.freeze, [">= 0"])
|
80
|
+
s.add_development_dependency(%q<shoulda>.freeze, [">= 0"])
|
81
|
+
s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
|
82
|
+
s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
|
83
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
84
|
+
else
|
85
|
+
s.add_dependency(%q<trisulrp>.freeze, [">= 0"])
|
86
|
+
s.add_dependency(%q<terminal-table>.freeze, [">= 0"])
|
87
|
+
s.add_dependency(%q<shoulda>.freeze, [">= 0"])
|
88
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
89
|
+
s.add_dependency(%q<juwelier>.freeze, [">= 0"])
|
90
|
+
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
data/lib/cmd_base.rb
CHANGED
data/lib/cmd_root.rb
CHANGED
@@ -11,9 +11,10 @@ class Cmd_root < Cmd
|
|
11
11
|
|
12
12
|
|
13
13
|
def enter(cmdline)
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
end
|
15
|
+
|
16
|
+
def notfound(cmdline)
|
17
|
+
print("#{cmdline} : not found\n");
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module ITRP
|
2
|
+
|
3
|
+
# usage agg proto=11 group_by:nf_routerid,nf_ifindex_out,nf_ifindex_in
|
4
|
+
|
5
|
+
class Cmd_agg_flow < Cmd
|
6
|
+
def initialize (e)
|
7
|
+
super(e)
|
8
|
+
@enabled_in_state = :flow
|
9
|
+
@attach_cmd = ''
|
10
|
+
@trigger = 'agg'
|
11
|
+
end
|
12
|
+
|
13
|
+
def completions(patt)
|
14
|
+
TRP::AggregateSessionsRequest
|
15
|
+
.fields
|
16
|
+
.collect { |a| a.name.to_s }
|
17
|
+
.grep( /^#{Regexp.escape(patt)}/i)
|
18
|
+
end
|
19
|
+
|
20
|
+
def enter(patt)
|
21
|
+
|
22
|
+
terms = patt.scan( /(\w+)\s*=\s*([\w\-_\.\:,]+)+/ )
|
23
|
+
qparams = terms.inject({}) { |acc,t| acc.store( t[0].to_sym, t[1]);acc}
|
24
|
+
|
25
|
+
print("Query Params=#{qparams}\n")
|
26
|
+
|
27
|
+
group_by = patt.scan( /group_by:(\S+)/ )
|
28
|
+
group_by.flatten!
|
29
|
+
if not group_by.empty? then
|
30
|
+
group_by = group_by[0]
|
31
|
+
else
|
32
|
+
group_by = ""
|
33
|
+
end
|
34
|
+
|
35
|
+
print("Group By =#{group_by}\n")
|
36
|
+
|
37
|
+
|
38
|
+
# meter names
|
39
|
+
req =mk_request(TRP::Message::Command::AGGREGATE_SESSIONS_REQUEST ,
|
40
|
+
{
|
41
|
+
:session_group => appstate(:cgguid),
|
42
|
+
:time_interval => appstate(:time_interval),
|
43
|
+
:resolve_keys => true,
|
44
|
+
:group_by_fields => group_by.split(',')
|
45
|
+
}.merge(qparams))
|
46
|
+
|
47
|
+
|
48
|
+
get_response_zmq(@appenv.zmq_endpt,req) do |resp|
|
49
|
+
|
50
|
+
%w(dest_port nf_routerid nf_ifindex_in nf_ifindex_out ).each do |fieldname|
|
51
|
+
|
52
|
+
rows = []
|
53
|
+
rows << resp.send(fieldname).collect do |item|
|
54
|
+
[item.key.key, item.key.readable, item.key.label, item.count, item.metric]
|
55
|
+
end
|
56
|
+
|
57
|
+
table = Terminal::Table.new(
|
58
|
+
:headings => [fieldname, 'Readable', 'Label', 'Flows', 'Metric' ],
|
59
|
+
:rows => rows.first )
|
60
|
+
puts(table)
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
# tags
|
65
|
+
resp.tag_group.each do |tg|
|
66
|
+
|
67
|
+
puts(tg.group_name)
|
68
|
+
|
69
|
+
rows = []
|
70
|
+
rows << tg.tag_metrics.collect do |item|
|
71
|
+
[item.key.key, item.count, item.metric]
|
72
|
+
end
|
73
|
+
|
74
|
+
table = Terminal::Table.new(
|
75
|
+
:headings => ['Tag', 'Flows', 'Metric' ],
|
76
|
+
:rows => rows.first )
|
77
|
+
puts(table)
|
78
|
+
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
|
data/lib/handlers/alert.rb
CHANGED
@@ -10,16 +10,21 @@ class Cmd_alert < Cmd
|
|
10
10
|
|
11
11
|
|
12
12
|
def completions(patt)
|
13
|
-
[ "
|
14
|
-
"Blacklist
|
15
|
-
"
|
16
|
-
"
|
17
|
-
"
|
13
|
+
[ "IDS {9AFD8C08-07EB-47E0-BF05-28B4A7AE8DC9}",
|
14
|
+
"Blacklist {5E97C3A3-41DB-4E34-92C3-87C904FAB83E}",
|
15
|
+
"TCA {03AC6B72-FDB7-44C0-9B8C-7A1975C1C5BA}",
|
16
|
+
"SYS {18CE5961-38FF-4AEA-BAF8-2019F3A09063}",
|
17
|
+
"TB {0E7E367D-4455-4680-BC73-699D81B7CBE0}"
|
18
18
|
].grep( /#{Regexp.escape(patt)}/i)
|
19
19
|
end
|
20
20
|
|
21
21
|
def enter(s)
|
22
|
-
|
22
|
+
patt = s.scan(/set\s+alert\s+(\S+)\s+({.*}$)/).flatten
|
23
|
+
print("\nContext set to alert group [#{patt[0]}] [#{patt[1]}]\n\n")
|
24
|
+
@appenv.prompt = "iTRP A:(#{patt[0]})> "
|
25
|
+
@appenv.context_data[:cgguid] = patt[1]
|
26
|
+
@appenv.context_data[:cgname] = patt[0]
|
27
|
+
@appenv.context = :alerts
|
23
28
|
|
24
29
|
end
|
25
30
|
end
|
@@ -19,7 +19,7 @@ class Cmd_delete_alerts < Cmd
|
|
19
19
|
|
20
20
|
def enter(cmdline)
|
21
21
|
|
22
|
-
terms =
|
22
|
+
terms = cmdline.scan( /(\w+)\s*=\s*([\w\-=\%_\.\:,]+)+/ )
|
23
23
|
qparams = terms.inject({}) { |acc,t| acc.store( t[0].to_sym, t[1]);acc}
|
24
24
|
|
25
25
|
p qparams
|
@@ -27,7 +27,7 @@ class Cmd_delete_alerts < Cmd
|
|
27
27
|
# meter names
|
28
28
|
req =mk_request(TRP::Message::Command::DELETE_ALERTS_REQUEST,
|
29
29
|
{ :alert_group => appstate(:cgguid),
|
30
|
-
:time_interval =>
|
30
|
+
:time_interval => appstate(:time_interval)
|
31
31
|
}.merge(qparams))
|
32
32
|
|
33
33
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module ITRP
|
2
|
+
|
3
|
+
class Cmd_edges < Cmd
|
4
|
+
def initialize (e)
|
5
|
+
super(e)
|
6
|
+
@enabled_in_state = :counter
|
7
|
+
@attach_cmd = ''
|
8
|
+
@trigger = 'edges'
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
def enter(cmdline)
|
14
|
+
|
15
|
+
patt = cmdline.scan(/edges\s+(.*)/).flatten
|
16
|
+
|
17
|
+
p patt
|
18
|
+
|
19
|
+
use_key = patt.empty? ? appstate(:cgkey) : patt[0]
|
20
|
+
|
21
|
+
# meter names
|
22
|
+
req =mk_request(TRP::Message::Command::GRAPH_REQUEST,
|
23
|
+
:time_interval => appstate( :time_interval),
|
24
|
+
:subject_group => @appenv.context_data[:cgguid],
|
25
|
+
:subject_key => use_key )
|
26
|
+
|
27
|
+
rows = []
|
28
|
+
|
29
|
+
print "Request sent at #{Time.now}\n"
|
30
|
+
|
31
|
+
TrisulRP::Protocol.get_response_zmq(@appenv.zmq_endpt,req) do |resp|
|
32
|
+
|
33
|
+
print "===== RESPONSE =====\n"
|
34
|
+
print "\tSUBJECT GUID = #{resp.subject_group}\n"
|
35
|
+
print "\tSUBJECT KEY = #{resp.subject_key.key}\n"
|
36
|
+
|
37
|
+
resp.graphs.each do |g|
|
38
|
+
|
39
|
+
print "===== GRAPH =====\n"
|
40
|
+
print "\t\tTIME FROM = #{Time.at(g.time_interval.from.tv_sec)}\n"
|
41
|
+
print "\t\tTIME TO = #{Time.at(g.time_interval.to.tv_sec)}\n"
|
42
|
+
|
43
|
+
g.vertex_groups.each do |vg|
|
44
|
+
|
45
|
+
vertices_labels = vg.vertex_keys.collect { |k| k.label }.join(',')
|
46
|
+
|
47
|
+
print "\t\t\t---------------------------------------------\n"
|
48
|
+
print "\t\t\tVERTEX GROUP = #{vg.vertex_group}\n"
|
49
|
+
print "\t\t\tVERTICES LABELS = #{vertices_labels}\n"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module ITRP
|
2
|
+
|
3
|
+
class Cmd_grep < Cmd
|
4
|
+
def initialize (e)
|
5
|
+
super(e)
|
6
|
+
@enabled_in_state = :any
|
7
|
+
@attach_cmd = ''
|
8
|
+
@trigger = 'grep'
|
9
|
+
end
|
10
|
+
|
11
|
+
def enter(cmdline)
|
12
|
+
|
13
|
+
patt = cmdline.scan(/grep\s+(\w+)/).flatten.first
|
14
|
+
|
15
|
+
req =TrisulRP::Protocol.mk_request(TRP::Message::Command::GREP_REQUEST,
|
16
|
+
:time_interval => appstate(:time_interval),
|
17
|
+
:pattern_text => patt )
|
18
|
+
|
19
|
+
rows = []
|
20
|
+
TrisulRP::Protocol.get_response_zmq(@appenv.zmq_endpt,req) do |resp|
|
21
|
+
sz = resp.sessions.size
|
22
|
+
(0..sz-1).each do |i|
|
23
|
+
s = resp.sessions[i]
|
24
|
+
rows << [ s.session_key, s.time_interval.from.tv_sec, s.time_interval.to.tv_sec, s.key1A.label, s.key1Z.label, resp.hints[i]]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
table = Terminal::Table.new(
|
29
|
+
:headings => %w(key tmFrom tmTo IPA IPZ hints ),
|
30
|
+
:rows => rows)
|
31
|
+
puts(table)
|
32
|
+
|
33
|
+
if cmdline =~ /savefilter/
|
34
|
+
|
35
|
+
|
36
|
+
fkeys = rows.collect{ |r| r[0] }.join(",")
|
37
|
+
@appenv.context_data[:filter] = '{99A78737-4B41-4387-8F31-8077DB917336}=' + fkeys
|
38
|
+
puts "Filter string saved as @appenv.context_data[:filter] " + @appenv.context_data[:filter]
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module ITRP
|
2
|
+
|
3
|
+
class Cmd_keyspace < Cmd
|
4
|
+
def initialize (e)
|
5
|
+
super(e)
|
6
|
+
@enabled_in_state = :counter
|
7
|
+
@attach_cmd = ''
|
8
|
+
@trigger = 'keyspace'
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
def enter(cmdline)
|
14
|
+
|
15
|
+
patt = cmdline.scan(/keyspace\s+(\S+)\s*(\S+)/).flatten
|
16
|
+
|
17
|
+
p "#{patt[0]} to #{patt[1]}"
|
18
|
+
|
19
|
+
use_spaces = [ TRP::KeySpaceRequest::KeySpace.new(
|
20
|
+
:from_key => TRP::KeyT.new( :label => patt[0]),
|
21
|
+
:to_key => TRP::KeyT.new( :label => patt[1]) ) ]
|
22
|
+
|
23
|
+
req =TrisulRP::Protocol.mk_request(TRP::Message::Command::KEYSPACE_REQUEST,
|
24
|
+
:counter_group => @appenv.context_data[:cgguid],
|
25
|
+
:time_interval => appstate( :time_interval),
|
26
|
+
:totals_only => true )
|
27
|
+
|
28
|
+
rows = []
|
29
|
+
|
30
|
+
|
31
|
+
TrisulRP::Protocol.get_response_zmq(@appenv.zmq_endpt,req) do |resp|
|
32
|
+
|
33
|
+
resp.hits.each_with_index do |kt,i |
|
34
|
+
rows << [ i, kt.key, kt.label, kt.readable ]
|
35
|
+
end
|
36
|
+
|
37
|
+
p "TOTAL HITS = #{resp.total_hits}"
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
table = Terminal::Table.new(
|
43
|
+
:headings => %w(# Key Label Readable ),
|
44
|
+
:rows => rows)
|
45
|
+
puts(table)
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
@@ -10,19 +10,28 @@ class Cmd_cglist < Cmd
|
|
10
10
|
|
11
11
|
|
12
12
|
def enter(cmdline)
|
13
|
-
req =mk_request(TRP::Message::Command::COUNTER_GROUP_INFO_REQUEST)
|
13
|
+
req =mk_request(TRP::Message::Command::COUNTER_GROUP_INFO_REQUEST, {:get_meter_info=>true} )
|
14
14
|
|
15
15
|
rows = []
|
16
16
|
get_response_zmq(@appenv.zmq_endpt,req) do |resp|
|
17
17
|
resp.group_details.each do |group_detail|
|
18
|
+
cstr=""
|
19
|
+
if group_detail.crosskey
|
20
|
+
cstr = [group_detail.crosskey.parentguid,
|
21
|
+
group_detail.crosskey.crosskeyguid_1,
|
22
|
+
group_detail.crosskey.crosskeyguid_2].join(",")
|
23
|
+
|
24
|
+
end
|
18
25
|
rows << [ group_detail.name,
|
19
26
|
group_detail.guid,
|
20
|
-
group_detail.bucket_size.to_i/1000
|
27
|
+
group_detail.bucket_size.to_i/1000,
|
28
|
+
group_detail.meters.size,
|
29
|
+
cstr
|
21
30
|
]
|
22
31
|
end
|
23
32
|
end
|
24
33
|
|
25
|
-
table = Terminal::Table.new :headings => %w(name guid bs), :rows => rows
|
34
|
+
table = Terminal::Table.new :headings => %w(name guid bs num_meters), :rows => rows
|
26
35
|
puts(table)
|
27
36
|
end
|
28
37
|
|