Class: Istat::Frames::MeasurementResponse
- Defined in:
- lib/istat/frames/measurement.rb
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
-
#cpu ⇒ Array<Hash>
collect cpu data (can contain history).
-
#cpu? ⇒ Boolean
returns true if there is a cpu section in the frame.
-
#disks ⇒ Array<Hash>
collect all disk informations.
-
#disks? ⇒ Boolean
returns true if there is a disks section in the frame.
-
#fans ⇒ Array
collect all fan informations in order.
-
#fans? ⇒ Boolean
returns true if there is a fan section in the frame.
-
#load ⇒ Array
parse the load informations.
-
#load? ⇒ Boolean
returns true if there is a load section in the frame.
-
#memory ⇒ Hash
parse the memory informations.
-
#memory? ⇒ Boolean
returns true if there is a memory section in the frame.
-
#network ⇒ Hash<Array<Hash>>
collects all network information over the interfaces (can contain history).
-
#network? ⇒ Boolean
returns true if there is a network section in the frame.
-
#rid ⇒ Integer
parse the isr header request id.
-
#sid_disk ⇒ Integer
parse the isr header disk id.
-
#sid_fans ⇒ Integer
parse the isr header fans sid.
-
#sid_temp ⇒ Integer
parse the isr header temp sid.
-
#temps ⇒ Array
collect all temperature informations in order.
-
#temps? ⇒ Boolean
returns true if there is a temps section in the frame.
-
#uptime ⇒ Time
calculate the system uptime.
-
#uptime? ⇒ Boolean
returns true if there is a uptime section in the frame.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Istat::Frames::Base
Instance Method Details
#cpu ⇒ Array<Hash>
collect cpu data (can contain history)
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/istat/frames/measurement.rb', line 89 def cpu if cpu? map(:CPU) do |element, attributes| { :id => attributes["id"].to_i, :user => attributes["u"].to_i, :system => attributes["s"].to_i, :nice => attributes["n"].to_i } end end end |
#cpu? ⇒ Boolean
returns true if there is a cpu section in the frame
76 77 78 |
# File 'lib/istat/frames/measurement.rb', line 76 def cpu? has_node? :CPU end |
#disks ⇒ Array<Hash>
collect all disk informations
262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/istat/frames/measurement.rb', line 262 def disks if disks? map(:DISKS) do |element, attributes| { :label => attributes["n"], :uuid => attributes["uuid"], :free => attributes["f"].to_i, :percent_used => attributes["p"].to_f } end end end |
#disks? ⇒ Boolean
returns true if there is a disks section in the frame
248 249 250 |
# File 'lib/istat/frames/measurement.rb', line 248 def disks? has_node? :DISKS end |
#fans ⇒ Array
collect all fan informations in order
221 222 223 224 225 226 227 228 229 |
# File 'lib/istat/frames/measurement.rb', line 221 def fans if fans? fans = [] map(:FANS) do |element, attributes| fans[attributes["i"].to_i] = attributes["s"].to_i end fans end end |
#fans? ⇒ Boolean
returns true if there is a fan section in the frame
212 213 214 |
# File 'lib/istat/frames/measurement.rb', line 212 def fans? has_node? :FANS end |
#load ⇒ Array
parse the load informations
184 185 186 187 188 189 |
# File 'lib/istat/frames/measurement.rb', line 184 def load if load? attributes = node(:LOAD).attributes [attributes["one"].to_f, attributes["fv"].to_f, attributes["ff"].to_f] end end |
#load? ⇒ Boolean
returns true if there is a load section in the frame
175 176 177 |
# File 'lib/istat/frames/measurement.rb', line 175 def load? has_node? :LOAD end |
#memory ⇒ Hash
parse the memory informations
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/istat/frames/measurement.rb', line 157 def memory if memory? attributes = node(:MEM).attributes { :wired => attributes["w"].to_i, :active => attributes["a"].to_i, :inactive => attributes["i"].to_i, :free => attributes["f"].to_i, :total => attributes["t"].to_i, :swap_used => attributes["su"].to_i, :swap_total => attributes["st"].to_i, :page_ins => attributes["pi"].to_i, :page_outs => attributes["po"].to_i } end end |
#memory? ⇒ Boolean
returns true if there is a memory section in the frame
138 139 140 |
# File 'lib/istat/frames/measurement.rb', line 138 def memory? has_node? :MEM end |
#network ⇒ Hash<Array<Hash>>
supports only one interface at the moment
collects all network information over the interfaces (can contain history). Send and received values are byte numbers.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/istat/frames/measurement.rb', line 121 def network if network? interface_name = node(:NET).attributes["if"].to_i interfaces = { interface_name => [] } map(:NET) do |element, attributes| interfaces[interface_name] << { :id => attributes["id"].to_i, :received => attributes["d"].to_i, :send => attributes["u"].to_i, :time => Time.at(attributes["t"].to_f) } end interfaces end end |
#network? ⇒ Boolean
returns true if there is a network section in the frame
103 104 105 |
# File 'lib/istat/frames/measurement.rb', line 103 def network? has_node? :NET end |
#rid ⇒ Integer
parse the isr header request id
53 54 55 |
# File 'lib/istat/frames/measurement.rb', line 53 def rid @root.attributes["rid"].to_i end |
#sid_disk ⇒ Integer
parse the isr header disk id
59 60 61 |
# File 'lib/istat/frames/measurement.rb', line 59 def sid_disk @root.attributes["ds"].to_i end |
#sid_fans ⇒ Integer
parse the isr header fans sid
71 72 73 |
# File 'lib/istat/frames/measurement.rb', line 71 def sid_fans @root.attributes["fs"].to_i end |
#sid_temp ⇒ Integer
parse the isr header temp sid
65 66 67 |
# File 'lib/istat/frames/measurement.rb', line 65 def sid_temp @root.attributes["ts"].to_i end |
#temps ⇒ Array
collect all temperature informations in order
201 202 203 204 205 206 207 208 209 |
# File 'lib/istat/frames/measurement.rb', line 201 def temps if temps? temps = [] map(:TEMPS) do |element, attributes| temps[attributes["i"].to_i] = attributes["t"].to_i end temps end end |
#temps? ⇒ Boolean
returns true if there is a temps section in the frame
192 193 194 |
# File 'lib/istat/frames/measurement.rb', line 192 def temps? has_node? :TEMPS end |
#uptime ⇒ Time
calculate the system uptime
241 242 243 244 245 |
# File 'lib/istat/frames/measurement.rb', line 241 def uptime if uptime? Time.now - node(:UPT).attributes["u"].to_i end end |
#uptime? ⇒ Boolean
returns true if there is a uptime section in the frame
232 233 234 |
# File 'lib/istat/frames/measurement.rb', line 232 def uptime? has_node? :UPT end |