rubix 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -30,9 +30,11 @@ module Rubix
30
30
  }.freeze
31
31
  TYPE_NAMES = TYPE_CODES.invert.freeze
32
32
 
33
- # The numeric codes for the value types of a Zabbix item. This Hash
34
- # is used by ZabbixPipe#value_code_from_value to dynamically set the
35
- # type of a value when creating a new Zabbix item.
33
+ # The numeric codes for the value types of a Zabbix item.
34
+ #
35
+ # This Hash is used by ZabbixPipe#value_code_from_value to
36
+ # dynamically set the type of a value when creating a new Zabbix
37
+ # item.
36
38
  VALUE_CODES = {
37
39
  :float => 0, # Numeric (float)
38
40
  :character => 1, # Character
@@ -42,6 +44,26 @@ module Rubix
42
44
  }.freeze
43
45
  VALUE_NAMES = VALUE_CODES.invert.freeze
44
46
 
47
+ # The numeric codes for the data types of a Zabbix item.
48
+ #
49
+ # The default will be <tt>:decimal</tt>
50
+ DATA_CODES = {
51
+ :decimal => 0,
52
+ :octal => 1,
53
+ :hexadecimal => 2
54
+ }.freeze
55
+ DATA_NAMES = DATA_CODES.invert.freeze
56
+
57
+ # The numeric codes for the status of a Zabbix item.
58
+ #
59
+ # The default will be <tt>:active</tt>
60
+ STATUS_CODES = {
61
+ :active => 0,
62
+ :disabled => 1,
63
+ :not_supported => 3
64
+ }.freeze
65
+ STATUS_NAMES = STATUS_CODES.invert.freeze
66
+
45
67
  # Return the +value_type+ name (:float, :text, &c.) for a Zabbix
46
68
  # item's value type by examining the given +value+.
47
69
  def self.value_type_from_value value
@@ -60,8 +82,8 @@ module Rubix
60
82
  end
61
83
 
62
84
  attr_accessor :key, :description, :units
63
- attr_writer :type, :value_type
64
-
85
+ attr_writer :type, :value_type, :data_type, :history, :trends, :status
86
+
65
87
  def initialize properties={}
66
88
  super(properties)
67
89
  @key = properties[:key]
@@ -70,6 +92,10 @@ module Rubix
70
92
  @units = properties[:units]
71
93
 
72
94
  self.value_type = properties[:value_type]
95
+ self.data_type = properties[:data_type]
96
+ self.history = properties[:history]
97
+ self.trends = properties[:trends]
98
+ self.status = properties[:status]
73
99
 
74
100
  self.host = properties[:host]
75
101
  self.host_id = properties[:host_id]
@@ -89,10 +115,27 @@ module Rubix
89
115
  @value_type ||= :character
90
116
  end
91
117
 
118
+ def data_type
119
+ @data_type ||= :decimal
120
+ end
121
+
92
122
  def type
93
123
  @type ||= :trapper
94
124
  end
95
125
 
126
+ def history
127
+ @history ||= 90
128
+ end
129
+
130
+ def trends
131
+ @trends ||= 365
132
+ end
133
+
134
+ def status
135
+ @status ||= :active
136
+ end
137
+
138
+
96
139
  #
97
140
  # == Associations ==
98
141
  #
@@ -111,7 +154,11 @@ module Rubix
111
154
  :description => (description || 'Unknown'),
112
155
  :type => self.class::TYPE_CODES[type],
113
156
  :key_ => key,
114
- :value_type => self.class::VALUE_CODES[value_type]
157
+ :value_type => self.class::VALUE_CODES[value_type],
158
+ :data_type => self.class::DATA_CODES[data_type],
159
+ :history => history,
160
+ :trends => trends,
161
+ :status => self.class::STATUS_CODES[status],
115
162
  }.tap do |p|
116
163
  p[:applications] = application_ids if application_ids
117
164
  p[:units] = units if units
@@ -141,6 +188,10 @@ module Rubix
141
188
  :description => item['description'],
142
189
  :type => TYPE_NAMES[item['type'].to_i],
143
190
  :value_type => VALUE_NAMES[item['value_type'].to_i],
191
+ :data_type => DATA_NAMES[item['data_type'].to_i],
192
+ :history => item['history'].to_i,
193
+ :trends => item['trends'].to_i,
194
+ :status => STATUS_NAMES[item['status'].to_i],
144
195
  :application_ids => (item['applications'] || []).map { |app| app['applicationid'].to_i },
145
196
  :key => item['key_'],
146
197
  :units => item['units']
@@ -41,6 +41,10 @@ describe "Items" do
41
41
  @item.description = 'rubix item description 2'
42
42
  @item.type = :external
43
43
  @item.value_type = :unsigned_int
44
+ @item.data_type = :octal
45
+ @item.history = 91
46
+ @item.trends = 400
47
+ @item.status = :disabled
44
48
  @item.host_id = @host_2.id
45
49
  @item.units = 'MB'
46
50
  @item.applications = [@app_2]
@@ -51,9 +55,13 @@ describe "Items" do
51
55
  new_item = Rubix::Item.find(:key => 'rubix.spec2', :host_id => @host_2.id)
52
56
  new_item.should_not be_nil
53
57
  new_item.value_type.should == :unsigned_int
58
+ new_item.data_type.should == :octal
59
+ new_item.history.should == 91
60
+ new_item.trends.should == 400
61
+ new_item.status.should == :disabled
54
62
  new_item.type.should == :external
55
- new_item.host.name.should == @host_2.name
56
- new_item.units.should == 'MB'
63
+ new_item.host.name.should == @host_2.name
64
+ new_item.units.should == 'MB'
57
65
  new_item.applications.map(&:name).should include(@app_2.name)
58
66
  end
59
67
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dhruv Bansal
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-02-06 00:00:00 -06:00
17
+ date: 2012-02-10 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency