+int gl_ident_get_rrdargs (graph_config_t *cfg, /* {{{ */
+ graph_instance_t *inst,
+ graph_ident_t *ident,
+ str_array_t *args)
+{
+ char *file;
+ char **dses = NULL;
+ size_t dses_num = 0;
+ int status;
+ size_t i;
+
+ if ((cfg == NULL) || (inst == NULL) || (ident == NULL) || (args == NULL))
+ return (EINVAL);
+
+ file = ident_to_file (ident);
+ if (file == NULL)
+ {
+ GL_DEBUG ("gl_ident_get_rrdargs: ident_to_file returned NULL.\n");
+ return (-1);
+ }
+
+ GL_DEBUG ("gl_ident_get_rrdargs: file = %s;\n", file);
+
+ status = ds_list_from_rrd_file (file, &dses_num, &dses);
+ if (status != 0)
+ {
+ free (file);
+ return (status);
+ }
+
+ for (i = 0; i < dses_num; i++)
+ {
+ int index;
+
+ GL_DEBUG ("gl_ident_get_rrdargs: ds[%lu] = %s;\n", (unsigned long) i, dses[i]);
+
+ index = array_argc (args);
+
+ /* CDEFs */
+ array_append_format (args, "DEF:def_%04i_min=%s:%s:MIN",
+ index, file, dses[i]);
+ array_append_format (args, "DEF:def_%04i_avg=%s:%s:AVERAGE",
+ index, file, dses[i]);
+ array_append_format (args, "DEF:def_%04i_max=%s:%s:MAX",
+ index, file, dses[i]);
+ /* VDEFs */
+ array_append_format (args, "VDEF:vdef_%04i_min=def_%04i_min,MINIMUM",
+ index, index);
+ array_append_format (args, "VDEF:vdef_%04i_avg=def_%04i_avg,AVERAGE",
+ index, index);
+ array_append_format (args, "VDEF:vdef_%04i_max=def_%04i_max,MAXIMUM",
+ index, index);
+ array_append_format (args, "VDEF:vdef_%04i_lst=def_%04i_avg,LAST",
+ index, index);
+
+ /* Graph part */
+ array_append_format (args, "LINE1:def_%04i_avg#%06"PRIx32":%s",
+ index, get_random_color (), dses[i]);
+ array_append_format (args, "GPRINT:vdef_%04i_min:%%lg min,", index);
+ array_append_format (args, "GPRINT:vdef_%04i_avg:%%lg avg,", index);
+ array_append_format (args, "GPRINT:vdef_%04i_max:%%lg max,", index);
+ array_append_format (args, "GPRINT:vdef_%04i_lst:%%lg last\\l", index);
+
+ free (dses[i]);
+ }
+ free (dses);
+
+ free (file);
+
+ return (0);
+} /* }}} int gl_ident_get_rrdargs */
+