fluent-plugin-juniper-telemetry_tech-mocha 0.4.0

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.
@@ -0,0 +1,114 @@
1
+
2
+ ##############################
3
+ ## Supporting functions ##
4
+ ##############################
5
+
6
+ def epoc_to_sec(epoc)
7
+
8
+ # Check if sec, usec or msec
9
+ nbr_digit = epoc.to_s.size
10
+
11
+ if nbr_digit == 10
12
+ return epoc.to_i
13
+ elsif nbr_digit == 13
14
+ return (epoc.to_i/1000).to_i
15
+ elsif nbr_digit == 16
16
+ return (epoc.to_i/1000000).to_i
17
+ end
18
+
19
+ return epoc
20
+ end
21
+
22
+ def clean_up_name(name)
23
+
24
+ ## Create a clean copy of Name and convert to string
25
+ tmp = name.to_s.dup
26
+
27
+ ## Clean up device name and interface name to remove restricted caracter
28
+ tmp.gsub!('/', '_')
29
+ tmp.gsub!(':', '_')
30
+ tmp.gsub!('.', '_')
31
+ tmp.gsub!(' ', '_')
32
+
33
+ return tmp
34
+ end
35
+
36
+ def build_record(type, data_to_build)
37
+
38
+ if type.to_s == 'flat'
39
+
40
+ record = {}
41
+
42
+ # initialize variables
43
+ name = ""
44
+ sensor_value = ""
45
+
46
+ ## Concatene all key/value into a string and stop at "value"
47
+ data_to_build.each do |entry|
48
+ entry.each do |key, value|
49
+
50
+ if key == "value"
51
+ sensor_value = value
52
+ next
53
+ end
54
+
55
+ if name == ""
56
+ name = key + "." + clean_up_name(value)
57
+ else
58
+ name = name + "." + key + "." + clean_up_name(value)
59
+ end
60
+ end
61
+ end
62
+
63
+ record = { name => sensor_value }
64
+ return record
65
+
66
+ elsif output_format.to_s == 'structured'
67
+
68
+ record = {}
69
+ ## Convert list into Hash
70
+ ## Each entry on the list is a hash with 1 key/value
71
+ data_to_build.each do |entry|
72
+ entry.each do |key, value|
73
+ record[key] = value
74
+ end
75
+ end
76
+
77
+ return record
78
+
79
+ elsif output_format.to_s == 'statsd'
80
+
81
+ record = {}
82
+
83
+ # initialize variables
84
+ name = ""
85
+ sensor_value = ""
86
+
87
+ ## Concatene all key/value into a string, exclude device & stop at "value"
88
+ data_to_build.each do |entry|
89
+ entry.each do |key, value|
90
+
91
+ if key == "value"
92
+ sensor_value = value
93
+ next
94
+ elsif key == "device"
95
+ next
96
+ else
97
+ if name == ""
98
+ name = key + "." + clean_up_name(value)
99
+ else
100
+ name = name + "." + key + "." + clean_up_name(value)
101
+ end
102
+ end
103
+ end
104
+ end
105
+
106
+ record[:statsd_type] = 'gauge'
107
+ record[:statsd_key] = name.downcase
108
+ record[:statsd_gauge] = sensor_value
109
+
110
+ return record
111
+ else
112
+ $log.warn "Output_format '#{type.to_s}' not supported"
113
+ end
114
+ end
@@ -0,0 +1,98 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf'
7
+
8
+
9
+ ##
10
+ # Imports
11
+ #
12
+ require 'telemetry_top.pb'
13
+
14
+
15
+ ##
16
+ # Message Classes
17
+ #
18
+ class LogicalPort < ::Protobuf::Message; end
19
+ class LogicalInterfaceInfo < ::Protobuf::Message; end
20
+ class IngressInterfaceStats < ::Protobuf::Message; end
21
+ class EgressInterfaceStats < ::Protobuf::Message; end
22
+ class OperationalState < ::Protobuf::Message; end
23
+ class ForwardingClassAccounting < ::Protobuf::Message; end
24
+ class LogicalInterfaceQueueStats < ::Protobuf::Message; end
25
+
26
+
27
+ ##
28
+ # Message Fields
29
+ #
30
+ class LogicalPort
31
+ repeated ::LogicalInterfaceInfo, :interface_info, 1
32
+ end
33
+
34
+ class LogicalInterfaceInfo
35
+ required :string, :if_name, 1, :".telemetry_options" => { :is_key => true }
36
+ required :uint64, :init_time, 2, :".telemetry_options" => { :is_timestamp => true }
37
+ optional :uint32, :snmp_if_index, 3, :".telemetry_options" => { :is_key => true }
38
+ optional :string, :parent_ae_name, 4, :".telemetry_options" => { :is_key => true }
39
+ optional ::IngressInterfaceStats, :ingress_stats, 5
40
+ optional ::EgressInterfaceStats, :egress_stats, 6
41
+ optional ::OperationalState, :op_state, 7
42
+ optional :string, :administractive_status, 8
43
+ optional :string, :description, 9
44
+ optional :uint32, :last_change, 10
45
+ optional :uint32, :high_speed, 11
46
+ repeated ::LogicalInterfaceQueueStats, :ingress_queue_info, 12
47
+ repeated ::LogicalInterfaceQueueStats, :egress_queue_info, 13
48
+ end
49
+
50
+ class IngressInterfaceStats
51
+ required :uint64, :if_packets, 1, :".telemetry_options" => { :is_counter => true }
52
+ required :uint64, :if_octets, 2, :".telemetry_options" => { :is_counter => true }
53
+ optional :uint64, :if_ucast_packets, 3, :".telemetry_options" => { :is_counter => true }
54
+ optional :uint64, :if_mcast_packets, 4, :".telemetry_options" => { :is_counter => true }
55
+ repeated ::ForwardingClassAccounting, :if_fc_stats, 5
56
+ end
57
+
58
+ class EgressInterfaceStats
59
+ required :uint64, :if_packets, 1, :".telemetry_options" => { :is_counter => true }
60
+ required :uint64, :if_octets, 2, :".telemetry_options" => { :is_counter => true }
61
+ optional :uint64, :if_ucast_packets, 3, :".telemetry_options" => { :is_counter => true }
62
+ optional :uint64, :if_mcast_packets, 4, :".telemetry_options" => { :is_counter => true }
63
+ end
64
+
65
+ class OperationalState
66
+ optional :string, :operational_status, 1
67
+ end
68
+
69
+ class ForwardingClassAccounting
70
+ optional :string, :if_family, 1, :".telemetry_options" => { :is_key => true }
71
+ optional :uint32, :fc_number, 2, :".telemetry_options" => { :is_key => true }
72
+ optional :uint64, :if_packets, 3, :".telemetry_options" => { :is_counter => true }
73
+ optional :uint64, :if_octets, 4, :".telemetry_options" => { :is_counter => true }
74
+ end
75
+
76
+ class LogicalInterfaceQueueStats
77
+ optional :uint32, :queue_number, 1, :".telemetry_options" => { :is_key => true }
78
+ optional :uint64, :packets, 2, :".telemetry_options" => { :is_counter => true }
79
+ optional :uint64, :bytes, 3, :".telemetry_options" => { :is_counter => true }
80
+ optional :uint64, :tail_drop_packets, 4, :".telemetry_options" => { :is_counter => true }
81
+ optional :uint64, :rate_limit_drop_packets, 5, :".telemetry_options" => { :is_counter => true }
82
+ optional :uint64, :rate_limit_drop_bytes, 6, :".telemetry_options" => { :is_counter => true }
83
+ optional :uint64, :red_drop_packets, 7, :".telemetry_options" => { :is_counter => true }
84
+ optional :uint64, :red_drop_bytes, 8, :".telemetry_options" => { :is_counter => true }
85
+ optional :uint64, :average_buffer_occupancy, 9, :".telemetry_options" => { :is_gauge => true }
86
+ optional :uint64, :current_buffer_occupancy, 10, :".telemetry_options" => { :is_gauge => true }
87
+ optional :uint64, :peak_buffer_occupancy, 11, :".telemetry_options" => { :is_gauge => true }
88
+ optional :uint64, :allocated_buffer_size, 12, :".telemetry_options" => { :is_gauge => true }
89
+ end
90
+
91
+
92
+ ##
93
+ # Extended Message Fields
94
+ #
95
+ class ::JuniperNetworksSensors < ::Protobuf::Message
96
+ optional ::LogicalPort, :".jnprLogicalInterfaceExt", 7, :extension => true
97
+ end
98
+
@@ -0,0 +1,115 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf'
7
+
8
+
9
+ ##
10
+ # Enum Classes
11
+ #
12
+ class Lsp_event < ::Protobuf::Enum
13
+ define :INITIATED, 0
14
+ define :CONCLUDED_UP, 1
15
+ define :CONCLUDED_TORN_DOWN, 2
16
+ define :PROTECTION_AVAILABLE, 3
17
+ define :PROTECTION_UNAVAILABLE, 4
18
+ define :AUTOBW_SUCCESS, 5
19
+ define :AUTOBW_FAIL, 6
20
+ define :RESV_TEAR_RECEIVED, 7
21
+ define :DESELECT_ACTIVE_PATH, 8
22
+ define :CHANGE_ACTIVE_PATH, 9
23
+ define :DETOUR_UP, 10
24
+ define :DETOUR_DOWN, 11
25
+ define :ORIGINATE_MBB, 12
26
+ define :SELECT_ACTIVE_PATH, 13
27
+ define :CSPF_NO_ROUTE, 14
28
+ define :CSPF_SUCCESS, 15
29
+ define :RESTART_RECOVERY_FAIL, 16
30
+ define :PATHERR_RECEIVED, 17
31
+ define :PATH_MTU_CHANGE, 18
32
+ define :TUNNEL_LOCAL_REPAIRED, 19
33
+ end
34
+
35
+ class Event_subcode < ::Protobuf::Enum
36
+ define :ADMISSION_CONTROL_FAILURE, 1
37
+ define :SESSION_PREEMPTED, 2
38
+ define :BAD_LOOSE_ROUTE, 3
39
+ define :BAD_STRICT_ROUTE, 4
40
+ define :LABEL_ALLOCATION_FAILURE, 5
41
+ define :NON_RSVP_CAPABLE_ROUTER, 6
42
+ define :TTL_EXPIRED, 7
43
+ define :ROUTING_LOOP_DETECTED, 8
44
+ define :REQUESTED_BANDWIDTH_UNAVAILABLE, 9
45
+ end
46
+
47
+
48
+ ##
49
+ # Message Classes
50
+ #
51
+ class Key < ::Protobuf::Message; end
52
+ class Lsp_monitor_data_event < ::Protobuf::Message; end
53
+ class Ero_type_entry < ::Protobuf::Message; end
54
+ class Ero_ipv4_type < ::Protobuf::Message; end
55
+ class Rro_type_entry < ::Protobuf::Message; end
56
+ class Rro_ipv4_type < ::Protobuf::Message; end
57
+ class Lsp_monitor_data_property < ::Protobuf::Message; end
58
+ class Lsp_mon < ::Protobuf::Message; end
59
+
60
+
61
+ ##
62
+ # File Options
63
+ #
64
+ #set_option :optimize_for, ::Google::Protobuf::FileOptions::OptimizeMode::LITE_RUNTIME
65
+
66
+
67
+ ##
68
+ # Message Fields
69
+ #
70
+ class Key
71
+ required :string, :name, 1
72
+ required :int32, :instance_identifier, 2
73
+ required :uint64, :time_stampg, 3
74
+ end
75
+
76
+ class Lsp_monitor_data_event
77
+ required ::Lsp_event, :event_identifier, 1
78
+ optional ::Event_subcode, :subcode, 2
79
+ end
80
+
81
+ class Ero_type_entry
82
+ required :uint32, :ip, 1
83
+ optional :string, :flags, 2
84
+ end
85
+
86
+ class Ero_ipv4_type
87
+ repeated ::Ero_type_entry, :entry, 1
88
+ end
89
+
90
+ class Rro_type_entry
91
+ optional :uint32, :nodeid, 1
92
+ optional :uint32, :flags, 2
93
+ optional :uint32, :intf_addr, 3
94
+ optional :uint32, :label, 4
95
+ end
96
+
97
+ class Rro_ipv4_type
98
+ repeated ::Rro_type_entry, :rro_entry, 1
99
+ end
100
+
101
+ class Lsp_monitor_data_property
102
+ optional :uint64, :bandwidth, 1
103
+ optional :string, :path_name, 2
104
+ optional :int32, :metric, 3
105
+ optional :float, :max_avg_bw, 4
106
+ optional ::Ero_ipv4_type, :ero, 5
107
+ optional ::Rro_ipv4_type, :rro, 6
108
+ end
109
+
110
+ class Lsp_mon
111
+ required ::Key, :key_field, 1
112
+ optional ::Lsp_monitor_data_event, :event_field, 2
113
+ optional ::Lsp_monitor_data_property, :property_field, 3
114
+ end
115
+
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf'
7
+
8
+
9
+ ##
10
+ # Imports
11
+ #
12
+ require 'telemetry_top.pb'
13
+
14
+
15
+ ##
16
+ # Message Classes
17
+ #
18
+ class LspStats < ::Protobuf::Message; end
19
+ class LspStatsRecord < ::Protobuf::Message; end
20
+
21
+
22
+ ##
23
+ # Message Fields
24
+ #
25
+ class LspStats
26
+ repeated ::LspStatsRecord, :lsp_stats_records, 1
27
+ end
28
+
29
+ class LspStatsRecord
30
+ required :string, :name, 1, :".telemetry_options" => { :is_key => true }
31
+ required :uint32, :instance_identifier, 2, :".telemetry_options" => { :is_key => true }
32
+ required :string, :counter_name, 3, :".telemetry_options" => { :is_key => true }
33
+ optional :uint64, :packets, 4, :".telemetry_options" => { :is_counter => true }
34
+ optional :uint64, :bytes, 5, :".telemetry_options" => { :is_counter => true }
35
+ optional :uint64, :packet_rate, 6
36
+ optional :uint64, :byte_rate, 7
37
+ end
38
+
39
+
40
+ ##
41
+ # Extended Message Fields
42
+ #
43
+ class ::JuniperNetworksSensors < ::Protobuf::Message
44
+ optional ::LspStats, :".jnpr_lsp_statistics_ext", 5, :extension => true
45
+ end
46
+
@@ -0,0 +1,59 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf'
7
+
8
+
9
+ ##
10
+ # Imports
11
+ #
12
+ require 'telemetry_top.pb'
13
+
14
+
15
+ ##
16
+ # Message Classes
17
+ #
18
+ class NetworkProcessorMemoryUtilization < ::Protobuf::Message; end
19
+ class NpuMemory < ::Protobuf::Message; end
20
+ class NpuMemorySummary < ::Protobuf::Message; end
21
+ class NpuMemoryPartition < ::Protobuf::Message; end
22
+
23
+
24
+ ##
25
+ # Message Fields
26
+ #
27
+ class NetworkProcessorMemoryUtilization
28
+ repeated ::NpuMemory, :memory_stats, 1
29
+ end
30
+
31
+ class NpuMemory
32
+ required :string, :identifier, 1
33
+ repeated ::NpuMemorySummary, :summary, 2
34
+ repeated ::NpuMemoryPartition, :partition, 3
35
+ end
36
+
37
+ class NpuMemorySummary
38
+ optional :string, :resource_name, 1
39
+ optional :uint64, :size, 2
40
+ optional :uint64, :allocated, 3
41
+ optional :int32, :utilization, 4
42
+ end
43
+
44
+ class NpuMemoryPartition
45
+ optional :string, :name, 1
46
+ optional :string, :application_name, 2
47
+ optional :uint32, :bytes_allocated, 3
48
+ optional :uint32, :allocation_count, 4
49
+ optional :uint32, :free_count, 5
50
+ end
51
+
52
+
53
+ ##
54
+ # Extended Message Fields
55
+ #
56
+ class ::JuniperNetworksSensors < ::Protobuf::Message
57
+ optional ::NetworkProcessorMemoryUtilization, :".npu_memory_ext", 11, :extension => true
58
+ end
59
+
@@ -0,0 +1,63 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf'
7
+
8
+
9
+ ##
10
+ # Imports
11
+ #
12
+ require 'telemetry_top.pb'
13
+
14
+
15
+ ##
16
+ # Message Classes
17
+ #
18
+ class NetworkProcessorUtilization < ::Protobuf::Message; end
19
+ class Utilization < ::Protobuf::Message; end
20
+ class MemoryLoad < ::Protobuf::Message; end
21
+ class PacketLoad < ::Protobuf::Message; end
22
+
23
+
24
+ ##
25
+ # Message Fields
26
+ #
27
+ class NetworkProcessorUtilization
28
+ repeated ::Utilization, :npu_util_stats, 1
29
+ end
30
+
31
+ class Utilization
32
+ required :string, :identifier, 1
33
+ optional :uint32, :utilization, 2
34
+ repeated ::PacketLoad, :packets, 3
35
+ repeated ::MemoryLoad, :memory, 4
36
+ end
37
+
38
+ class MemoryLoad
39
+ optional :string, :name, 1
40
+ optional :uint32, :average_util, 2
41
+ optional :uint32, :highest_util, 3
42
+ optional :uint32, :lowest_util, 4
43
+ optional :uint32, :average_cache_hit_rate, 5
44
+ optional :uint32, :highest_cache_hit_rate, 6
45
+ optional :uint32, :lowest_cache_hit_rate, 7
46
+ end
47
+
48
+ class PacketLoad
49
+ required :string, :identifier, 1
50
+ optional :uint64, :rate, 2
51
+ optional :uint32, :average_instructions_per_packet, 3
52
+ optional :uint32, :average_wait_cycles_per_packet, 4
53
+ optional :uint32, :average_cycles_per_packet, 5
54
+ end
55
+
56
+
57
+ ##
58
+ # Extended Message Fields
59
+ #
60
+ class ::JuniperNetworksSensors < ::Protobuf::Message
61
+ optional ::NetworkProcessorUtilization, :".jnpr_npu_utilization_ext", 12, :extension => true
62
+ end
63
+