lita-trisul 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d01c8f697d872e9971b93125dc2a96f3d86ea50d
4
- data.tar.gz: 93c5b3725cf828efebc55180f4f85488774b8223
3
+ metadata.gz: 18a8a6df5b0323586fb9930984f786432b5ab34e
4
+ data.tar.gz: e6e0d1eea27ec02149cd84bd85fb86d9fd5522a6
5
5
  SHA512:
6
- metadata.gz: 4e8e8949a3ea6ee4043ffc16fed6d1a48fe6635d9906ed2fbaa68fcd0564a752743c3f2fb3edcfb7c7a5e8f2b676775c3b7bbf90a1cb3fe5be490487f55bc716
7
- data.tar.gz: 82052515403b0736182e0a3f08ad4ce8cbdfc51739d074a6be358f2132e181e6c3128fbe2690f084a188a224f024573589f3d31057bf250bbf07d01eaf53d7ce
6
+ metadata.gz: 497c5e38cb9a6f997f2cd7b2c9c885d13e0c6ad2f55e1f92ee10f3a78058c7975c9cfc33cdad389273fdb8a95b2edab8d10b6cb0e4f39f83a88e2da75457d1bf
7
+ data.tar.gz: 09c0e0aa3a325d92ddd8ce994ae7b440cc67e0ab5aa4bdbedc5e9fdf92eb5bc0fd4b12004bc4a9afcfaec4e248ed7107f0a5e4a16fd2a3ad93b1aef1c4e0331a
data/README.md CHANGED
@@ -17,6 +17,18 @@ gem "lita-trisul"
17
17
 
18
18
  ## Configuration
19
19
 
20
+ Add the following config parameters
21
+
22
+ ````
23
+
24
+ # where the Trisul TRP server is
25
+ config.handlers.trisul.trp_server_endpoint="tcp://192.168.2.8:12006"
26
+
27
+ # external IP of this host for serving images
28
+ config.handlers.trisul.local_http_server="http://192.168.2.11:3000"
29
+
30
+ ````
31
+
20
32
  TODO: Describe any configuration attributes the plugin exposes.
21
33
 
22
34
  ## Usage
@@ -36,9 +48,9 @@ TODO: Describe the plugin's features and how to use them.
36
48
  2. Install ruby
37
49
  - Ubuntu - `sudo apt-get install ruby ruby-dev`
38
50
  3. Install Ruby binding for ZMQ - we use this to connect to Trisul domain
39
- 1. Ubuntu - `sudo apt-get install ruby-ffi-rzmq`
51
+ - Ubuntu - `sudo apt-get install ruby-ffi-rzmq`
40
52
  4. Install other dependencies
41
- 1. Ubuntu - `sudo apt-get install build-essential libssl-dev redis-server librsvg2-bin`
53
+ - Ubuntu - `sudo apt-get install build-essential libssl-dev redis-server librsvg2-bin libzmq3-dev`
42
54
  5. Install bundler and all the gems
43
55
  - Ubuntu - `sudo gem install bundler` then `bundle install`
44
56
 
@@ -47,7 +59,6 @@ TODO: Describe the plugin's features and how to use them.
47
59
  ### Creating your Chat bot
48
60
 
49
61
 
50
-
51
62
  1. Create a new LITA instance
52
63
  - `lita new mybotwalle`
53
64
  1. Configure your BOT for HIPCHAT
@@ -55,10 +66,3 @@ TODO: Describe the plugin's features and how to use them.
55
66
 
56
67
 
57
68
 
58
- # There seems to be a bug with gerbil charts
59
- # To provide a temporary fix against the bug, copy the gerbil.js and brushmetal.css files to the directory to the directory from which the bot is started and then start the bot
60
- # cp /var/lib/gems/2.3.0/gems/lita-trisul-0.2.0/lib/lita/handlers/gerbil.js .
61
- # cp /var/lib/gems/2.3.0/gems/lita-trisul-0.2.0/lib/lita/handlers/brushmetal.js .
62
-
63
-
64
-
@@ -11,5 +11,3 @@ Lita::Handlers::Trisul.template_root File.expand_path(
11
11
  __FILE__
12
12
  )
13
13
  require "lita/handlers/lita-hello"
14
- require "lita/handlers/lita-gerbile"
15
- require 'trisulrp'
@@ -5,9 +5,15 @@ require 'base64'
5
5
  module Lita
6
6
  module Handlers
7
7
  class Hello < Handler
8
+
8
9
  $id=rand(100)
9
10
  extend Lita::Handler::HTTPRouter
10
11
  http.get "/kkr:id.png", :example
12
+
13
+ config :query_endpoint
14
+ config :lita_public_ip
15
+
16
+
11
17
  def example(request,response2)
12
18
  `ruby /home/lita/test_lines.rb`
13
19
  `rsvg-convert /tmp/sq_linechart.svg -o /home/lita/robot/test.png`
@@ -37,7 +43,7 @@ module Lita
37
43
  tint.from= TRP::Timestamp.new()
38
44
  tint.from.tv_sec = tint.to.tv_sec - 3600
39
45
  req = TrisulRP::Protocol.mk_request(TRP::Message::Command::COUNTER_GROUP_TOPPER_REQUEST,{:counter_group=>response.matches[0][0],:meter=>0,:maxitems=>2,time_interval:tint})
40
- TrisulRP::Protocol.get_response_zmq(conn,req) do |resp|
46
+ TrisulRP::Protocol.get_response_zmq(config.query_endpoint,req) do |resp|
41
47
  resp.keys.each do |key|
42
48
  response.reply("#{key.label}=#{key.metric*300}")
43
49
  end
@@ -48,7 +54,7 @@ module Lita
48
54
 
49
55
 
50
56
  def imagery(response)
51
- response.reply("http://139.59.66.54:9000/kkr#{$id}.png")
57
+ response.reply("http://#{config.lita_public_ip}:9000/kkr#{$id}.png")
52
58
  $id=rand(100)
53
59
 
54
60
  end
@@ -1,9 +1,69 @@
1
+ require 'json'
2
+ require 'lita'
3
+ require 'open-uri'
4
+ require 'base64'
5
+ require 'gerbilcharts'
6
+
1
7
  module Lita
2
8
  module Handlers
3
9
  class Trisul < Handler
4
- # insert handler code here
10
+
11
+ $id=rand(100)
12
+ extend Lita::Handler::HTTPRouter
13
+
14
+ config :trp_server_endpoint
15
+ config :local_http_server
16
+
17
+ http.get "/ers:id.png", :example
18
+
19
+ def example(request,response2)
20
+ `rsvg-convert /tmp/chart.svg -o /tmp/chart.png`
21
+ file=File.read("/tmp/chart.png")
22
+ response2["Content-Type"] = "image/png"
23
+ response2.write(file)
24
+ response2.finish
25
+ end
26
+
27
+
28
+ def chart_generate(data)
29
+ mod1 = GerbilCharts::Models::TimeSeriesGraphModel.new("External Gateway")
30
+ mod1.add_tuples data
31
+ modgroup = GerbilCharts::Models::GraphModelGroup.new("Hosts")
32
+ modgroup.add(mod1)
33
+ mychart = GerbilCharts::Charts::AreaChart.new( :width => 750, :height => 250, :squarize => true,
34
+ :auto_tooltips => false,:style => 'inline:brushmetal.css' )
35
+ mychart.setmodelgroup(modgroup)
36
+ mychart.render('/tmp/chart.svg')
37
+ end
38
+
39
+
40
+ route(/^Total\straffic\s(.*)/i, :trpchart, command: false, help: { "trpchart" => "To chart trp" })
41
+
42
+
43
+ def trpchart(response)
44
+ if response.matches[0]=="hey" and ! response.matches[0].is_a?Array
45
+ response.reply("Please enter hey <counter_group_id>")
46
+ end
47
+ tint = TRP::TimeInterval.new()
48
+ tint.to= TRP::Timestamp.new({:tv_sec=>Time.now.tv_sec})
49
+ tint.from= TRP::Timestamp.new()
50
+ tint.from.tv_sec = tint.to.tv_sec - 3600
51
+ keyt = TRP::KeyT.new({:key=>"TOTALBW"})
52
+ req = TrisulRP::Protocol.mk_request(TRP::Message::Command::COUNTER_ITEM_REQUEST,{:counter_group=>response.matches[0][0].strip,:key=>keyt,time_interval:tint})
53
+ data = []
54
+ TrisulRP::Protocol.get_response_zmq(config.trisul.trp_server_endpoint,req) do |resp|
55
+ resp.stats.each do |stat|
56
+ data << [ stat.ts_tv_sec,stat.values[0]*8]
57
+ end#stats
58
+ end#trp
59
+ chart_generate(data)
60
+ response.reply("http://#{config.trisul.local_http_server}/ers#{$id}.png")
61
+ $id=rand(100)
62
+ end#def
5
63
 
6
64
  Lita.register_handler(self)
7
- end
8
- end
9
- end
65
+
66
+ end #CLASS
67
+ end #module handlers
68
+ end #modulelita
69
+
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-trisul"
3
- spec.version = "0.2.3"
3
+ spec.version = "0.2.4"
4
4
  spec.authors = ["Krishna"]
5
5
  spec.email = ["info@unleashnetworks.com"]
6
6
  spec.description = "Lita chatops to Trisul Network Analytics"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-trisul
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krishna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-27 00:00:00.000000000 Z
11
+ date: 2017-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -194,7 +194,6 @@ files:
194
194
  - lib/lita/handlers/gerbil.js
195
195
  - lib/lita/handlers/lita-gerbile.rb
196
196
  - lib/lita/handlers/lita-hello.rb
197
- - lib/lita/handlers/lita-trpgerbil.rb
198
197
  - lib/lita/handlers/trisul.rb
199
198
  - lita-trisul.gemspec
200
199
  - locales/en.yml
@@ -1,72 +0,0 @@
1
- require 'json'
2
- require 'lita'
3
- require 'open-uri'
4
- require 'base64'
5
- require 'gerbilcharts'
6
- module Lita
7
- module Handlers
8
- class Gerbile < Handler
9
- config :config.trisul.host, type: String, required: true
10
- config :config.public.host, type: String, required: true
11
- $id=rand(100)
12
- extend Lita::Handler::HTTPRouter
13
- http.get "/kkr:id.png", :example
14
- def example(request,response)
15
- chart_generate()
16
- `rsvg-convert /tmp/chart.svg -o /tmp/chart.png`
17
- file=File.read("/tmp/chart.png")
18
- response2["Content-Type"] = "image/png"
19
- response2.write(file)
20
- response2.finish
21
- end
22
-
23
-
24
- def chart_generate(test_vector_tm1)
25
- test_vector_tm1 = []
26
- tbeg = Time.local( 1978, "jun", 5, 9, 10, 0, 0)
27
- sbeg = tbeg
28
- sec_inc = 50
29
- for i in (0..20)
30
- test_vector_tm1 << [sbeg + i*sec_inc, i*sec_inc*250*rand() ]
31
- end
32
- mod1 = GerbilCharts::Models::TimeSeriesGraphModel.new("External Gateway")
33
- mod1.add_tuples test_vector_tm1
34
- modgroup = GerbilCharts::Models::GraphModelGroup.new("Hosts")
35
- modgroup.add(mod1)
36
- mychart = GerbilCharts::Charts::LineChart.new( :width => 750, :height => 250, :squarize => true,:javascripts => ['inline:gerbil.js' ],
37
- :auto_tooltips => false, :style => 'inline:brushmetal.css' )
38
- mychart.setmodelgroup(modgroup)
39
- mychart.render('/tmp/chart.svg')
40
- end
41
-
42
-
43
- route(/^chart me/, :trpchart, command: false, help: { "trchart" => "To chart trp" })
44
-
45
-
46
- def trpchart(response)
47
- if response.matches[0]=="hey" and ! response.matches[0].is_a?Array
48
- response.reply("Please enter hey <counter_group_id>")
49
- end
50
- conn = "tcp://$config.trisul.host"
51
- tint = TRP::TimeInterval.new()
52
- tint.to= TRP::Timestamp.new({:tv_sec=>Time.now.tv_sec})
53
- tint.from= TRP::Timestamp.new()
54
- tint.from.tv_sec = tint.to.tv_sec - 3600
55
- req = TrisulRP::Protocol.mk_request(TRP::Message::Command::COUNTER_GROUP_TOPPER_REQUEST,{:counter_group=>response.matches[0][0],:meter=>0,:maxitems=>2,time_interval:tint})
56
- data = []
57
- TrisulRP::Protocol.get_response_zmq(conn,req) do |resp|
58
- resp.keys.each do |key|
59
- #response.reply("#{key.label}=#{key.metric*300}")
60
- data << [#{key.label},#{key.metric}]
61
- end
62
- end
63
- chart_generate(data)
64
- response.reply("http://$config.public.host/kkr#{$id}.png")
65
- $id=rand(100)
66
- end#def
67
-
68
- end#CLASS
69
- Lita.register_handler(Gerbile)
70
- end#module handlers
71
- end#modulelita
72
-