org.jrobin.cmd
Class RrdCommander

java.lang.Object
  extended by org.jrobin.cmd.RrdCommander

public class RrdCommander
extends Object

Class to be used to execute various RRDTool commands (original syntax of RRDTool 1.0.x must be used). Currently supported commands are CREATE, UPDATE, LAST, FETCH, DUMP, RESTORE, XPORT, GRAPH, TUNE, INFO


Constructor Summary
RrdCommander()
           
 
Method Summary
static Object execute(String command)
          Executes single RRDTool command.
static boolean isRrdDbPoolUsed()
          Checks if the class uses RrdDbPool internally while executing RRDTool commands.
static boolean isStandardOutUsed()
          Checks if the output from any RRDTool command will be visible on the standard output device (console).
static void main(String[] args)
          A small demo which allows you to pass arbitrary RRDTool commands to JRobin
static void setRrdDbPoolUsed(boolean rrdDbPoolUsed)
          Forces or prohibits RrdDbPool usage internally while executing RRDTool commands
static void setStandardOutUsed(boolean standardOutUsed)
          Method used to control access to stdout (System.out, console) for all RRDTool commands.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RrdCommander

public RrdCommander()
Method Detail

isStandardOutUsed

public static boolean isStandardOutUsed()
Checks if the output from any RRDTool command will be visible on the standard output device (console). Default setting is true.

Returns:
true, if the output will be visible on the standard output device; false, otherwise.

setStandardOutUsed

public static void setStandardOutUsed(boolean standardOutUsed)
Method used to control access to stdout (System.out, console) for all RRDTool commands. By default, all RRDTool commands are allowed to print results to stdout, in a form used by RRDTool.

Parameters:
standardOutUsed - true if the output should be visible on the standard output device, false otherwise.

isRrdDbPoolUsed

public static boolean isRrdDbPoolUsed()
Checks if the class uses RrdDbPool internally while executing RRDTool commands.

Returns:
true if the pool is used, false otherwise

setRrdDbPoolUsed

public static void setRrdDbPoolUsed(boolean rrdDbPoolUsed)
Forces or prohibits RrdDbPool usage internally while executing RRDTool commands

Parameters:
rrdDbPoolUsed - true, to force pool usage, false otherwise.

execute

public static Object execute(String command)
                      throws IOException,
                             RrdException
Executes single RRDTool command. The command string should start with some well known RRDTool command word (create, update, fetch, graph...)

Parameters:
command - RRDTool command like:

                create test.rrd --start "noon yesterday" --step 300 DS:x:GAUGE:600:U:U RRA:AVERAGE:0.5:5:1000
                update test.rrd N:1000
                last test.rrd
                ...
                
Returns:
Result of specific RRDTool command. It is guaranteed that the result of any successfully executed command will be always different from null. Unsuccessfully executed commands will always throw an exception, so you need not check for null results.

Exact type of the result depends from the type of executed RRDTool command:

  • create: returns java.lang.String containing path to the newly created RRD file.
  • last: returns java.lang.Long representing timestamp of the last update.
  • update: returns java.lang.Long representing timestamp of the last update.
  • dump: returns (very long) java.lang.String representing the content of a RRD file in XML format.
  • fetch: returns FetchData object representing fetched data.
  • restore: returns path to the restored RRD file.
  • xport: returns java.lang.String containing exported data
  • graph: returns RrdGraphInfo object containing graph info
  • tune: returns path to the tuned RRD file
Throws:
IOException - thrown in case of I/O error
RrdException - thrown for all other errors (parsing errors, unknown RRDTool syntax/command/option, internal RRD errors...)

main

public static void main(String[] args)
                 throws IOException
A small demo which allows you to pass arbitrary RRDTool commands to JRobin

Parameters:
args - Not used
Throws:
IOException


Copyright 2003-2008. All Rights Reserved.