<commit_before>= Introduction 

rrd-ffi is a gem for using rrd actions in your ruby code.

You may use it in the raw format, as many rrd libs in languages like perl or python, or you can use it through the dsl we provide.

rrd-ffi uses ffi to wrap the librrd C bindings, not system calls.

IMPORTANT: You need librrd installed in your system for this gem to work

= Basics 

Here's what you need to know before starting.

== Installation 

=== Notes

To install rrd-ffi, you will need to have librrd in your system.

Then, run <tt>sudo gem install rrd-ffi</tt>

If you are using Mac Ports you will have problems, so add the following to your .profile|.bashrc|.bash_profile file:

  export RRD_LIB=/opt/local/lib/librrd.dylib

or

  export LD_LIBRARY_PATH=/opt/local/lib

If you are not using MAC OS and still have problems, export the RRD_PATH variable with the path to your librrd file.

=== Installing librrd

Debian/Ubuntu: <tt>apt-get install librrd-dev</tt>

Fedora/Red Hat: <tt>yum install rrdtool-devel</tt>

Mac: <tt>port install rrdtool</tt>

== Example Usage
  require "rrd"
  rrd = RRD::Base.new("myrrd.rrd")
  # Restoring a rrd file from xml
  rrd.restore("myrrd.xml")

  # Fetching data from rrd
  rrd.fetch(:average).each {|line| puts line.inspect}

  # Collecting information from rrd
  puts rrd.info.to_yaml

  # Updating rrd (this rrd example has 3 datasources)
  rrd.update Time.now, 500, nil, 30<commit_msg>Updated readme with restore overwrite option<commit_after>= Introduction 

rrd-ffi is a gem for using rrd actions in your ruby code.

You may use it in the raw format, as many rrd libs in languages like perl or python, or you can use it through the dsl we provide.

rrd-ffi uses ffi to wrap the librrd C bindings, not system calls.

IMPORTANT: You need librrd installed in your system for this gem to work

= Basics 

Here's what you need to know before starting.

== Installation 

=== Notes

To install rrd-ffi, you will need to have librrd in your system.

Then, run <tt>sudo gem install rrd-ffi</tt>

If you are using Mac Ports you will have problems, so add the following to your .profile|.bashrc|.bash_profile file:

  export RRD_LIB=/opt/local/lib/librrd.dylib

or

  export LD_LIBRARY_PATH=/opt/local/lib

If you are not using MAC OS and still have problems, export the RRD_PATH variable with the path to your librrd file.

=== Installing librrd

Debian/Ubuntu: <tt>apt-get install librrd-dev</tt>

Fedora/Red Hat: <tt>yum install rrdtool-devel</tt>

Mac: <tt>port install rrdtool</tt>

== Example Usage
  require "rrd"
  rrd = RRD::Base.new("myrrd.rrd")
  # Restoring a rrd file from xml
  rrd.restore("myrrd.xml", :overwrite => true)

  # Fetching data from rrd
  rrd.fetch(:average).each {|line| puts line.inspect}

  # Collecting information from rrd
  puts rrd.info.to_yaml

  # Updating rrd (this rrd example has 3 datasources)
  rrd.update Time.now, 500, nil, 30
{'fraction_non_alphanumeric': 0.0826730967964175, 'fraction_numerical': 0.004133654839820875, 'mean_word_length': 3.831946755407654, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7405953', 'n_tokens_mistral': 1044, 'n_tokens_neox': 968, 'n_words': 398}