Browse files

Updated readme

  • Loading branch information...
1 parent 455ab58 commit 247f94ae18e4cdcb4bcf35f3cd33a79bbdb59816 Thiago Morello committed Mar 2, 2010
Showing with 37 additions and 22 deletions.
  1. +27 −12 README.rdoc
  2. +10 −10 lib/rrd/wrapper.rb
View
39 README.rdoc
@@ -93,29 +93,44 @@ Mac: <tt>port install rrdtool</tt>
Normal methods return false on error, or the expected result otherwise.
-Bang methods raise exception on error.
-
- # Restoring a rrd file from xml
- RRD::Wrapper.restore "myrrd.xml", "myrrd.rrd"
-
- # Creating a rrd file
+ # Creating a rrd file
RRD::Wrapper.create "myrrd.rrd", "--step", "300", "DS:ifOutOctets:COUNTER:1800:0:4294967295", "RRA:AVERAGE:0.5:1:2016"
-
- # Updating rrd with a new value
- RRD::Wrapper.update "myrrd.rrd", "N:500000000"
# Fetching average data
RRD::Wrapper.fetch "myrrd.rrd", "AVERAGE"
- # Looking for the first and last entered dates
+ # Looking for the first entered dates
RRD::Wrapper.first "myrrd.rrd"
- RRD::Wrapper.last "myrrd.rrd"
- # Creating a graph
+ # Creating a graph
RRD::Wrapper.graph("graph.png", "DEF:data=myrrd.rrd:ifOutOctets:AVERAGE", "LINE1:data#0000FF:Output bytes")
+ # Getting info on a rrd file
+ RRD::Wrapper.info("myrrd.rrd")
+
+ # Looking for the last entered dates
+ RRD::Wrapper.last "myrrd.rrd"
+
+ # Getting last data inserted on a rrd
+ RRD::Wrapper.last_update "myrrd.rrd"
+
+ # Resizing a rrd file RRA
+ RRD::Wrapper.resize "myrrd.rrd", "0", "GROW", "10"
+
+ # Restoring a rrd file from xml
+ RRD::Wrapper.restore "myrrd.xml", "myrrd.rrd"
+
+ # Tuning a rrd file
+ RRD::Wrapper.tune "myrrd.rrd", "--minimum", "memory:5"
+
+ # Updating rrd with a new value
+ RRD::Wrapper.update "myrrd.rrd", "N:500000000"
+
+
# Getting the error happened
puts RRD::Wrapper.error
+Bang methods raise exception on error.
+
# Throwing the error if happens
RRD::Wrapper.fetch! "myrrd.rrd", "WRONG FUNCTION"
View
20 lib/rrd/wrapper.rb
@@ -159,6 +159,13 @@ def last(*args)
date
end
+ # Get the last entered data.
+ #
+ # Returns an array of 2 arrays (one with datasource names and other with the values):
+ #
+ # [["time" , "cpu", "memory"],
+ # [1266933900, "0.9", "253" ]]
+ #
def last_update(file)
update_time_ptr = empty_pointer
ds_count_ptr = empty_pointer
@@ -200,27 +207,20 @@ def update(*args)
rrd_update(args.size+1, argv) == 0
end
+ # Returns the error happened.
def error
rrd_get_error
end
+ # Clear the error message.
def clear_error
rrd_clear_error
end
def methods
super + BANG_METHODS
end
-=begin
- def respond_to?(method, include_private = false)
- super || BANG_METHODS.include?(method.to_sym)
- end
-
- def method_missing(method, *args)
- return bang($1, *args) if method.to_s =~ /^(.+)!$/ && BANG_METHODS.include?(method.to_sym)
- super
- end
-=end
+
def bang(method, *args, &block)
result = send(method, *args, &block)
raise error unless result

0 comments on commit 247f94a

Please sign in to comment.