summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a0ec2de)
raw | patch | inline | side by side (parent: a0ec2de)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 17 Jan 2007 21:31:23 +0000 (21:31 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 17 Jan 2007 21:31:23 +0000 (21:31 +0000) |
get stored even for ABSOLUTE and GAUGE data sources ... -- andy.riebs hp.com
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@951 a5681a0c-68f1-0310-ab6d-d61299d08faa
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@951 a5681a0c-68f1-0310-ab6d-d61299d08faa
diff --git a/program/acinclude.m4 b/program/acinclude.m4
index d0f8c0e81670e1a34f98dd9cadda9ec9d8ff1fb7..b71fe8e8058dd75b7414fcbcf3b37b18739c8ed1 100644 (file)
--- a/program/acinclude.m4
+++ b/program/acinclude.m4
])
+dnl ---------------------------------------------------------------------------
+dnl CF_DISABLE_ECHO version: 10 updated: 2003/04/17 22:27:11
+dnl ---------------
+dnl stolen from xterm aclocal.m4
+dnl
+dnl You can always use "make -n" to see the actual options, but it's hard to
+dnl pick out/analyze warning messages when the compile-line is long.
+dnl
+dnl Sets:
+dnl ECHO_LT - symbol to control if libtool is verbose
+dnl ECHO_LD - symbol to prefix "cc -o" lines
+dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
+dnl SHOW_CC - symbol to put before explicit "cc -c" lines
+dnl ECHO_CC - symbol to put before any "cc" line
+dnl
+AC_DEFUN([CF_DISABLE_ECHO],[
+AC_MSG_CHECKING(if you want to see long compiling messages)
+CF_ARG_DISABLE(echo,
+ [ --disable-echo display "compiling" commands],
+ [
+ ECHO_LT='--silent'
+ ECHO_LD='@echo linking [$]@;'
+ RULE_CC=' @echo compiling [$]<'
+ SHOW_CC=' @echo compiling [$]@'
+ ECHO_CC='@'
+],[
+ ECHO_LT=''
+ ECHO_LD=''
+ RULE_CC='# compiling'
+ SHOW_CC='# compiling'
+ ECHO_CC=''
+])
+AC_MSG_RESULT($enableval)
+AC_SUBST(ECHO_LT)
+AC_SUBST(ECHO_LD)
+AC_SUBST(RULE_CC)
+AC_SUBST(SHOW_CC)
+AC_SUBST(ECHO_CC)
+])dnl
index e9cff801294761d6c2ace0b6f12f79225a5c0b53..33ceb15f3ca7116d2fc3bd92ab8e970d1e14419c 100644 (file)
@@ -308,7 +308,42 @@ Rrd_Update(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *ar
return TCL_OK;
}
-
+static int
+Rrd_Lastupdate(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
+ {
+ time_t last_update;
+ char **argv2;
+ char **ds_namv;
+ char **last_ds;
+ char s[30];
+ Tcl_Obj *listPtr;
+ unsigned long ds_cnt, i;
+
+ argv2 = getopt_init(argc, argv);
+ if (rrd_lastupdate(argc-1, argv2, &last_update,
+ &ds_cnt, &ds_namv, &last_ds) == 0) {
+ listPtr = Tcl_GetObjResult(interp);
+ for (i=0; i<ds_cnt; i++) {
+ sprintf(s, " %28s", ds_namv[i]);
+ Tcl_ListObjAppendElement(interp, listPtr,
+ Tcl_NewStringObj(s, -1));
+ sprintf(s, "\n\n%10lu:", last_update);
+ Tcl_ListObjAppendElement(interp, listPtr,
+ Tcl_NewStringObj(s, -1));
+ for (i=0; i<ds_cnt; i++) {
+ sprintf(s, " %s", last_ds[i]);
+ Tcl_ListObjAppendElement(interp, listPtr,
+ Tcl_NewStringObj(s, -1));
+ free(last_ds[i]);
+ free(ds_namv[i]);
+ }
+ sprintf(s, "\n");
+ Tcl_ListObjAppendElement(interp, listPtr,
+ Tcl_NewStringObj(s, -1));
+ free(last_ds);
+ free(ds_namv);
+ }
+}
static int
Rrd_Fetch(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
} CmdInfo;
static CmdInfo rrdCmds[] = {
- { "Rrd::create", Rrd_Create, 1 }, /* Thread-safe version */
- { "Rrd::dump", Rrd_Dump, 0 }, /* Thread-safe version */
- { "Rrd::last", Rrd_Last, 0 }, /* Thread-safe version */
- { "Rrd::update", Rrd_Update, 1 }, /* Thread-safe version */
- { "Rrd::fetch", Rrd_Fetch, 0 },
- { "Rrd::graph", Rrd_Graph, 1 }, /* Due to RRD's API, a safe
+ { "Rrd::create", Rrd_Create, 1 }, /* Thread-safe version */
+ { "Rrd::dump", Rrd_Dump, 0 }, /* Thread-safe version */
+ { "Rrd::last", Rrd_Last, 0 }, /* Thread-safe version */
+ { "Rrd::lastupdate", Rrd_Lastupdate, 0 }, /* Thread-safe version */
+ { "Rrd::update", Rrd_Update, 1 }, /* Thread-safe version */
+ { "Rrd::fetch", Rrd_Fetch, 0 },
+ { "Rrd::graph", Rrd_Graph, 1 }, /* Due to RRD's API, a safe
interpreter cannot create
a graph since it writes to
a filename supplied by the
caller */
- { "Rrd::tune", Rrd_Tune, 1 },
- { "Rrd::resize", Rrd_Resize, 1 },
- { "Rrd::restore", Rrd_Restore, 1 },
- { (char *) NULL, (Tcl_CmdProc *) NULL, 0 }
+ { "Rrd::tune", Rrd_Tune, 1 },
+ { "Rrd::resize", Rrd_Resize, 1 },
+ { "Rrd::restore", Rrd_Restore, 1 },
+ { (char *) NULL, (Tcl_CmdProc *) NULL, 0 }
};
index 19f5730dce545d3e80d2e19b6c34217bfeaba7f0..70f456c2a5a4f82db60c62dc601f06fc2a1e4c6b 100644 (file)
--- a/program/doc/Makefile.am
+++ b/program/doc/Makefile.am
cdeftutorial.pod rrdfetch.pod rrdgraph_graph.pod rrdthreads.pod rrdxport.pod \
rpntutorial.pod rrdfirst.pod rrdgraph_rpn.pod rrdtool.pod \
rrd-beginners.pod rrdinfo.pod rrdtune.pod rrdbuild.pod \
- rrdcgi.pod rrdgraph.pod rrdlast.pod \
+ rrdcgi.pod rrdgraph.pod rrdlast.pod rrdlastupdate.pod \
rrdcreate.pod rrdgraph_data.pod rrdresize.pod rrdtutorial.pod
index 1a1c7ed7c5aaebf8da84d46d00ea3c728d818618..1f5fe0c713b3d17c8cbd381433a4a5d8776d7b22 100644 (file)
--- a/program/src/Makefile.am
+++ b/program/src/Makefile.am
rrd_graph.c \
rrd_graph_helper.c \
rrd_last.c \
+ rrd_lastupdate.c \
rrd_first.c \
rrd_resize.c \
rrd_restore.c \
diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c
index f393f860d6f8749f69550b2e8df85c81f754cf4f..72f8fe8903ff32b1cc505aed3ea743e6c5c765ed 100644 (file)
--- a/program/src/rrd_tool.c
+++ b/program/src/rrd_tool.c
char help_list[] =
"Valid commands: create, update, updatev, graph, dump, restore,\n"
- "\t\tlast, first, info, fetch, tune, resize, xport\n\n";
+ "\t\tlast, lastupdate, first, info, fetch, tune,\n"
+ " resize, xport\n\n";
char help_listremote[] =
"Valid remote commands: quit, ls, cd, mkdir, pwd\n\n";
"* last - show last update time for RRD\n\n"
"\trrdtool last filename.rrd\n\n";
+ char help_lastupdate[] =
+ "* lastupdate - returns the most recent datum stored for\n"
+ " each DS in an RRD\n\n"
+ "\trrdtool lastupdate filename.rrd\n\n";
+
char help_first[] =
"* first - show first update time for RRA within an RRD\n\n"
"\trrdtool first filename.rrd [--rraindex number]\n\n";
"For more information read the RRD manpages\n\n";
- enum { C_NONE, C_CREATE, C_DUMP, C_INFO, C_RESTORE, C_LAST, C_FIRST,
- C_UPDATE, C_FETCH, C_GRAPH, C_TUNE, C_RESIZE, C_XPORT,
- C_QUIT, C_LS, C_CD, C_MKDIR, C_PWD, C_UPDATEV };
+ enum { C_NONE, C_CREATE, C_DUMP, C_INFO, C_RESTORE, C_LAST,
+ C_LASTUPDATE, C_FIRST, C_UPDATE, C_FETCH, C_GRAPH, C_TUNE,
+ C_RESIZE, C_XPORT, C_QUIT, C_LS, C_CD, C_MKDIR, C_PWD,
+ C_UPDATEV };
int help_cmd = C_NONE;
help_cmd = C_RESTORE;
else if (!strcmp(cmd,"last"))
help_cmd = C_LAST;
+ else if (!strcmp(cmd,"lastupdate"))
+ help_cmd = C_LASTUPDATE;
else if (!strcmp(cmd,"first"))
help_cmd = C_FIRST;
else if (!strcmp(cmd,"update"))
case C_LAST:
fputs(help_last, stdout);
break;
+ case C_LASTUPDATE:
+ fputs(help_lastupdate, stdout);
+ break;
case C_FIRST:
fputs(help_first, stdout);
break;
}
free(data);
}
-
+
else if (strcmp("--version", argv[1]) == 0 ||
strcmp("version", argv[1]) == 0 ||
strcmp("v", argv[1]) == 0 ||
rrd_resize(argc-1, &argv[1]);
else if (strcmp("last", argv[1]) == 0)
printf("%ld\n",rrd_last(argc-1, &argv[1]));
- else if (strcmp("first", argv[1]) == 0)
+ else if (strcmp("lastupdate", argv[1]) == 0) {
+ time_t last_update;
+ char **ds_namv;
+ char **last_ds;
+ unsigned long ds_cnt,
+ i;
+ if (rrd_lastupdate(argc-1, &argv[1], &last_update,
+ &ds_cnt, &ds_namv, &last_ds) == 0) {
+ for (i=0; i<ds_cnt; i++)
+ printf(" %s", ds_namv[i]);
+ printf("\n\n");
+ printf("%10lu:", last_update);
+ for (i=0; i<ds_cnt; i++) {
+ printf(" %s", last_ds[i]);
+ free(last_ds[i]);
+ free(ds_namv[i]);
+ }
+ printf("\n");
+ free(last_ds);
+ free(ds_namv);
+ }
+ } else if (strcmp("first", argv[1]) == 0)
printf("%ld\n",rrd_first(argc-1, &argv[1]));
else if (strcmp("update", argv[1]) == 0)
rrd_update(argc-1, &argv[1]);
diff --git a/program/src/rrd_tool.h b/program/src/rrd_tool.h
index bb96194feaee7d357efe7dec6833f5ce1779ca73..df6a5a96c26fe3efd13b94682679f033ec3c67a0 100644 (file)
--- a/program/src/rrd_tool.h
+++ b/program/src/rrd_tool.h
} info_t;
info_t *rrd_info(int, char **);
+int rrd_lastupdate(int argc, char **argv, time_t *last_update,
+ unsigned long *ds_cnt, char ***ds_namv, char ***last_ds);
info_t *rrd_update_v(int, char **);
char * sprintf_alloc(char *, ...);
info_t *info_push(info_t *, char *, enum info_type, infoval);
index 0f32121e35094bab9b02a760f7eead04e2c8e5ec..a66f14e4121962eb7c61b504a81d3b72cdb6c620 100644 (file)
--- a/program/src/rrd_update.c
+++ b/program/src/rrd_update.c
dst_idx= dst_conv(rrd.ds_def[i].dst);
/* make sure we do not build diffs with old last_ds values */
- if(rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt < interval
- && ( dst_idx == DST_COUNTER || dst_idx == DST_DERIVE)){
+ if(rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt < interval) {
strncpy(rrd.pdp_prep[i].last_ds,"U",LAST_DS_LEN-1);
rrd.pdp_prep[i].last_ds[LAST_DS_LEN-1]='\0';
}
rrd.pdp_prep[i].last_ds,
updvals[i+1], pdp_new[i]);
#endif
- if(dst_idx == DST_COUNTER || dst_idx == DST_DERIVE){
- strncpy(rrd.pdp_prep[i].last_ds,
- updvals[i+1],LAST_DS_LEN-1);
- rrd.pdp_prep[i].last_ds[LAST_DS_LEN-1]='\0';
- }
+ strncpy(rrd.pdp_prep[i].last_ds, updvals[i+1],LAST_DS_LEN-1);
+ rrd.pdp_prep[i].last_ds[LAST_DS_LEN-1]='\0';
}
/* break out of the argument parsing loop if the error_string is set */
if (rrd_test_error()){