fluent-plugin-telemetry-iosxr 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +6 -0
- data/README.md +143 -0
- data/Rakefile +2 -0
- data/fluent-plugin-telemetry-iosxr.gemspec +36 -0
- data/lib/fluent/plugin/in_telemetry_iosxr.rb +89 -0
- metadata +92 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: b500be3a83d7647d27cc43f0f7a497d7a2b31bcf
|
|
4
|
+
data.tar.gz: 63af8ac269ad362e75206ef9efbb79416d2b4bd4
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9864842367b007e42cb7d99bb3cfd3a5b8093adfff2c79835a5505b1a5df45e09787ec78ad5d38f4eec7af4ce50a7d65a23fb14501ea3188dd0f14f9a7abd307
|
|
7
|
+
data.tar.gz: 98262672e4c2343c95a84b36a7dea22c931a0c59f35e31f056136abd91f4f3ef88481b9c5f335ce9c3fe2f367a8837fff01b2dfbee02d56e984ed071fd02815e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# fluent-plugin-telemetry-iosxr, a plugin for [Fluentd](http://fluentd.org)
|
|
2
|
+
|
|
3
|
+
[Fluentd](http://fluentd.org) input plugin to collect IOS-XR telemetry.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
`fluent-plugin-telemetry-iosxr` supports fluentd-0.14.0 or later.
|
|
8
|
+
|
|
9
|
+
## installation
|
|
10
|
+
|
|
11
|
+
$ fluent-gem install fluent-plugin-telemetry-iosxr
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Configuration Example 1
|
|
16
|
+
|
|
17
|
+
Collect telemetry input and then output to stdout.
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
<source>
|
|
21
|
+
@type telemetry_iosxr
|
|
22
|
+
bind 0.0.0.0
|
|
23
|
+
port 5432
|
|
24
|
+
@label @telemetry
|
|
25
|
+
</source>
|
|
26
|
+
|
|
27
|
+
<label @telemetry>
|
|
28
|
+
<match **>
|
|
29
|
+
@type stdout
|
|
30
|
+
</match>
|
|
31
|
+
</label>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Configuration Example 2
|
|
35
|
+
|
|
36
|
+
Collect telemetry input and then output to InfluxDB with deleting nested input.
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
<source>
|
|
40
|
+
@type telemetry_iosxr
|
|
41
|
+
bind 0.0.0.0
|
|
42
|
+
port 5432
|
|
43
|
+
delete_nested true
|
|
44
|
+
@label @telemetry
|
|
45
|
+
</source>
|
|
46
|
+
|
|
47
|
+
<label @telemetry>
|
|
48
|
+
<match **>
|
|
49
|
+
@type influxdb
|
|
50
|
+
host localhost
|
|
51
|
+
port 8086
|
|
52
|
+
dbname telemetry
|
|
53
|
+
user admin
|
|
54
|
+
password admin
|
|
55
|
+
time_precision s
|
|
56
|
+
auto_tags true
|
|
57
|
+
</match>
|
|
58
|
+
</label>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**bind**
|
|
62
|
+
|
|
63
|
+
IP address on which the plugin will accept Telemetry.
|
|
64
|
+
(Default: '0.0.0.0')
|
|
65
|
+
|
|
66
|
+
**port**
|
|
67
|
+
|
|
68
|
+
TCP port number on which the plugin will accept Telemetry.
|
|
69
|
+
(Default: 5432)
|
|
70
|
+
|
|
71
|
+
**delete_nested**
|
|
72
|
+
|
|
73
|
+
Delete nested input.
|
|
74
|
+
(Default: false)
|
|
75
|
+
|
|
76
|
+
Assume the input is multi-dimensional as below:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
{
|
|
80
|
+
"node-name":"0/RP0/CPU0",
|
|
81
|
+
"total-cpu-one-minute":2,
|
|
82
|
+
"total-cpu-five-minute":2,
|
|
83
|
+
"total-cpu-fifteen-minute":2,
|
|
84
|
+
"process-cpu":[
|
|
85
|
+
{
|
|
86
|
+
"process-name":"init",
|
|
87
|
+
"process-id":1,
|
|
88
|
+
"process-cpu-one-minute":0,
|
|
89
|
+
"process-cpu-five-minute":0,
|
|
90
|
+
"process-cpu-fifteen-minute":0
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"process-name":"bash",
|
|
94
|
+
"process-id":1589,
|
|
95
|
+
"process-cpu-one-minute":0,
|
|
96
|
+
"process-cpu-five-minute":0,
|
|
97
|
+
"process-cpu-fifteen-minute":0
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"process-name":"sh",
|
|
101
|
+
"process-id":1605,
|
|
102
|
+
"process-cpu-one-minute":0,
|
|
103
|
+
"process-cpu-five-minute":0,
|
|
104
|
+
"process-cpu-fifteen-minute":0
|
|
105
|
+
},
|
|
106
|
+
...
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Then the output becomes as below:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
{
|
|
115
|
+
"node-name":"0/RP0/CPU0",
|
|
116
|
+
"total-cpu-one-minute":2,
|
|
117
|
+
"total-cpu-five-minute":2,
|
|
118
|
+
"total-cpu-fifteen-minute":2
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### IOS XR Configuration Example
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
telemetry model-driven
|
|
126
|
+
destination-group destination1
|
|
127
|
+
address-family ipv4 <ip_addr> port <port>
|
|
128
|
+
encoding json
|
|
129
|
+
protocol tcp
|
|
130
|
+
!
|
|
131
|
+
!
|
|
132
|
+
sensor-group sensor1
|
|
133
|
+
sensor-path Cisco-IOS-XR-wdsysmon-fd-oper:system-monitoring/cpu-utilization
|
|
134
|
+
sensor-path Cisco-IOS-XR-nto-misc-oper:memory-summary/nodes/node/summary
|
|
135
|
+
sensor-path Cisco-IOS-XR-infra-statsd-oper:infra-statistics/interfaces/interface/latest/data-rate
|
|
136
|
+
sensor-path Cisco-IOS-XR-infra-statsd-oper:infra-statistics/interfaces/interface/latest/generic-counters
|
|
137
|
+
!
|
|
138
|
+
subscription 1
|
|
139
|
+
sensor-group-id sensor1 sample-interval 1000
|
|
140
|
+
destination-id destination1
|
|
141
|
+
!
|
|
142
|
+
!
|
|
143
|
+
```
|
data/Rakefile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
#require "fluent/plugin/telemetry/iosxr/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "fluent-plugin-telemetry-iosxr"
|
|
8
|
+
spec.version = "0.0.1"
|
|
9
|
+
spec.authors = ["Tetsuhiro Sato"]
|
|
10
|
+
spec.email = ["tetsusat@cisco.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Fluentd input plugin to collect IOS-XR telemetry.}
|
|
13
|
+
spec.description = spec.summary
|
|
14
|
+
spec.homepage = "https://github.com/tetsusat/fluent-plugin-telemetry-iosxr"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
|
+
#if spec.respond_to?(:metadata)
|
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
|
21
|
+
#else
|
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
|
23
|
+
# "public gem pushes."
|
|
24
|
+
#end
|
|
25
|
+
|
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
|
28
|
+
end
|
|
29
|
+
spec.bindir = "exe"
|
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
31
|
+
spec.require_paths = ["lib"]
|
|
32
|
+
|
|
33
|
+
spec.add_dependency "fluentd", "~> 0.14"
|
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
36
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
require 'fluent/input'
|
|
2
|
+
require 'socket'
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
5
|
+
module Fluent
|
|
6
|
+
class TelemetryInput < Input
|
|
7
|
+
Fluent::Plugin.register_input('telemetry_iosxr', self)
|
|
8
|
+
|
|
9
|
+
helpers :server
|
|
10
|
+
|
|
11
|
+
config_param :bind, :string, :default => '0.0.0.0'
|
|
12
|
+
config_param :port, :integer, :default => 5432
|
|
13
|
+
config_param :delete_nested, :bool, :default => false
|
|
14
|
+
|
|
15
|
+
def configure(conf)
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def start
|
|
20
|
+
super
|
|
21
|
+
@hdr_parsed = false
|
|
22
|
+
@buffer = ""
|
|
23
|
+
@hdr_buffer = ""
|
|
24
|
+
server_create(:in_telemetry_server, @port, bind: @bind, proto: :tcp) do |data, sock|
|
|
25
|
+
receive_data(sock.remote_host, data)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
def shutdown
|
|
29
|
+
super
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
protected
|
|
33
|
+
|
|
34
|
+
def receive_data(host, data)
|
|
35
|
+
log.info "receive data ..."
|
|
36
|
+
if @hdr_parsed == false
|
|
37
|
+
# Do I need to consider the case the header is in separate receive data?
|
|
38
|
+
@hdr_buffer << data[0..11]
|
|
39
|
+
@remaining_len = hdr_parse()
|
|
40
|
+
@hdr_buffer = ""
|
|
41
|
+
data = data[12..-1] # remove header
|
|
42
|
+
@hdr_parsed = true
|
|
43
|
+
end
|
|
44
|
+
if data.length <= @remaining_len
|
|
45
|
+
@buffer << data
|
|
46
|
+
@remaining_len -= data.length
|
|
47
|
+
if @remaining_len == 0
|
|
48
|
+
data_parse()
|
|
49
|
+
@buffer = "" # reset
|
|
50
|
+
@hdr_parsed = false
|
|
51
|
+
end
|
|
52
|
+
else # this happens when received data in fluentd tcp server contains multi telemetry messages.
|
|
53
|
+
@buffer << data[0..@remaining_len-1]
|
|
54
|
+
data_parse()
|
|
55
|
+
@buffer = "" # reset
|
|
56
|
+
@hdr_parsed = false
|
|
57
|
+
receive_data(host, data[@remaining_len..-1])
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
def hdr_parse()
|
|
61
|
+
log.info "parse telemetry header ..."
|
|
62
|
+
msg_type = @hdr_buffer[0..1].unpack("n")[0]
|
|
63
|
+
msg_encap = @hdr_buffer[2..3].unpack("n")[0]
|
|
64
|
+
msg_hdr_ver = @hdr_buffer[4..5].unpack("n")[0]
|
|
65
|
+
msg_flag = @hdr_buffer[6..7].unpack("n")[0]
|
|
66
|
+
msg_len = @hdr_buffer[8..11].unpack("N")[0]
|
|
67
|
+
log.info "msg_type=#{msg_type} msg_encap=#{msg_encap} msg_hdr_ver=#{msg_hdr_ver} msg_flag=#{msg_flag} msg_len=#{msg_len}"
|
|
68
|
+
return msg_len
|
|
69
|
+
end
|
|
70
|
+
def data_parse()
|
|
71
|
+
log.info "parse telemetry data ..."
|
|
72
|
+
obj = JSON.parse(@buffer)
|
|
73
|
+
tag = obj['encoding_path']
|
|
74
|
+
es = MultiEventStream.new
|
|
75
|
+
for data in obj['data_json']
|
|
76
|
+
time = data['timestamp'] / 1000
|
|
77
|
+
obj = data['keys'].merge(data['content'])
|
|
78
|
+
record = nil
|
|
79
|
+
if @delete_nested
|
|
80
|
+
record = obj.reject { |k,v| v.is_a? Array }
|
|
81
|
+
else
|
|
82
|
+
record = obj
|
|
83
|
+
end
|
|
84
|
+
es.add(time, record)
|
|
85
|
+
end
|
|
86
|
+
router.emit_stream(tag, es)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: fluent-plugin-telemetry-iosxr
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Tetsuhiro Sato
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-09-30 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: fluentd
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.14'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.14'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.15'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.15'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '10.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '10.0'
|
|
55
|
+
description: Fluentd input plugin to collect IOS-XR telemetry.
|
|
56
|
+
email:
|
|
57
|
+
- tetsusat@cisco.com
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".gitignore"
|
|
63
|
+
- Gemfile
|
|
64
|
+
- README.md
|
|
65
|
+
- Rakefile
|
|
66
|
+
- fluent-plugin-telemetry-iosxr.gemspec
|
|
67
|
+
- lib/fluent/plugin/in_telemetry_iosxr.rb
|
|
68
|
+
homepage: https://github.com/tetsusat/fluent-plugin-telemetry-iosxr
|
|
69
|
+
licenses:
|
|
70
|
+
- MIT
|
|
71
|
+
metadata: {}
|
|
72
|
+
post_install_message:
|
|
73
|
+
rdoc_options: []
|
|
74
|
+
require_paths:
|
|
75
|
+
- lib
|
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - ">="
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '0'
|
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
|
+
requirements:
|
|
83
|
+
- - ">="
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '0'
|
|
86
|
+
requirements: []
|
|
87
|
+
rubyforge_project:
|
|
88
|
+
rubygems_version: 2.5.2.1
|
|
89
|
+
signing_key:
|
|
90
|
+
specification_version: 4
|
|
91
|
+
summary: Fluentd input plugin to collect IOS-XR telemetry.
|
|
92
|
+
test_files: []
|