Class: MonitoringProtocols::Collectd::NetworkMessage
- Inherits:
-
NetworkMessage
- Object
- DataStruct
- NetworkMessage
- MonitoringProtocols::Collectd::NetworkMessage
- Defined in:
- lib/monitoring_protocols/collectd/msg.rb
Overview
from collectd source code plugin.h
notification: int severity; cdtime_t time; char message; char host; char plugin; char plugin_instance; char type; char type_instance;
data value_t *values; int values_len; cdtime_t time; cdtime_t interval; char host; char plugin; char plugin_instance; char type; char type_instance;
Instance Method Summary collapse
- #convert_content ⇒ Object
- #data? ⇒ Boolean
-
#measure_id ⇒ Object
return a unique id for the measured data.
- #notification? ⇒ Boolean
- #plugin_display ⇒ Object
- #type_display ⇒ Object
- #value(index = 0) ⇒ Object
Methods inherited from DataStruct
#<=>, attributes, #initialize, #list_keys, #merge_data_from!, properties, #selected_field?, #to_a, #to_h, #to_msgpack
Constructor Details
This class inherits a constructor from MonitoringProtocols::DataStruct
Instance Method Details
#convert_content ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/monitoring_protocols/collectd/msg.rb', line 80 def convert_content common = { time: time, host: host, app_name: plugin, res_name: type, metric_name: type_instance, } if data? ret = DataPoint.new(common.merge!( value: value )) else ret = Notification.new(common.merge!( severity: severity, message: )) end [ret] end |
#data? ⇒ Boolean
50 51 52 |
# File 'lib/monitoring_protocols/collectd/msg.rb', line 50 def data? self..nil? end |
#measure_id ⇒ Object
return a unique id for the measured data.
76 77 78 |
# File 'lib/monitoring_protocols/collectd/msg.rb', line 76 def measure_id "#{host}-#{plugin_display}-#{type_display}" end |
#notification? ⇒ Boolean
46 47 48 |
# File 'lib/monitoring_protocols/collectd/msg.rb', line 46 def notification? !self..nil? end |
#plugin_display ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/monitoring_protocols/collectd/msg.rb', line 58 def plugin_display if plugin_instance && !plugin_instance.empty? "#{plugin}/#{plugin_instance}" else plugin end end |
#type_display ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/monitoring_protocols/collectd/msg.rb', line 66 def type_display if type_instance && !type_instance.empty? "#{type}/#{type_instance}" else type end end |
#value(index = 0) ⇒ Object
54 55 56 |
# File 'lib/monitoring_protocols/collectd/msg.rb', line 54 def value(index = 0) values[index] end |