summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 13b1259)
raw | patch | inline | side by side (parent: 13b1259)
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) |
program/netware/Makefile | patch | blob | history | |
program/src/rrd_lastupdate.c | [new file with mode: 0644] | patch | blob |
program/win32/Makefile | patch | blob | history |
index df6a9b0694154b4e684028583d18ee2e6c85dce2..77fa960282d54a55571c403ea8b8445c700fc584 100644 (file)
--- a/program/netware/Makefile
+++ b/program/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/program/src/rrd_lastupdate.c b/program/src/rrd_lastupdate.c
--- /dev/null
@@ -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/program/win32/Makefile b/program/win32/Makefile
index 5c086a580d058bead5052a714a492e089f032e4a..fada2c3363be36c52bd41e2a4cdb325588ba6bf8 100644 (file)
--- a/program/win32/Makefile
+++ b/program/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 \