X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fgraph_def.c;h=4bd5f1e339bc4b9431d74232af1484c5380a4d62;hb=48e1cdc50ece8684c0ab87e8162d7fffe2edfbd0;hp=927b3fef3badeb46e04bc3c59e6c3220c984468b;hpb=e570ccd032c7f252d8f8a5b5b15471a544c47d23;p=collection4.git diff --git a/src/graph_def.c b/src/graph_def.c index 927b3fe..4bd5f1e 100644 --- a/src/graph_def.c +++ b/src/graph_def.c @@ -5,6 +5,7 @@ #include "graph_def.h" #include "graph.h" #include "graph_config.h" +#include "graph_ident.h" #include "common.h" #include "oconfig.h" @@ -286,10 +287,11 @@ int def_foreach (graph_def_t *def, def_callback_t callback, /* {{{ */ } /* }}} int def_foreach */ int def_get_rrdargs (graph_def_t *def, graph_ident_t *ident, /* {{{ */ - str_array_t *args) + rrd_args_t *args) { char *file; int index; + char draw_def[64]; if ((def == NULL) || (ident == NULL) || (args == NULL)) return (EINVAL); @@ -303,42 +305,65 @@ int def_get_rrdargs (graph_def_t *def, graph_ident_t *ident, /* {{{ */ DEBUG ("gl_ident_get_rrdargs: file = %s;\n", file); - index = array_argc (args); + index = args->index; + args->index++; /* CDEFs */ - array_append_format (args, "DEF:def_%04i_min=%s:%s:MIN", + array_append_format (args->data, "DEF:def_%04i_min=%s:%s:MIN", index, file, def->ds_name); - array_append_format (args, "DEF:def_%04i_avg=%s:%s:AVERAGE", + array_append_format (args->data, "DEF:def_%04i_avg=%s:%s:AVERAGE", index, file, def->ds_name); - array_append_format (args, "DEF:def_%04i_max=%s:%s:MAX", + array_append_format (args->data, "DEF:def_%04i_max=%s:%s:MAX", index, file, def->ds_name); /* VDEFs */ - array_append_format (args, "VDEF:vdef_%04i_min=def_%04i_min,MINIMUM", + array_append_format (args->data, "VDEF:vdef_%04i_min=def_%04i_min,MINIMUM", index, index); - array_append_format (args, "VDEF:vdef_%04i_avg=def_%04i_avg,AVERAGE", + array_append_format (args->data, "VDEF:vdef_%04i_avg=def_%04i_avg,AVERAGE", index, index); - array_append_format (args, "VDEF:vdef_%04i_max=def_%04i_max,MAXIMUM", + array_append_format (args->data, "VDEF:vdef_%04i_max=def_%04i_max,MAXIMUM", index, index); - array_append_format (args, "VDEF:vdef_%04i_lst=def_%04i_avg,LAST", + array_append_format (args->data, "VDEF:vdef_%04i_lst=def_%04i_avg,LAST", index, index); + if (def->stack) + { + if (args->last_stack_cdef[0] != 0) + { + array_append_format (args->calc, "CDEF:cdef_%04i_stack=%s,def_%04i_avg,+", + index, args->last_stack_cdef, index); + snprintf (draw_def, sizeof (draw_def), "cdef_%04i_stack", index); + } + else + { + snprintf (draw_def, sizeof (draw_def), "def_%04i_avg", index); + } + } + else + { + snprintf (draw_def, sizeof (draw_def), "def_%04i_avg", index); + } + + if (def->area) + array_prepend_format (args->areas, "AREA:%s#%06"PRIx32, + draw_def, fade_color (def->color)); + /* Graph part */ - array_append_format (args, "%s:def_%04i_avg#%06"PRIx32":%s%s", - def->area ? "AREA" : "LINE1", - index, def->color, - (def->legend != NULL) ? def->legend : def->ds_name, - def->stack ? ":STACK" : ""); - array_append_format (args, "GPRINT:vdef_%04i_min:%s min,", - index, (def->format != NULL) ? def->format : "%lg"); - array_append_format (args, "GPRINT:vdef_%04i_avg:%s avg,", - index, (def->format != NULL) ? def->format : "%lg"); - array_append_format (args, "GPRINT:vdef_%04i_max:%s max,", - index, (def->format != NULL) ? def->format : "%lg"); - array_append_format (args, "GPRINT:vdef_%04i_lst:%s last\\l", - index, (def->format != NULL) ? def->format : "%lg"); + array_prepend_format (args->lines, "GPRINT:vdef_%04i_lst:%s last\\l", + index, (def->format != NULL) ? def->format : "%6.2lf"); + array_prepend_format (args->lines, "GPRINT:vdef_%04i_max:%s max,", + index, (def->format != NULL) ? def->format : "%6.2lf"); + array_prepend_format (args->lines, "GPRINT:vdef_%04i_avg:%s avg,", + index, (def->format != NULL) ? def->format : "%6.2lf"); + array_prepend_format (args->lines, "GPRINT:vdef_%04i_min:%s min,", + index, (def->format != NULL) ? def->format : "%6.2lf"); + array_prepend_format (args->lines, "LINE1:%s#%06"PRIx32":%s", + draw_def, def->color, + (def->legend != NULL) ? def->legend : def->ds_name); free (file); + memcpy (args->last_stack_cdef, draw_def, sizeof (args->last_stack_cdef)); + return (0); } /* }}} int def_get_rrdargs */