Module: Zenoss::Model::RRDView
Instance Method Summary collapse
-
#fetch_rrd_value(dpname, vstart, vend = DateTime.now, cf = 'AVERAGE', resolution = 300) ⇒ Object
Get all of the data point falues between a certain time period.
-
#get_rrd_data_points ⇒ Array
Of datapoints.
-
#get_rrd_values(dsnames) ⇒ Hash
Get key/value pairs of RRD Values for the passed data source names.
-
#parse_rrd_fetch(vstr) ⇒ Object
Parse the string returned by the REST call fetchRRDValue.
Methods included from Zenoss::Model
Methods included from Zenoss
connect, #parse_array, #pdatetime_to_datetime, #pdict_to_hash, #plist_to_array, #ptuples_to_hash, #sanitize_str
Instance Method Details
#fetch_rrd_value(dpname, vstart, vend = DateTime.now, cf = 'AVERAGE', resolution = 300) ⇒ Object
Get all of the data point falues between a certain time period
51 52 53 54 55 56 57 58 |
# File 'lib/zenoss/model/rrd_view.rb', line 51 def fetch_rrd_value(dpname,vstart,vend=DateTime.now,cf='AVERAGE',resolution=300) method = "fetchRRDValue?dpname=#{dpname}" method << "&cf=#{cf}&resolution=#{resolution}" method << "&start=#{vstart.strftime('%s')}" method << "&end=#{vend.strftime('%s')}" custom_rest(method) parse_rrd_fetch(custom_rest(method)) end |
#get_rrd_data_points ⇒ Array
Returns of datapoints.
26 27 28 29 30 31 |
# File 'lib/zenoss/model/rrd_view.rb', line 26 def get_rrd_data_points (plist_to_array( custom_rest('getRRDDataPoints').chomp )).map do |dstr| dp = dstr.sub(/^<([\w]+)\s+at\s+(.*)>$/,'\2') RRDDataPoint.new(@zenoss,dp) end end |
#get_rrd_values(dsnames) ⇒ Hash
Get key/value pairs of RRD Values for the passed data source names.
37 38 39 |
# File 'lib/zenoss/model/rrd_view.rb', line 37 def get_rrd_values(dsnames) pdict_to_hash(custom_rest("getRRDValues?dsnames=[#{dsnames.join(',')}]")) end |
#parse_rrd_fetch(vstr) ⇒ Object
Parse the string returned by the REST call fetchRRDValue.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/zenoss/model/rrd_view.rb', line 64 def parse_rrd_fetch(vstr) vstr = vstr.chomp vstr = vstr.slice 1, (vstr.length - 2) parts = vstr.match(/^\(([^\)]+)\),\s*\(([^\)]+)\),\s*\[([^\]]+)\]/) # Get the first part of the return, start, end, resolution retparms = Hash[[:start,:end,:resolution].zip( parts[1].split(/\s*,\s*/).map {|v| v.to_i} )] # Get the datasource name. This will almost always be 'ds0' retparms[:rrdds] = parts[2].gsub(/['"]/,'').split(/,/).first # Get the values retparms[:rrdvalues] = plist_to_array(parts[3]).map do |v| atom = v.gsub(/(\(|\))/,'').split(/\s*,\s*/)[0] case atom when /\d\.\d/ atom.to_f when /^\d$/ atom.to_i when /None/ nil end end retparms end |