[PATCH] Add create and info to rrdupdate
Sven-Göran Bergh <[email protected]> Fri, 10 Aug 2012 11:46:06 -0700 (PDT)
| Newsgroups | gmane.comp.db.rrdtool.devel |
|---|---|
| Message-ID | <[email protected]> |
Dear List, we have the need to incorporate generation/updates of RRD files in an embedded environment. However, there are a few dependencies that ruin our plan, most notably libxml2 and libglib. Even a minimal build (--disable-*) still has these dependencies. What we need is just to create and update RRDs. All graphing is interactive and handled in the web GUI. I have also seen similar needs expressed regarding restricted environments. The rrdupdate standalone utility is a good start, but it lacks the ability to create RRDs. The proposed patch (attached) adds two features to rrdupdate: info and create. This is done by invoking the binary with different names (ala BusyBox). For this, two symbolic links, rrdcreate and rrdinfo, are used. The size of a stripped rrdupdate is increased from 80kB to 88kB (libc on i386), but that is a small sacrifice compared with rrdtool + dependencies (minimal build >2.0MB). My auto[voodoo] skills are limited and so is my insight in the rrdtool code, so any comments are most welcome. Brgds /S-G _______________________________________________ rrd-developers mailing list [email protected] https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers
rrdupdate-with-create-info.patch
(application/octet-stream, 2.8 KB)
diff -urN rrdtool-1.4.7.002296.orig/src/Makefile.am rrdtool-1.4.7.002296.mod/src/Makefile.am
--- rrdtool-1.4.7.002296.orig/src/Makefile.am 2011-11-22 13:46:15.000000000 +0100
+++ rrdtool-1.4.7.002296.mod/src/Makefile.am 2012-08-10 14:28:23.140120583 +0200
@@ -16,6 +16,8 @@
## no including this by default @WERROR@
UPD_C_FILES = \
+ rrd_create.c \
+ hash_32.c \
rrd_parsetime.c \
rrd_hw.c \
rrd_hw_math.c \
@@ -32,8 +34,6 @@
rrd_update.c
RRD_C_FILES = \
- rrd_create.c \
- hash_32.c \
rrd_version.c \
rrd_last.c \
rrd_lastupdate.c \
@@ -129,3 +129,6 @@
librrd.sym: librrd.sym.in
$(AM_V_GEN)grep -v LIBC_HAS_GETOPT_LONG librrd.sym.in >$@
+
+install-exec-hook:
+ (cd $(DESTDIR)$(bindir) && $(LN_S) rrdupdate rrdcreate && $(LN_S) rrdupdate rrdinfo)
diff -urN rrdtool-1.4.7.002296.orig/src/rrdupdate.c rrdtool-1.4.7.002296.mod/src/rrdupdate.c
--- rrdtool-1.4.7.002296.orig/src/rrdupdate.c 2012-01-24 11:08:48.000000000 +0100
+++ rrdtool-1.4.7.002296.mod/src/rrdupdate.c 2012-08-10 14:28:34.349115743 +0200
@@ -15,20 +15,46 @@
#endif
#include "rrd.h"
+#include "plbasename.h"
int main(
int argc,
char **argv)
{
- rrd_update(argc, argv);
+ char *name=basename(argv[0]);
+ rrd_info_t *info;
+
+ if (!strcmp(name, "rrdcreate"))
+ rrd_create(argc, argv);
+ else if (!strcmp(name, "rrdinfo")) {
+ info=rrd_info(argc, argv);
+ rrd_info_print(info);
+ rrd_info_free(info);
+ }
+ else
+ rrd_update(argc, argv);
+
if (rrd_test_error()) {
printf("RRDtool " PACKAGE_VERSION
- " Copyright by Tobi Oetiker, 1997-2010\n\n"
- "Usage: rrdupdate filename\n"
- "\t\t\t[--template|-t ds-name:ds-name:...]\n"
- "\t\t\ttime|N:value[:value...]\n\n"
- "\t\t\tat-time@value[:value...]\n\n"
- "\t\t\t[ time:value[:value...] ..]\n\n");
+ " Copyright by Tobi Oetiker, 1997-2010\n\n");
+ if (!strcmp(name, "rrdcreate")) {
+ printf("Usage: rrdcreate <filename>\n"
+ "\t\t\t[--start|-b start time]\n"
+ "\t\t\t[--step|-s step]\n"
+ "\t\t\t[--no-overwrite]\n"
+ "\t\t\t[DS:ds-name:DST:dst arguments]\n"
+ "\t\t\t[RRA:CF:cf arguments]\n\n");
+ }
+ else if (!strcmp(name, "rrdinfo")) {
+ printf("Usage: rrdinfo <filename>\n");
+ }
+ else {
+ printf("Usage: rrdupdate <filename>\n"
+ "\t\t\t[--template|-t ds-name[:ds-name]...]\n"
+ "\t\t\ttime|N:value[:value...]\n\n"
+ "\t\t\tat-time@value[:value...]\n\n"
+ "\t\t\t[ time:value[:value...] ..]\n\n");
+ }
printf("ERROR: %s\n", rrd_get_error());
rrd_clear_error();