summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 090e0fb)
raw | patch | inline | side by side (parent: 090e0fb)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 17 Jan 2007 23:35:01 +0000 (23:35 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 17 Jan 2007 23:35:01 +0000 (23:35 +0000) |
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@952 a5681a0c-68f1-0310-ab6d-d61299d08faa
netware/Makefile | patch | blob | history | |
src/rrd_lastupdate.c | [new file with mode: 0644] | patch | blob |
win32/Makefile | patch | blob | history |
diff --git a/netware/Makefile b/netware/Makefile
index df6a9b0694154b4e684028583d18ee2e6c85dce2..77fa960282d54a55571c403ea8b8445c700fc584 100644 (file)
--- a/netware/Makefile
+++ b/netware/Makefile
$(OBJDIR)/rrd_hw.o \
$(OBJDIR)/rrd_info.o \
$(OBJDIR)/rrd_last.o \
+ $(OBJDIR)/rrd_lastupdate.o \
$(OBJDIR)/rrd_nan_inf.o \
$(OBJDIR)/rrd_open.o \
$(OBJDIR)/rrd_resize.o \
diff --git a/src/rrd_lastupdate.c b/src/rrd_lastupdate.c
--- /dev/null
+++ b/src/rrd_lastupdate.c
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * RRDtool 1.2.15 Copyright by Tobi Oetiker, 1997-2006
+ *****************************************************************************
+ * rrd_lastupdate Get the last datum entered for each DS
+ *****************************************************************************/
+
+#include "rrd_tool.h"
+#include "rrd_rpncalc.h"
+#include <stdarg.h>
+
+int
+rrd_lastupdate(int argc, char **argv, time_t *last_update,
+ unsigned long *ds_cnt, char ***ds_namv, char ***last_ds) {
+ unsigned long i=0;
+ char *filename;
+ FILE *in_file;
+ rrd_t rrd;
+
+ if(argc < 2){
+ rrd_set_error("please specify an rrd");
+ return -1;
+ }
+ filename = argv[1];
+
+ if(rrd_open(filename,&in_file,&rrd, RRD_READONLY)==-1){
+ return(-1);
+ }
+ fclose(in_file);
+
+ *last_update=rrd.live_head->last_up;
+ *ds_cnt = rrd.stat_head->ds_cnt;
+ if (((*ds_namv) =
+ (char **) malloc(rrd.stat_head->ds_cnt * sizeof(char*)))==NULL){
+ rrd_set_error("malloc fetch ds_namv array");
+ rrd_free(&rrd);
+ return(-1);
+ }
+
+ if (((*last_ds) =
+ (char **) malloc(rrd.stat_head->ds_cnt * sizeof(char*)))==NULL){
+ rrd_set_error("malloc fetch last_ds array");
+ rrd_free(&rrd);
+ free(*ds_namv);
+ return(-1);
+ }
+
+ for(i=0;i<rrd.stat_head->ds_cnt;i++){
+ (*ds_namv)[i] = sprintf_alloc("%s", rrd.ds_def[i].ds_nam);
+ (*last_ds)[i] = sprintf_alloc("%s", rrd.pdp_prep[i].last_ds);
+ }
+
+ rrd_free(&rrd);
+ return(0);
+}
diff --git a/win32/Makefile b/win32/Makefile
index 5c086a580d058bead5052a714a492e089f032e4a..fada2c3363be36c52bd41e2a4cdb325588ba6bf8 100644 (file)
--- a/win32/Makefile
+++ b/win32/Makefile
$(OBJDIR)/rrd_hw.o \
$(OBJDIR)/rrd_info.o \
$(OBJDIR)/rrd_last.o \
+ $(OBJDIR)/rrd_lastupdate.o \
$(OBJDIR)/rrd_nan_inf.o \
$(OBJDIR)/rrd_open.o \
$(OBJDIR)/rrd_resize.o \