sub end ();
sub read ();
-$VERSION=1.3000;
+$VERSION=1.3001;
sub start ($){
croak "rrdtool is already running"
require DynaLoader;
-$VERSION=1.3000;
+$VERSION=1.3001;
bootstrap RRDs $VERSION;
$lastupdate = RRDs::last ...
-B<RRDs::graph> returns an pointer to an ARRAY containing the x-size and y-size of the
-created image and results of the PRINT arguments.
+B<RRDs::graph> returns an ARRAY containing the x-size and y-size of the
+created image and a pointer to an array with the results of the PRINT arguments.
- ($averages,$xsize,$ysize) = RRDs::graph ...
+ ($result_arr,$xsize,$ysize) = RRDs::graph ...
print "Imagesize: ${xsize}x${ysize}\n";
print "Averages: ", (join ", ", @$averages);
print "DS names: ", join (", ", @$names)."\n";
print "Data points: ", $#$data + 1, "\n";
print "Data:\n";
- foreach my $line (@$data) {
+ for my $line (@$data) {
print " ", scalar localtime($start), " ($start) ";
$start += $step;
- foreach my $val (@$line) {
+ for my $val (@$line) {
printf "%12.1f ", $val;
}
print "\n";
free(argv); \
if (rrd_test_error()) XSRETURN_UNDEF; \
hash = newHV(); \
+ save=data; \
while (data) { \
- save=data; \
/* the newSV will get copied by hv so we create it as a mortal \
to make sure it does not keep hanging round after the fact */ \
switch (data->type) { \
break; \
case RD_I_STR: \
hvs(newSVpv(data->value.u_str,0)); \
- rrd_freemem(data->value.u_str); \
break; \
case RD_I_BLO: \
hvs(newSVpv(data->value.u_blo.ptr,data->value.u_blo.size)); \
- rrd_freemem(data->value.u_blo.ptr); \
break; \
} \
- rrd_freemem(data->key); \
data = data->next; \
- rrd_freemem(save); \
- } \
- rrd_freemem(data); \
+ } \
+ rrd_info_free(save); \
RETVAL = newRV_noinc((SV*)hash);
/*
RETVAL
-void
+SV *
rrd_graph(...)
PROTOTYPE: @
PREINIT:
PUSHs(sv_2mortal(newSViv(xsize)));
PUSHs(sv_2mortal(newSViv(ysize)));
-void
+SV *
rrd_fetch(...)
PROTOTYPE: @
PREINIT:
PUSHs(sv_2mortal(newRV_noinc((SV*)names)));
PUSHs(sv_2mortal(newRV_noinc((SV*)retar)));
-void
+SV *
rrd_times(start, end)
char *start
char *end
RRD_CHECK_ERROR result = rb_hash_new();
+ p = data;
while (data) {
VALUE key = rb_str_new2(data->key);
break;
case RD_I_STR:
rb_hash_aset(result, key, rb_str_new2(data->value.u_str));
- rrd_freemem(data->value.u_str);
break;
case RD_I_BLO:
rb_hash_aset(result, key,
rb_str_new(data->value.u_blo.ptr,
data->value.u_blo.size));
- rrd_freemem(data->value.u_blo.ptr);
break;
}
- p = data;
data = data->next;
- rrd_freemem(p);
}
+ rrd_info_free(p);
return result;
}
VALUE self,
VALUE args)
{
- return rrd_infocall(rrd_info, args);
+ return rb_rrd_infocall(rrd_info, args);
}
VALUE rb_rrd_updatev(
VALUE self,
VALUE args)
{
- return rrd_infocall(rrd_update_v, args);
+ return rb_rrd_infocall(rrd_update_v, args);
}
VALUE rb_rrd_graphv(
VALUE self,
VALUE args)
{
- return rrd_infocall(rrd_graph_v, args);
+ return rb_rrd_infocall(rrd_graph_v, args);
}
dnl the official version number is
dnl a.b.c
-AC_INIT([rrdtool],[1.3.0])
+AC_INIT([rrdtool],[1.3.1])
dnl for testing a numberical version number comes handy
dnl the released version are
dnl a.bccc
dnl the devel versions will be something like
dnl a.b999yymmddhh
-NUMVERS=1.3000
+NUMVERS=1.3001
AC_SUBST(NUMVERS)
dnl for the linker to understand which version the library is compatible with
have_broken_isfinite=no],have_broken_isfinite=yes,[
case "${target}" in
hppa*-*-hpux*) have_broken_isfinite=yes ;;
+ sparc-sun-solaris2.8) have_broken_isfinite=yes ;;
*) have_broken_isfinite=no ;;
esac])
])
Once you have decided. Save the two locations into environment variables.
BUILD_DIR=/tmp/rrdbuild
- INSTALL_DIR=/usr/local/rrdtool-1.3.0
+ INSTALL_DIR=/usr/local/rrdtool-1.3.1
If your F</tmp> is mounted with the option noexec (RHEL seems todo that) you have to choose
Lets first assume you already have all the necessary libraries
pre-installed.
- wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.0.tar.gz
- gunzip -c rrdtool-1.3.0.tar.gz | tar xf -
- cd rrdtool-1.3.0
+ wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.1.tar.gz
+ gunzip -c rrdtool-1.3.1.tar.gz | tar xf -
+ cd rrdtool-1.3.1
./configure --prefix=$INSTALL_DIR && make && make install
Ok, this was very optimistic. This try will probably have ended with
tcl setups that would prevent rrdtool from building if they are included in
their current state.
- cd $BUILD_DIR/rrdtool-1.3.0
+ cd $BUILD_DIR/rrdtool-1.3.1
./configure --prefix=$INSTALL_DIR --disable-tcl --disable-python
$MAKE clean
$MAKE
Only generate the graph if the current graph is out of date or not existent.
Note, that only the image size will be returned, if you run with lazy even
-when using graphv.
+when using graphv and even when using PRINT.
[B<--daemon> I<address>]
C<A-Z, a-z, 0-9, -,_> and a maximum length of 255 characters.
When picking variable names, make sure you do not choose a name that is
-already taken by an RPN operator. A save bet it to use lowercase or
+already taken by an RPN operator. A safe bet it to use lowercase or
mixedcase names for variables since operators will always be in uppercase.
=head1 DEF
Summary: Round Robin Database Tool to store and display time-series data
Name: rrdtool
-Version: 1.3.0
+Version: 1.3.1
Release: 0.20%{?pre:.%{pre}}%{?dist}
License: GPLv2+ with exceptions
Group: Applications/Databases
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* pngsize.c determine the size of a PNG image
*****************************************************************************/
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrdlib.h Public header file for librrd
*****************************************************************************
#if defined(__GNUC__) && defined (RRD_EXPORT_DEPRECATED)
# define RRD_DEPRECATED __attribute__((deprecated))
#else
-# define RRD_DEPRECATED /**/
+# define RRD_DEPRECATED /**/
#endif
-
- void rrd_free (rrd_t *rrd)
- RRD_DEPRECATED;
- void rrd_init (rrd_t *rrd)
- RRD_DEPRECATED;
-
- rrd_file_t *rrd_open (const char *const file_name, rrd_t *rrd,
- unsigned rdwr)
- RRD_DEPRECATED;
-
- void rrd_dontneed (rrd_file_t *rrd_file, rrd_t *rrd)
- RRD_DEPRECATED;
- int rrd_close (rrd_file_t *rrd_file)
- RRD_DEPRECATED;
- ssize_t rrd_read (rrd_file_t *rrd_file, void *buf, size_t count)
- RRD_DEPRECATED;
- ssize_t rrd_write (rrd_file_t *rrd_file,
- const void *buf, size_t count)
- RRD_DEPRECATED;
- void rrd_flush (rrd_file_t *rrd_file)
- RRD_DEPRECATED;
- off_t rrd_seek (rrd_file_t *rrd_file, off_t off, int whence)
- RRD_DEPRECATED;
- off_t rrd_tell (rrd_file_t *rrd_file)
- RRD_DEPRECATED;
- int rrd_lock (rrd_file_t *file)
- RRD_DEPRECATED;
-#endif /* defined(_RRD_TOOL_H) || defined(RRD_EXPORT_DEPRECATED) */
+ void rrd_free(
+ rrd_t *rrd)
+ RRD_DEPRECATED;
+ void rrd_init(
+ rrd_t *rrd)
+ RRD_DEPRECATED;
+
+ rrd_file_t *rrd_open(
+ const char *const file_name,
+ rrd_t *rrd,
+ unsigned rdwr)
+ RRD_DEPRECATED;
+
+ void rrd_dontneed(
+ rrd_file_t *rrd_file,
+ rrd_t *rrd)
+ RRD_DEPRECATED;
+ int rrd_close(
+ rrd_file_t *rrd_file)
+ RRD_DEPRECATED;
+ ssize_t rrd_read(
+ rrd_file_t *rrd_file,
+ void *buf,
+ size_t count)
+ RRD_DEPRECATED;
+ ssize_t rrd_write(
+ rrd_file_t *rrd_file,
+ const void *buf,
+ size_t count)
+ RRD_DEPRECATED;
+ void rrd_flush(
+ rrd_file_t *rrd_file)
+ RRD_DEPRECATED;
+ off_t rrd_seek(
+ rrd_file_t *rrd_file,
+ off_t off,
+ int whence)
+ RRD_DEPRECATED;
+ off_t rrd_tell(
+ rrd_file_t *rrd_file)
+ RRD_DEPRECATED;
+ int rrd_lock(
+ rrd_file_t *file)
+ RRD_DEPRECATED;
+#endif /* defined(_RRD_TOOL_H) || defined(RRD_EXPORT_DEPRECATED) */
#endif /* _RRDLIB_H */
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_cgi.c RRD Web Page Generator
*****************************************************************************/
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_create.c creates new rrds
*****************************************************************************/
long int rra_random_row(
rra_def_t *);
+static void rrd_free2(
+ rrd_t *rrd); /* our onwn copy, immmune to mmap */
+
int rrd_create(
int argc,
char **argv)
/* static header */
if ((rrd.stat_head = calloc(1, sizeof(stat_head_t))) == NULL) {
rrd_set_error("allocating rrd.stat_head");
- free(rrd.stat_head);
+ rrd_free2(&rrd);
return (-1);
}
/* live header */
if ((rrd.live_head = calloc(1, sizeof(live_head_t))) == NULL) {
rrd_set_error("allocating rrd.live_head");
- free(rrd.stat_head);
- free(rrd.live_head);
+ rrd_free2(&rrd);
return (-1);
}
old_size + sizeof(ds_def_t))) ==
NULL) {
rrd_set_error("allocating rrd.ds_def");
- free(rrd.stat_head);
- free(rrd.live_head);
+ rrd_free2(&rrd);
return (-1);
}
memset(&rrd.ds_def[rrd.stat_head->ds_cnt], 0, sizeof(ds_def_t));
rrd_set_error("invalid DS format");
}
if (rrd_test_error()) {
- free(rrd.stat_head);
- free(rrd.live_head);
+ rrd_free2(&rrd);
return -1;
}
}
if (rrd_test_error()) {
- free(rrd.stat_head);
- free(rrd.live_head);
+ rrd_free2(&rrd);
return -1;
}
rrd.stat_head->ds_cnt++;
old_size + sizeof(rra_def_t))) ==
NULL) {
rrd_set_error("allocating rrd.rra_def");
- free(rrd.stat_head);
- free(rrd.live_head);
+ rrd_free2(&rrd);
return (-1);
}
memset(&rrd.rra_def[rrd.stat_head->rra_cnt], 0,
default:
rrd.rra_def[rrd.stat_head->rra_cnt].pdp_cnt =
atoi(token);
+ if (atoi(token) < 1)
+ rrd_set_error("Invalid step: must be >= 1");
break;
}
break;
if (rrd_test_error()) {
/* all errors are unrecoverable */
free(argvcopy);
- free(rrd.stat_head);
- free(rrd.live_head);
+ rrd_free2(&rrd);
return (-1);
}
token = strtok_r(NULL, ":", &tokptr);
if (create_hw_contingent_rras(&rrd, period, hashed_name) ==
-1) {
rrd_set_error("creating contingent RRA");
- free(rrd.stat_head);
- free(rrd.live_head);
+ rrd_free2(&rrd);
return -1;
}
}
rrd.stat_head->rra_cnt++;
} else {
rrd_set_error("can't parse argument '%s'", argv[i]);
- free(rrd.stat_head);
- free(rrd.live_head);
+ rrd_free2(&rrd);
return -1;
}
}
if (rrd.stat_head->rra_cnt < 1) {
rrd_set_error("you must define at least one Round Robin Archive");
- free(rrd.stat_head);
- free(rrd.live_head);
+ rrd_free2(&rrd);
return (-1);
}
if (rrd.stat_head->ds_cnt < 1) {
rrd_set_error("you must define at least one Data Source");
- free(rrd.stat_head);
- free(rrd.live_head);
+ rrd_free2(&rrd);
return (-1);
}
return rrd_create_fn(filename, &rrd);
if ((rrd->rra_def = rrd_realloc(rrd->rra_def,
old_size + 4 * sizeof(rra_def_t))) ==
NULL) {
+ rrd_free2(rrd);
rrd_set_error("allocating rrd.rra_def");
return (-1);
}
int unkn_cnt;
rrd_file_t *rrd_file_dn;
rrd_t rrd_dn;
- unsigned flags = O_WRONLY | O_CREAT | O_TRUNC;
+ unsigned flags = O_WRONLY | O_CREAT | O_TRUNC;
+
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
flags |= O_BINARY;
#endif
if ((rrd_file = open(file_name, flags, 0666)) < 0) {
rrd_set_error("creating '%s': %s", file_name, rrd_strerror(errno));
- free(rrd->stat_head);
- free(rrd->live_head);
+ rrd_free2(rrd);
return (-1);
}
if ((rrd->pdp_prep = calloc(1, sizeof(pdp_prep_t))) == NULL) {
rrd_set_error("allocating pdp_prep");
- free(rrd->stat_head);
- free(rrd->live_head);
+ rrd_free2(rrd);
close(rrd_file);
return (-1);
}
if ((rrd->cdp_prep = calloc(1, sizeof(cdp_prep_t))) == NULL) {
rrd_set_error("allocating cdp_prep");
- free(rrd->stat_head);
- free(rrd->live_head);
+ rrd_free2(rrd);
close(rrd_file);
return (-1);
}
if ((rrd->rra_ptr = calloc(1, sizeof(rra_ptr_t))) == NULL) {
rrd_set_error("allocating rra_ptr");
- free(rrd->stat_head);
- free(rrd->live_head);
+ rrd_free2(rrd);
close(rrd_file);
return (-1);
}
/* write the empty data area */
if ((unknown = (rrd_value_t *) malloc(512 * sizeof(rrd_value_t))) == NULL) {
rrd_set_error("allocating unknown");
- free(rrd->stat_head);
- free(rrd->live_head);
+ rrd_free2(rrd);
close(rrd_file);
return (-1);
}
}
free(unknown);
fdatasync(rrd_file);
- free(rrd->stat_head);
- free(rrd->live_head);
+ rrd_free2(rrd);
if (close(rrd_file) == -1) {
rrd_set_error("creating rrd: %s", rrd_strerror(errno));
return -1;
return (0);
}
+
+static void rrd_free2(
+ rrd_t *rrd)
+{
+ free(rrd->live_head);
+ free(rrd->stat_head);
+ free(rrd->ds_def);
+ free(rrd->rra_def);
+ free(rrd->rra_ptr);
+ free(rrd->pdp_prep);
+ free(rrd->cdp_prep);
+ free(rrd->rrd_value);
+}
+
static int rand_init = 0;
long int rra_random_row(
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_datalang A system for passing named and typed parameters between
* the different parts of rrdtool
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
* This code is stolen from rateup (mrtg-2.x) by Dave Rand
*****************************************************************************
* diff calculate the difference between two very long integers available as
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_dump Display a RRD
*****************************************************************************
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_error.c Common Header File
*****************************************************************************
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_fetch.c read date from an rrd to use for further processing
*****************************************************************************
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_first Return
*****************************************************************************
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_format.c RRD Database Format helper functions
*****************************************************************************
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_format.h RRD Database Format header
*****************************************************************************/
/****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
****************************************************************************
* rrd_gfx.c graphics wrapper for rrdtool
**************************************************************************/
double dash_off)
{
cairo_t *cr = im->cr;
- double dashes[] = { dash_on, dash_off };
+ double dashes[2];
double x = 0;
double y = 0;
+ dashes[0] = dash_on;
+ dashes[1] = dash_off;
+
cairo_save(cr);
cairo_new_path(cr);
cairo_set_line_width(cr, width);
image_desc_t *im,
double x,
gfx_color_t color,
- char *font,
- double size,
+ PangoFontDescription *font_desc,
double tabwidth,
const char *text)
{
- PangoLayout *layout;
- PangoFontDescription *font_desc;
+ PangoLayout *layout = im->layout;
+ PangoFontDescription *pfd;
cairo_t *cr = im->cr;
+ static double last_tabwidth = -1;
+
+
+
/* for performance reasons we might
want todo that only once ... tabs will always
be the same */
long tab_count = strlen(text);
long tab_shift = fmod(x, tabwidth);
int border = im->text_prop[TEXT_PROP_LEGEND].size * 2.0;
+
+ gchar *utf8_text;
- PangoTabArray *tab_array;
- PangoContext *pango_context;
-
- tab_array = pango_tab_array_new(tab_count, (gboolean) (1));
- for (i = 1; i <= tab_count; i++) {
- pango_tab_array_set_tab(tab_array,
- i, PANGO_TAB_LEFT,
- tabwidth * i - tab_shift + border);
+ if (last_tabwidth < 0 || last_tabwidth != tabwidth){
+ PangoTabArray *tab_array;
+ // fprintf(stderr,"t");
+ last_tabwidth = tabwidth;
+ tab_array = pango_tab_array_new(tab_count, (gboolean) (1));
+ for (i = 1; i <= tab_count; i++) {
+ pango_tab_array_set_tab(tab_array,
+ i, PANGO_TAB_LEFT,
+ tabwidth * i - tab_shift + border);
+ }
+ pango_layout_set_tabs(layout, tab_array);
+ pango_tab_array_free(tab_array);
}
- cairo_new_path(cr);
- cairo_set_source_rgba(cr, color.red, color.green, color.blue,
+ pfd = pango_layout_get_font_description(layout);
+
+ if (!pfd || !pango_font_description_equal (pfd,font_desc)){
+ pango_layout_set_font_description(layout, font_desc);
+ }
+// fprintf(stderr,"%s\n",pango_font_description_to_string(pango_layout_get_font_description(layout)));
+
+ cairo_new_path(cr);
+ cairo_set_source_rgba(cr, color.red, color.green, color.blue,
color.alpha);
- layout = pango_cairo_create_layout(cr);
- pango_context = pango_layout_get_context(layout);
- pango_cairo_context_set_font_options(pango_context, im->font_options);
- pango_cairo_context_set_resolution(pango_context, 100);
+/* layout = pango_cairo_create_layout(cr); */
+
+// pango_cairo_context_set_font_options(pango_context, im->font_options);
+// pango_cairo_context_set_resolution(pango_context, 100);
/* pango_cairo_update_context(cr, pango_context); */
- pango_layout_set_tabs(layout, tab_array);
- font_desc = pango_font_description_from_string(font);
- pango_font_description_set_size(font_desc, size * PANGO_SCALE);
- pango_layout_set_font_description(layout, font_desc);
+
+ /* pango expects the string to be utf-8 encoded */
+ utf8_text = g_locale_to_utf8((const gchar *) text, -1, NULL, NULL, NULL);
+
+ /* In case of an error, i.e. utf8_text == NULL (locale settings messed
+ * up?), we fall back to a possible "invalid UTF-8 string" warning instead
+ * of provoking a failed assertion in libpango. */
if (im->with_markup)
- pango_layout_set_markup(layout, text, -1);
+ pango_layout_set_markup(layout, utf8_text ? utf8_text : text, -1);
else
- pango_layout_set_text(layout, text, -1);
+ pango_layout_set_text(layout, utf8_text ? utf8_text : text, -1);
+
+ g_free(utf8_text);
return layout;
}
double gfx_get_text_width(
image_desc_t *im,
double start,
- char *font,
- double size,
+ PangoFontDescription *font_desc,
double tabwidth,
char *text)
{
PangoLayout *layout;
PangoRectangle log_rect;
gfx_color_t color = { 0, 0, 0, 0 };
- layout = gfx_prep_text(im, start, color, font, size, tabwidth, text);
+ layout = gfx_prep_text(im, start, color, font_desc, tabwidth, text);
pango_layout_get_pixel_extents(layout, NULL, &log_rect);
- pango_tab_array_free(pango_layout_get_tabs(layout));
- g_object_unref(layout);
+/* g_object_unref(layout); */
return log_rect.width;
}
double x,
double y,
gfx_color_t color,
- char *font,
- double size,
+ PangoFontDescription *font_desc,
double tabwidth,
double angle,
enum gfx_h_align_en h_align,
{
PangoLayout *layout;
PangoRectangle log_rect;
- PangoRectangle ink_rect;
cairo_t *cr = im->cr;
double sx = 0;
double sy = 0;
cairo_translate(cr, x, y);
/* gfx_line(cr,-2,0,2,0,1,color);
gfx_line(cr,0,-2,0,2,1,color); */
- layout = gfx_prep_text(im, x, color, font, size, tabwidth, text);
- pango_layout_get_pixel_extents(layout, &ink_rect, &log_rect);
+ layout = gfx_prep_text(im, x, color, font_desc, tabwidth, text);
+ pango_layout_get_pixel_extents(layout, NULL, &log_rect);
cairo_rotate(cr, -angle * G_PI / 180.0);
sx = log_rect.x;
switch (h_align) {
pango_cairo_update_layout(cr, layout);
cairo_move_to(cr, sx, sy);
pango_cairo_show_layout(cr, layout);
- pango_tab_array_free(pango_layout_get_tabs(layout));
- g_object_unref(layout);
+/* g_object_unref(layout); */
cairo_restore(cr);
}
/****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
****************************************************************************
* rrd__graph.c produce graphs from data in rrdfiles
****************************************************************************/
#endif
text_prop_t text_prop[] = {
- {8.0, RRD_DEFAULT_FONT}
+ {8.0, RRD_DEFAULT_FONT,NULL}
, /* default */
- {9.0, RRD_DEFAULT_FONT}
+ {9.0, RRD_DEFAULT_FONT,NULL}
, /* title */
- {7.0, RRD_DEFAULT_FONT}
+ {7.0, RRD_DEFAULT_FONT,NULL}
, /* axis */
- {8.0, RRD_DEFAULT_FONT}
+ {8.0, RRD_DEFAULT_FONT,NULL}
, /* unit */
- {8.0, RRD_DEFAULT_FONT} /* legend */
+ {8.0, RRD_DEFAULT_FONT,NULL} /* legend */
+ ,
+ {5.5, RRD_DEFAULT_FONT,NULL} /* watermark */
};
xlab_t xlab[] = {
conv_if(AXIS, TEXT_PROP_AXIS);
conv_if(UNIT, TEXT_PROP_UNIT);
conv_if(LEGEND, TEXT_PROP_LEGEND);
+ conv_if(WATERMARK, TEXT_PROP_WATERMARK);
return -1;
}
if (im->rendered_image) {
free(im->rendered_image);
}
+
+ if (im->layout) {
+ g_object_unref (im->layout);
+ }
+
if (im->surface)
cairo_surface_destroy(im->surface);
+
if (status)
fprintf(stderr, "OOPS: Cairo has issues it can't even die: %s\n",
cairo_status_to_string(status));
-
+
return 0;
}
im->
text_prop
[TEXT_PROP_LEGEND].
- font,
- im->
- text_prop
- [TEXT_PROP_LEGEND].
- size,
+ font_desc,
im->tabwidth, im->gdes[i].legend);
leg_c++;
} else {
im->
text_prop
[TEXT_PROP_LEGEND].
- font,
- im->
- text_prop
- [TEXT_PROP_LEGEND].
- size,
+ font_desc,
im->tabwidth, im->gdes[ii].legend)
+ legspace[ii]
+ glue;
im->graph_col[GRC_FONT],
im->
text_prop[TEXT_PROP_AXIS].
- font,
- im->
- text_prop[TEXT_PROP_AXIS].
- size, im->tabwidth, 0.0,
+ font_desc,
+ im->tabwidth, 0.0,
GFX_H_RIGHT, GFX_V_CENTER, graph_label);
gfx_line(im, X0 - 2, Y0, X0, Y0,
MGRIDWIDTH, im->graph_col[GRC_MGRID]);
im->graph_col[GRC_FONT],
im->
text_prop[TEXT_PROP_AXIS].
- font,
- im->
- text_prop[TEXT_PROP_AXIS].
- size, im->tabwidth, 0.0,
+ font_desc,
+ im->tabwidth, 0.0,
GFX_H_RIGHT, GFX_V_CENTER, graph_label);
/* minor grid */
if (mid < 4 && exfrac == 1) {
im->graph_col[GRC_FONT],
im->
text_prop[TEXT_PROP_AXIS].
- font,
- im->
- text_prop[TEXT_PROP_AXIS].
- size, im->tabwidth, 0.0,
+ font_desc,
+ im->tabwidth, 0.0,
GFX_H_CENTER, GFX_V_TOP, graph_label);
}
im->graph_col[GRC_FONT],
im->
text_prop[TEXT_PROP_AXIS].
- font,
- im->
- text_prop[TEXT_PROP_AXIS].
- size, im->tabwidth, 0.0,
+ font_desc,
+ im->tabwidth, 0.0,
GFX_H_CENTER, GFX_V_CENTER, nodata);
}
}
im->graph_col[GRC_FONT],
im->
text_prop[TEXT_PROP_UNIT].
- font,
- im->
- text_prop[TEXT_PROP_UNIT].
- size, im->tabwidth,
+ font_desc,
+ im->tabwidth,
RRDGRAPH_YLEGEND_ANGLE, GFX_H_CENTER, GFX_V_CENTER, im->ylegend);
/* graph title */
gfx_text(im,
im->graph_col[GRC_FONT],
im->
text_prop[TEXT_PROP_TITLE].
- font,
- im->
- text_prop[TEXT_PROP_TITLE].
- size, im->tabwidth, 0.0, GFX_H_CENTER, GFX_V_TOP, im->title);
+ font_desc,
+ im->tabwidth, 0.0, GFX_H_CENTER, GFX_V_TOP, im->title);
/* rrdtool 'logo' */
water_color = im->graph_col[GRC_FONT];
water_color.alpha = 0.3;
gfx_text(im, im->ximg - 4, 5,
water_color,
im->
- text_prop[TEXT_PROP_AXIS].
- font, 5.5, im->tabwidth,
+ text_prop[TEXT_PROP_WATERMARK].
+ font_desc, im->tabwidth,
-90, GFX_H_LEFT, GFX_V_TOP, "RRDTOOL / TOBI OETIKER");
/* graph watermark */
if (im->watermark[0] != '\0') {
im->ximg / 2, im->yimg - 6,
water_color,
im->
- text_prop[TEXT_PROP_AXIS].
- font, 5.5, im->tabwidth, 0,
+ text_prop[TEXT_PROP_WATERMARK].
+ font_desc, im->tabwidth, 0,
GFX_H_CENTER, GFX_V_BOTTOM, im->watermark);
}
im->graph_col[GRC_FONT],
im->
text_prop
- [TEXT_PROP_LEGEND].font,
- im->
- text_prop
- [TEXT_PROP_LEGEND].size,
+ [TEXT_PROP_LEGEND].font_desc,
im->tabwidth, 0.0,
GFX_H_LEFT, GFX_V_BOTTOM, im->gdes[i].legend);
/* The legend for GRAPH items starts with "M " to have
im->
text_prop
[TEXT_PROP_LEGEND].
- font,
- im->
- text_prop
- [TEXT_PROP_LEGEND].
- size, im->tabwidth, "o") * 1.2;
+ font_desc,
+ im->tabwidth, "o") * 1.2;
boxV = boxH;
/* shift the box up a bit */
Y0 -= boxV * 0.4;
im->
text_prop
[TEXT_PROP_AXIS].
- font,
- im->
- text_prop
- [TEXT_PROP_AXIS].
- size, im->tabwidth, "0") * im->unitslength;
+ font_desc,
+ im->tabwidth, "0") * im->unitslength;
}
}
double areazero = 0.0;
graph_desc_t *lastgdes = NULL;
rrd_infoval_t info;
- PangoFontMap *font_map = pango_cairo_font_map_get_default();
- /* if we are lazy and there is nothing to PRINT ... quit now */
- if (lazy && im->prt_c == 0) {
+// PangoFontMap *font_map = pango_cairo_font_map_get_default();
+
+ /* if we want and can be lazy ... quit now */
+ if (lazy) {
info.u_cnt = im->ximg;
grinfo_push(im, sprintf_alloc("image_width"), RD_I_CNT, info);
info.u_cnt = im->yimg;
* if there are no graph elements (i==0) we stop here ...
* if we are lazy, try to quit ...
*/
- i = print_calc(im);
+ i = print_calc(im);
if (i < 0)
return -1;
(im->surface, CAIRO_SVG_VERSION_1_1);
break;
};
+ cairo_destroy(im->cr);
im->cr = cairo_create(im->surface);
cairo_set_antialias(im->cr, im->graph_antialias);
cairo_scale(im->cr, im->zoom, im->zoom);
- pango_cairo_font_map_set_resolution(PANGO_CAIRO_FONT_MAP(font_map), 100);
+// pango_cairo_font_map_set_resolution(PANGO_CAIRO_FONT_MAP(font_map), 100);
gfx_new_area(im, 0, 0, 0, im->yimg,
im->ximg, im->yimg, im->graph_col[GRC_BACK]);
gfx_add_point(im, im->ximg, 0);
*ysize = 0;
*ymin = 0;
*ymax = 0;
- while (walker) {
+ while (walker) {
if (strcmp(walker->key, "image_width") == 0) {
*xsize = walker->value.u_int;
} else if (strcmp(walker->key, "image_height") == 0) {
{
image_desc_t im;
rrd_info_t *grinfo;
-
rrd_graph_init(&im);
/* a dummy surface so that we can measure text sizes for placements */
- im.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 10, 10);
- im.cr = cairo_create(im.surface);
+
rrd_graph_options(argc, argv, &im);
if (rrd_test_error()) {
rrd_info_free(im.grinfo);
if (im.imginfo) {
rrd_infoval_t info;
+ char *filename;
+ filename = im.graphfile + strlen(im.graphfile);
+ while (filename > im.graphfile) {
+ if (*(filename - 1) == '/' || *(filename - 1) == '\\')
+ break;
+ filename--;
+ }
info.u_str =
sprintf_alloc(im.imginfo,
- im.graphfile,
+ filename,
(long) (im.zoom *
im.ximg), (long) (im.zoom * im.yimg));
grinfo_push(&im, sprintf_alloc("image_info"), RD_I_STR, info);
return grinfo;
}
+static void
+rrd_set_font_desc (
+ image_desc_t *im,int prop,char *font, double size ){
+ static text_prop_t tp_cache[] = { {-1,"",NULL}, {-1,"",NULL}, {-1,"",NULL}, {-1,"",NULL}, {-1,"",NULL}, {-1,"",NULL}};
+
+ if (tp_cache[prop].font_desc == NULL){
+ if (prop > 0 && tp_cache[0].font_desc != NULL){
+ tp_cache[prop].font_desc = pango_font_description_copy (tp_cache[0].font_desc);
+ strcpy(tp_cache[prop].font,tp_cache[0].font);
+ tp_cache[prop].size = tp_cache[0].size;
+ }
+ else {
+ tp_cache[prop].font_desc = pango_font_description_new();
+ }
+ im->text_prop[prop].font_desc = pango_font_description_copy (tp_cache[prop].font_desc);
+ }
+
+ if (font != NULL && strcmp(tp_cache[prop].font,font) != 0){
+ pango_font_description_free(tp_cache[prop].font_desc);
+ pango_font_description_free(im->text_prop[prop].font_desc);
+ tp_cache[prop].font_desc = pango_font_description_from_string( font );
+ im->text_prop[prop].font_desc = pango_font_description_copy( tp_cache[prop].font_desc );
+ strncpy(tp_cache[prop].font, font, sizeof(text_prop[prop].font) - 1);
+ tp_cache[prop].font[sizeof(text_prop[prop].font) - 1] = '\0';
+ strcpy(im->text_prop[prop].font,tp_cache[prop].font);
+ }
+ if (size != 0 && size != (tp_cache[prop].size)){
+ pango_font_description_set_size(tp_cache[prop].font_desc, size * PANGO_SCALE);
+ pango_font_description_set_size(im->text_prop[prop].font_desc, size * PANGO_SCALE);
+ im->text_prop[prop].size = size;
+ tp_cache[prop].size = size;
+ }
+ if (im->text_prop[prop].size < 0){
+ im->text_prop[prop].size = tp_cache[prop].size;
+ im->text_prop[prop].font_desc = pango_font_description_copy( tp_cache[prop].font_desc );
+ strcpy(im->text_prop[prop].font,tp_cache[prop].font);
+ }
+ // fprintf(stderr,"%d %s\n",prop,pango_font_description_to_string(im->text_prop[prop].font_desc));
+}
+
void rrd_graph_init(
image_desc_t
*im)
{
unsigned int i;
+ char *deffont = getenv("RRD_DEFAULT_FONT");
#ifdef HAVE_TZSET
tzset();
#endif
#endif
im->base = 1000;
- im->cr = NULL;
im->draw_x_grid = 1;
im->draw_y_grid = 1;
im->extra_flags = 0;
im->rendered_image = NULL;
im->slopemode = 0;
im->step = 0;
- im->surface = NULL;
im->symbol = ' ';
im->tabwidth = 40.0;
im->title[0] = '\0';
im->yorigin = 0;
im->ysize = 100;
im->zoom = 1;
+
+ im->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 10, 10);
+ im->cr = cairo_create(im->surface);
+
+ for (i = 0; i < DIM(text_prop); i++) {
+ im->text_prop[i].size = -1;
+ rrd_set_font_desc(im,i, deffont ? deffont : text_prop[i].font,text_prop[i].size);
+ }
+
+ im->layout = pango_cairo_create_layout(im->cr);
+ pango_cairo_context_set_resolution(pango_layout_get_context(im->layout), 100);
+
cairo_font_options_set_hint_style
(im->font_options, CAIRO_HINT_STYLE_FULL);
cairo_font_options_set_hint_metrics
(im->font_options, CAIRO_HINT_METRICS_ON);
cairo_font_options_set_antialias(im->font_options, CAIRO_ANTIALIAS_GRAY);
+
+
+
for (i = 0; i < DIM(graph_col); i++)
im->graph_col[i] = graph_col[i];
- {
- char *deffont;
-
- deffont = getenv("RRD_DEFAULT_FONT");
- if (deffont != NULL) {
- for (i = 0; i < DIM(text_prop); i++) {
- strncpy(text_prop[i].font, deffont,
- sizeof(text_prop[i].font) - 1);
- text_prop[i].font[sizeof(text_prop[i].font) - 1] = '\0';
- }
- }
- }
- for (i = 0; i < DIM(text_prop); i++) {
- im->text_prop[i].size = text_prop[i].size;
- strcpy(im->text_prop[i].font, text_prop[i].font);
- }
+
+
}
+
void rrd_graph_options(
int argc,
char *argv[],
for (propidx = sindex;
propidx < TEXT_PROP_LAST; propidx++) {
if (size > 0) {
- im->text_prop[propidx].size = size;
+ rrd_set_font_desc(im,propidx,NULL,size);
}
if ((int) strlen(optarg) > end) {
if (optarg[end] == ':') {
- strncpy(im->text_prop[propidx].font,
- optarg + end + 1, 255);
- im->text_prop[propidx].font[255] = '\0';
+ rrd_set_font_desc(im,propidx,optarg + end + 1,0);
} else {
rrd_set_error
("expected : after font size in '%s'",
im->use_rrdcached = 1;
}
}
+
+ pango_cairo_context_set_font_options(pango_layout_get_context(im->layout), im->font_options);
+ pango_layout_context_changed(im->layout);
+
+
if (im->logarithmic && im->minval <= 0) {
rrd_set_error
src = &im->gdes[dst->vidx];
data = src->data + src->ds;
end =
- src->end_orig % (long)src->step ==
- 0 ? src->end_orig : (src->end_orig + (long)src->step -
- src->end_orig % (long)src->step);
+ src->end_orig % (long) src->step ==
+ 0 ? src->end_orig : (src->end_orig + (long) src->step -
+ src->end_orig % (long) src->step);
steps = (end - src->start) / src->step;
#if 0
, VDEF_LSLINT /* least squares line y_intercept */
, VDEF_LSLCORREL /* least squares line correlation coefficient */
};
-enum text_prop_en { TEXT_PROP_DEFAULT = 0, /* default settings */
+enum text_prop_en {
+ TEXT_PROP_DEFAULT = 0, /* default settings */
TEXT_PROP_TITLE, /* properties for the title */
TEXT_PROP_AXIS, /* for the numbers next to the axis */
TEXT_PROP_UNIT, /* for the vertical unit description */
- TEXT_PROP_LEGEND, /* fot the legend below the graph */
+ TEXT_PROP_LEGEND, /* for the legend below the graph */
+ TEXT_PROP_WATERMARK, /* for the little text to the side of the graph */
TEXT_PROP_LAST
};
typedef struct text_prop_t {
double size;
char font[1024];
+ PangoFontDescription *font_desc;
} text_prop_t;
cairo_t *cr; /* drawin context */
cairo_font_options_t *font_options; /* cairo font options */
cairo_antialias_t graph_antialias; /* antialiasing for the graph */
-
+ PangoLayout *layout; /* the pango layout we use for writing fonts */
rrd_info_t *grinfo; /* root pointer to extra graph info */
rrd_info_t *grinfo_current; /* pointing to current entry */
} image_desc_t;
char *const);
void rrd_graph_init(
image_desc_t *);
+
void rrd_graph_options(
int,
char **,
double x,
double y,
gfx_color_t color,
- char *font,
- double size,
+ PangoFontDescription *font_desc,
double tabwidth,
double angle,
enum gfx_h_align_en h_align,
double gfx_get_text_width(
image_desc_t *im,
double start,
- char *font,
- double size,
+ PangoFontDescription *font_desc,
double tabwidth,
char *text);
void grinfo_push(
image_desc_t *im,
char *key,
- rrd_info_type_t type,
- rrd_infoval_t value);
+ rrd_info_type_t type, rrd_infoval_t value);
/****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
****************************************************************************
* rrd_graph_helper.c commandline parser functions
* this code initially written by Alex van den Bogaerdt
}
-/* Parsing of PART, VRULE, HRULE, LINE, AREA, STACK and TICK
+/* Parsing of VRULE, HRULE, LINE, AREA, STACK and TICK
** is done in one function.
**
-** Stacking PART, VRULE, HRULE or TICK is not allowed.
+** Stacking VRULE, HRULE or TICK is not allowed.
**
** If a number (which is valid to enter) is more than a
** certain amount of characters, it is caught as an error.
float one_space = gfx_get_text_width(im, 0,
im->
text_prop[TEXT_PROP_LEGEND].
- font,
- im->
- text_prop[TEXT_PROP_LEGEND].
- size,
+ font_desc,
im->tabwidth, " ") / 4.0;
float target_space = gfx_get_text_width(im, 0,
im->
text_prop
- [TEXT_PROP_LEGEND].font,
- im->
- text_prop
- [TEXT_PROP_LEGEND].size,
+ [TEXT_PROP_LEGEND].font_desc,
im->tabwidth, "oo");
spacecnt = target_space / one_space;
}
(*eaten)++; /* after colon */
- /* PART, HRULE, VRULE and TICK cannot be stacked. */
+ /* HRULE, VRULE and TICK cannot be stacked. */
if ((gdp->gf != GF_HRULE)
&& (gdp->gf != GF_VRULE)
&& (gdp->gf != GF_TICK)) {
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_hw.c : Support for Holt-Winters Smoothing/ Aberrant Behavior Detection
*****************************************************************************
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_hw.h : Support for Holt-Winters Smoothing/ Aberrant Behavior Detection
*****************************************************************************/
unsigned long dependent_rra_idx, seasonal_cdp_idx;
unival *coefs = rrd->cdp_prep[cdp_idx].scratch;
rra_def_t *current_rra = &(rrd->rra_def[rra_idx]);
+ rrd_value_t seasonal_coef;
/* save coefficients from current prediction */
coefs[CDP_hw_last_intercept].u_val = coefs[CDP_hw_intercept].u_val;
dependent_rra_idx = current_rra->par[RRA_dependent_rra_idx].u_cnt;
seasonal_cdp_idx = dependent_rra_idx * (rrd->stat_head->ds_cnt) + ds_idx;
- rrd_value_t seasonal_coef = (dependent_rra_idx < rra_idx)
+ seasonal_coef = (dependent_rra_idx < rra_idx)
? rrd->cdp_prep[seasonal_cdp_idx].scratch[CDP_hw_last_seasonal].u_val
: rrd->cdp_prep[seasonal_cdp_idx].scratch[CDP_hw_seasonal].u_val;
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Takao Fujiwara, 2008
+ * RRDtool 1.3.1 Copyright by Takao Fujiwara, 2008
*****************************************************************************
* rrd_i18n.h Common Header File
*****************************************************************************/
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_info Get Information about the configuration of an RRD
*****************************************************************************/
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
* This file: Copyright 2003 Peter Stamfest <peter@stamfest.at>
* & Tobias Oetiker
* Distributed under the GPL
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_last.c
*****************************************************************************
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
* Copyright by Florian Forster, 2008
*****************************************************************************
* rrd_lastupdate Get the last datum entered for each DS
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
* This file: Copyright 2003 Peter Stamfest <peter@stamfest.at>
* & Tobias Oetiker
* Distributed under the GPL
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_open.c Open an RRD File
*****************************************************************************
mm_flags |= MAP_NONBLOCK; /* just populate ptes */
#endif
}
-
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
flags |= O_BINARY;
#endif
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_resize.c Alters size of an RRA
*****************************************************************************
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
* This file: Copyright 2008 Florian octo Forster
* Distributed under the GPL
*****************************************************************************
status = 0;
for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
+ if (atoi(rrd->stat_head->version) == 1) {
+ cdp_prep->scratch[CDP_primary_val].u_val = 0.0;
+ cdp_prep->scratch[CDP_secondary_val].u_val = 0.0;
+ }
if ((xmlStrcmp(child->name, (const xmlChar *) "comment") == 0)
|| (xmlStrcmp(child->name, (const xmlChar *) "text") == 0))
/* ignore */ ;
status = get_int_from_node(doc, child,
(int *) &cdp_prep->
scratch[CDP_unkn_pdp_cnt].u_cnt);
- /*
- * Compatibility code for 1.0.49
- */
- else if (xmlStrcmp(child->name, (const xmlChar *) "value") == 0) { /* {{{ */
- unsigned int i = 0;
- rra_def_t *rra_def = rrd->rra_def + (rrd->stat_head->rra_cnt - 1);
-
- while (42) {
- if (i >= ARRAY_LENGTH(cdp_prep->scratch)) {
- status = -1;
- break;
- }
-
- if ((cf_conv(rra_def->cf_nam) == CF_FAILURES)
- || (i == CDP_unkn_pdp_cnt)
- || (i == CDP_null_count)
- || (i == CDP_last_null_count))
- status = get_int_from_node(doc, child,
- (int *) &cdp_prep->scratch[i].
- u_cnt);
- else
- status = get_double_from_node(doc, child,
- &cdp_prep->scratch[i].
- u_val);
-
- if (status != 0)
- break;
-
- /* When this loops exits (sucessfully) `child' points to the last
- * `value' tag in the list. */
- if ((child->next == NULL)
- || (xmlStrcmp(child->name, (const xmlChar *) "value") !=
- 0))
- break;
-
- child = child->next;
- i++;
- }
- } /* }}} */
else {
rrd_set_error("parse_tag_rra_cdp_prep: Unknown tag: %s",
child->name);
else if (xmlStrcmp(child->name, (const xmlChar *) "pdp_per_row") == 0)
status = get_int_from_node(doc, child,
(int *) &cur_rra_def->pdp_cnt);
- else if (xmlStrcmp(child->name, (const xmlChar *) "params") == 0)
+ else if (atoi(rrd->stat_head->version) == 1
+ && xmlStrcmp(child->name, (const xmlChar *) "xff") == 0)
+ status = get_double_from_node(doc, child,
+ (double *) &cur_rra_def->
+ par[RRA_cdp_xff_val].u_val);
+ else if (atoi(rrd->stat_head->version) >= 2
+ && xmlStrcmp(child->name, (const xmlChar *) "params") == 0)
status = parse_tag_rra_params(doc, child, cur_rra_def);
else if (xmlStrcmp(child->name, (const xmlChar *) "cdp_prep") == 0)
status = parse_tag_rra_cdp_prep(doc, child, rrd, cur_cdp_prep);
break;
}
- /* Set the RRA pointer to the last value in the archive */
- cur_rra_ptr->cur_row = cur_rra_def->row_cnt - 1;
+ /* Set the RRA pointer to a random location */
+ cur_rra_ptr->cur_row = random() % cur_rra_def->row_cnt;
return (status);
} /* int parse_tag_rra */
{
FILE *fh;
unsigned int i;
- unsigned int value_count;
+ unsigned int rra_offset;
if (strcmp("-", file_name) == 0)
fh = stdout;
return (-1);
}
}
-
+ if (atoi(rrd->stat_head->version) < 3) {
+ /* we output 3 or higher */
+ strcpy(rrd->stat_head->version, "0003");
+ }
fwrite(rrd->stat_head, sizeof(stat_head_t), 1, fh);
fwrite(rrd->ds_def, sizeof(ds_def_t), rrd->stat_head->ds_cnt, fh);
fwrite(rrd->rra_def, sizeof(rra_def_t), rrd->stat_head->rra_cnt, fh);
fwrite(rrd->rra_ptr, sizeof(rra_ptr_t), rrd->stat_head->rra_cnt, fh);
/* calculate the number of rrd_values to dump */
- value_count = 0;
- for (i = 0; i < rrd->stat_head->rra_cnt; i++)
- value_count += (rrd->rra_def[i].row_cnt * rrd->stat_head->ds_cnt);
+ rra_offset = 0;
+ for (i = 0; i < rrd->stat_head->rra_cnt; i++) {
+ unsigned long num_rows = rrd->rra_def[i].row_cnt;
+ unsigned long cur_row = rrd->rra_ptr[i].cur_row;
+ unsigned long ds_cnt = rrd->stat_head->ds_cnt;
+
+ fwrite(rrd->rrd_value +
+ (rra_offset + num_rows - 1 - cur_row) * ds_cnt,
+ sizeof(rrd_value_t), (cur_row + 1) * ds_cnt, fh);
- fwrite(rrd->rrd_value, sizeof(rrd_value_t), value_count, fh);
+ fwrite(rrd->rrd_value + rra_offset * ds_cnt,
+ sizeof(rrd_value_t), (num_rows - 1 - cur_row) * ds_cnt, fh);
+
+ rra_offset += num_rows;
+ }
/* lets see if we had an error */
if (ferror(fh)) {
{
rrd_t *rrd;
+ srandom((unsigned int) time(NULL) + (unsigned int) getpid());
/* init rrd clean */
optind = 0;
opterr = 0; /* initialize getopt */
/****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
****************************************************************************
* rrd_rpncalc.c RPN calculator functions
****************************************************************************/
/****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
****************************************************************************
* rrd_rpncalc.h RPN calculator functions
****************************************************************************/
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
* This file: Copyright 2003 Peter Stamfest <peter@stamfest.at>
* & Tobias Oetiker
* Distributed under the GPL
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
* This file: Copyright 2003 Peter Stamfest <peter@stamfest.at>
* & Tobias Oetiker
* Distributed under the GPL
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_tool.c Startup wrapper
*****************************************************************************/
return *aLinePtr = linebuf;
bufsize += MAX_LENGTH;
if (!(linebuf = realloc(linebuf, bufsize))) {
+ free(linebuf);
perror("fgetslong: realloc");
exit(1);
}
}
- return *aLinePtr = linebuf[0] ? linebuf : 0;
+ if (linebuf[0]){
+ return *aLinePtr = linebuf;
+ }
+ free(linebuf);
+ return *aLinePtr = 0;
}
int main(
== 0) {
#ifdef HAVE_CHROOT
- chroot(argv[2]);
- if (errno != 0) {
- fprintf(stderr,
- "ERROR: can't change root to '%s' errno=%d\n",
- argv[2], errno);
+ if (chroot(argv[2]) != 0){
+ fprintf(stderr, "ERROR: chroot %s: %s\n", argv[2],rrd_strerror(errno));
exit(errno);
}
ChangeRoot = 1;
}
}
if (strcmp(firstdir, "")) {
- chdir(firstdir);
- if (errno != 0) {
- fprintf(stderr, "ERROR: %s\n", rrd_strerror(errno));
+ if (chdir(firstdir) != 0){
+ fprintf(stderr, "ERROR: chdir %s %s\n", firstdir,rrd_strerror(errno));
exit(errno);
}
}
while (fgetslong(&aLine, stdin)) {
if ((argc = CountArgs(aLine)) == 0) {
+ free(aLine);
printf("ERROR: not enough arguments\n");
}
if ((myargv = (char **) malloc((argc + 1) *
exit(1);
}
if ((argc = CreateArgs(argv[0], aLine, argc, myargv)) < 0) {
+ free(aLine);
+ free(myargv);
printf("ERROR: creating arguments\n");
} else {
int ret = HandleInputLine(argc, myargv, stdout);
/* Reset errno to 0 before we start.
*/
- errno = 0;
if (RemoteMode) {
if (argc > 1 && strcmp("quit", argv[1]) == 0) {
if (argc > 2) {
return (1);
}
#endif
- chdir(argv[2]);
- if (errno != 0) {
- printf("ERROR: %s\n", rrd_strerror(errno));
+ if (chdir(argv[2]) != 0){
+ printf("ERROR: chdir %s %s\n", argv[2], rrd_strerror(errno));
return (1);
}
return (0);
}
cwd = getcwd(NULL, MAXPATH);
if (cwd == NULL) {
- printf("ERROR: %s\n", rrd_strerror(errno));
+ printf("ERROR: getcwd %s\n", rrd_strerror(errno));
return (1);
}
printf("%s\n", cwd);
return (1);
}
#endif
- mkdir(argv[2], 0777);
- if (errno != 0) {
- printf("ERROR: %s\n", rrd_strerror(errno));
+ if(mkdir(argv[2], 0777)!=0){
+ printf("ERROR: mkdir %s: %s\n", argv[2],rrd_strerror(errno));
return (1);
}
return (0);
}
closedir(curdir);
} else {
- printf("ERROR: %s\n", rrd_strerror(errno));
+ printf("ERROR: opendir .: %s\n", rrd_strerror(errno));
return (errno);
}
return (0);
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_tool.h Common Header File
*****************************************************************************/
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* change header parameters of an rrd
*****************************************************************************
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
* Copyright by Florian Forster, 2008
*****************************************************************************
* rrd_update.c RRD Update Function
rra_step_cnt, updvals, tmpl_idx, tmpl_cnt,
&pcdp_summary, version, skip_update,
&schedule_smooth) == -1) {
- if (rrd_test_error()) { /* Should have error string always here */
- char *save_error;
-
- /* Prepend file name to error message */
- if ((save_error = strdup(rrd_get_error())) != NULL) {
- rrd_set_error("%s: %s", filename, save_error);
- free(save_error);
- }
- }
+ if (rrd_test_error()) { /* Should have error string always here */
+ char *save_error;
+
+ /* Prepend file name to error message */
+ if ((save_error = strdup(rrd_get_error())) != NULL) {
+ rrd_set_error("%s: %s", filename, save_error);
+ free(save_error);
+ }
+ }
free(arg_copy);
break;
}
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrd_version Return
*****************************************************************************
/****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
****************************************************************************
* rrd_xport.c export RRD data
****************************************************************************/
/****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
****************************************************************************
* rrd_xport.h contains XML related constants
****************************************************************************/
/*****************************************************************************
- * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008
*****************************************************************************
* rrdupdate.c Main program for the (standalone) rrdupdate utility
*****************************************************************************