OpenNMS API 1.2.9

## org.opennms.netmgt.rrd
Class RrdUtils

    java.lang.Object
      org.opennms.netmgt.rrd.RrdUtils

public class RrdUtils
extends java.lang.Object

Provides static methods for interacting with round robin files. Supports JNI and JRobin based files and provides queuing for managing differences in collection speed and disk write speed. This behaviour is implemented using the Strategy pattern with a different RrdStrategy for JRobin and JNI as well as a Strategy that provides Queueing on top of either one. The following System properties select which strategy is in use.

      org.opennms.rrd.usejni: (defaults to true)
       true - use the existing RRDTool code via the JNI interface @see JniRrdStrategy
       false - use the pure java JRobin interface @see JRobinRrdStrategy

      org.opennms.rrd.usequeue: (defaults to true)
        use the queueing that allows collection to occur even though the disks are
        keeping up. @see QueuingRrdStrategy

Field Summary
`private static RrdStrategy` `m_rrdStrategy`
`private static boolean` `USE_JNI`
`private static boolean` `USE_QUEUE`

Constructor Summary
`RrdUtils()`

Method Summary
`static java.io.InputStream` `createGraph(java.lang.String command, java.io.File workDir)` Creates an InputStream representing the bytes of a graph created from round robin data.
`static boolean` `createRRD(java.lang.String creator, java.lang.String directory, java.lang.String dsName, int step, java.lang.String dsType, int dsHeartbeat, java.lang.String dsMin, java.lang.String dsMax, java.util.List rraList)` Create a round robin database file.
`private static void` `createStrategy()` Create the appropriate RrdStrategy object based on the configuration
`static java.lang.Double` `fetchLastValue(java.lang.String rrdFile, int interval)` This method issues an round robin fetch command to retrieve the last value of the datasource stored in the specified RRD file.
`static java.lang.Double` `fetchLastValueInRange(java.lang.String rrdFile, int interval, int range)` This method issues an round robing fetch command to retrieve the last value of the datasource stored in the specified RRD file within given tolerance (which should be a multiple of the RRD interval).
`private static RrdStrategy` `getStrategy()`
`static void` `graphicsInitialize()`
`static void` `initialize()` Initializes the underlying round robin system and sets up the appropriate strategy.
`static void` `updateRRD(java.lang.String owner, java.lang.String repositoryDir, java.lang.String dsName, java.lang.String val)` Add a datapoint to a round robin database.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### USE_QUEUE

    private static final boolean USE_QUEUE

### USE_JNI

    private static final boolean USE_JNI

### m_rrdStrategy

    private static RrdStrategy m_rrdStrategy

Constructor Detail

### RrdUtils

    public RrdUtils()

Method Detail

### getStrategy

    private static RrdStrategy getStrategy()
                                    throws RrdException

  Throws:
    `RrdException`

### initialize

    public static void initialize()
                           throws RrdException

  Initializes the underlying round robin system and sets up the appropriate strategy. The strategies are currently selected using System properties. This creates the appropriate RrdStrategy and calls its initialize method

  Throws:
    `RrdException`

### graphicsInitialize

    public static void graphicsInitialize()
                                   throws RrdException

  Throws:
    `RrdException`

### createStrategy

    private static void createStrategy()

  Create the appropriate RrdStrategy object based on the configuration

### createRRD

    public static boolean createRRD(java.lang.String creator,
                                    java.lang.String directory,
                                    java.lang.String dsName,
                                    int step,
                                    java.lang.String dsType,
                                    int dsHeartbeat,
                                    java.lang.String dsMin,
                                    java.lang.String dsMax,
                                    java.util.List rraList)
                             throws RrdException

  Create a round robin database file. See the man page for rrdtool create for definitions of each of these.

  Parameters:
    `creator` - - A string representing who is creating this file for use in log msgs
    `directory` - - The directory to create the file in
    `dsName` - - The datasource name for use in the round robin database
    `step` - - the step for the database
    `dsType` - - the type for the datasource
    `dsHeartbeat` - - the heartbeat for the datasouce
    `dsMin` - - the minimum allowable value for the datasource
    `dsMax` - - the maximum allowable value for the datasouce
    `rraList` - - a List of the round robin archives to create in the database
  Returns:
    true if the file was actually created, false otherwise
  Throws:
    `RrdException`

### updateRRD

    public static void updateRRD(java.lang.String owner,
                                 java.lang.String repositoryDir,
                                 java.lang.String dsName,
                                 java.lang.String val)
                          throws RrdException

  Add a datapoint to a round robin database.

  Parameters:
    `owner` - the owner of the file. This is used in log messages
    `repositoryDir` - the directory the file resides in
    `dsName` - the datasource name for file. (Also becames the basename of the file)
    `val` - the value to be stored. This should be a string representation of a number
  Throws:
    `RrdException`

### fetchLastValue

    public static java.lang.Double fetchLastValue(java.lang.String rrdFile,
                                                  int interval)
                                           throws java.lang.NumberFormatException,
                                                  RrdException

  This method issues an round robin fetch command to retrieve the last value of the datasource stored in the specified RRD file. The retrieved value returned to the caller. NOTE: This method assumes that each RRD file contains a single datasource.

  Parameters:
    `rrdFile` - RRD file from which to fetch the data.
    `interval` - Thresholding interval (should equal RRD step size)
  Returns:
    Retrived datasource value as a java.lang.Double
  Throws:
    `java.lang.NumberFormatException` - if the retrieved value fails to convert to a double
    `RrdException`

### fetchLastValueInRange

    public static java.lang.Double fetchLastValueInRange(java.lang.String rrdFile,
                                                         int interval,
                                                         int range)
                                                  throws java.lang.NumberFormatException,
                                                         RrdException

  This method issues an round robing fetch command to retrieve the last value of the datasource stored in the specified RRD file within given tolerance (which should be a multiple of the RRD interval). This is useful If you are not entirely sure when an RRD might have been updated, but you want to retrieve the last value. NOTE: This method assumes that each RRD file contains a single datasource.

  Parameters:
    `rrdFile` - RRD file from which to fetch the data.
    `interval` - Thresholding interval (should equal RRD step size)
  Returns:
    Retrived datasource value as a java.lang.Double
  Throws:
    `java.lang.NumberFormatException` - if the retrieved value fails to convert to a double
    `RrdException`

### createGraph

    public static java.io.InputStream createGraph(java.lang.String command,
                                                  java.io.File workDir)
                                           throws java.io.IOException,
                                                  RrdException

  Creates an InputStream representing the bytes of a graph created from round robin data. It accepts an rrdtool graph command. The underlying implementation converts this command to a format appropriate for it .

  Parameters:
    `command` - the command needed to create the graph
    `workDir` - the directory that all referenced files are relative to
  Returns:
    an input stream representing the bytes of a graph image as a PNG file
  Throws:
    `java.io.IOException` - if an IOError occurs
    `RrdException` - if an RRD error occurs

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.