Update of /cvsroot/jrobin/src/org/jrobin/core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17853/org/jrobin/core
Modified Files:
RrdDb.java
Log Message:
Added two methods to fetch last datasource values from a RrdDb object
Index: RrdDb.java
===================================================================
RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDb.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** RrdDb.java 19 Oct 2004 10:14:02 -0000 1.31
--- RrdDb.java 21 Oct 2004 08:05:25 -0000 1.32
***************
*** 1088,1096 ****
}
public static void main(String[] args) {
- System.out.println("JRobin base directory: " + Util.getJRobinHomeDirectory());
System.out.println("JRobin Java Library :: RRDTool choice for the Java world");
! System.out.println("http://www.jrobin.org");
! System.out.println("(C) 2004 Sasa Markovic & Arne Vandamme");
}
--- 1088,1125 ----
}
+ /**
+ * Returns an array of last datasource values. The first value in the array corresponds
+ * to the first datasource defined in the RrdDb and so on.
+ * @return Array of last datasource values
+ * @throws IOException Thrown in case of I/O error
+ */
+ public synchronized double[] getLastDatasourceValues() throws IOException {
+ double[] values = new double[datasources.length];
+ for(int i = 0; i < values.length; i++) {
+ values[i] = datasources[i].getLastValue();
+ }
+ return values;
+ }
+
+ /**
+ * Returns the last stored value for the given datasource.
+ * @param dsName Datasource name
+ * @return Last stored value for the given datasource
+ * @throws IOException Thrown in case of I/O error
+ * @throws RrdException Thrown if no datasource in this RrdDb matches the given datasource name
+ */
+ public synchronized double getLastDatasourceValue(String dsName) throws IOException, RrdException {
+ int dsIndex = getDsIndex(dsName);
+ return datasources[dsIndex].getLastValue();
+ }
+
public static void main(String[] args) {
System.out.println("JRobin Java Library :: RRDTool choice for the Java world");
! System.out.println("==================================================================");
! System.out.println("JRobin base directory: " + Util.getJRobinHomeDirectory());
! System.out.println("Current timestamp: " + Util.getTime());
! System.out.println("------------------------------------------------------------------");
! System.out.println("For the latest information visit: http://www.jrobin.org");
! System.out.println("(C) 2003, 2004 Sasa Markovic & Arne Vandamme. All rights reserved.");
}
|