graph_instance_t *inst,
__attribute__((unused)) void *user_data)
{
- char buffer[1024];
+ char params[1024];
+ char desc[1024];
- memset (buffer, 0, sizeof (buffer));
- inst_get_params (cfg, inst, buffer, sizeof (buffer));
+ memset (params, 0, sizeof (params));
+ inst_get_params (cfg, inst, params, sizeof (params));
+
+ memset (desc, 0, sizeof (desc));
+ inst_describe (cfg, inst, desc, sizeof (desc));
- printf ("<li><a href=\"test.fcgi?action=graph;%s\">%s</a></li>\n", buffer, buffer);
+ printf ("<li><a href=\"test.fcgi?action=graph;%s\">%s</a></li>\n", params, desc);
return (0);
} /* }}} int print_graph_inst_html */
#include "common.h"
#include "filesystem.h"
-#define IS_ANY(str) (((str) != NULL) && (strcasecmp (ANY_TOKEN, (str)) == 0))
-#define IS_ALL(str) (((str) != NULL) && (strcasecmp (ALL_TOKEN, (str)) == 0))
-
/*
* Data types
*/
#define ANY_TOKEN "/any/"
#define ALL_TOKEN "/all/"
+#define IS_ANY(str) (((str) != NULL) && (strcasecmp (ANY_TOKEN, (str)) == 0))
+#define IS_ALL(str) (((str) != NULL) && (strcasecmp (ALL_TOKEN, (str)) == 0))
+
struct graph_ident_s;
typedef struct graph_ident_s graph_ident_t;
return (NULL);
} /* }}} graph_instance_t *inst_find_matching */
+int inst_describe (graph_config_t *cfg, graph_instance_t *inst, /* {{{ */
+ char *buffer, size_t buffer_size)
+{
+ graph_ident_t *cfg_select;
+
+ if ((cfg == NULL) || (inst == NULL)
+ || (buffer == NULL) || (buffer_size < 2))
+ return (EINVAL);
+
+ cfg_select = graph_get_selector (cfg);
+ if (cfg_select == NULL)
+ {
+ fprintf (stderr, "inst_describe: graph_get_selector failed\n");
+ return (-1);
+ }
+
+ buffer[0] = 0;
+
+#define CHECK_FIELD(field) do { \
+ if (IS_ANY (ident_get_##field (cfg_select))) \
+ { \
+ if (buffer[0] != 0) \
+ strlcat (buffer, "/", buffer_size); \
+ strlcat (buffer, ident_get_##field (inst->select), buffer_size); \
+ } \
+} while (0)
+
+ CHECK_FIELD (host);
+ CHECK_FIELD (plugin);
+ CHECK_FIELD (plugin_instance);
+ CHECK_FIELD (type);
+ CHECK_FIELD (type_instance);
+
+#undef CHECK_FIELD
+
+ if (buffer[0] == 0)
+ strlcat (buffer, "default", buffer_size);
+
+ ident_destroy (cfg_select);
+
+ return (0);
+} /* }}} int inst_describe */
+
/* vim: set sw=2 sts=2 et fdm=marker : */
graph_instance_t *inst_find_matching (graph_instance_t *inst,
const graph_ident_t *ident);
+int inst_describe (graph_config_t *cfg, graph_instance_t *inst,
+ char *buffer, size_t buffer_size);
+
#endif /* GRAPH_INSTANCE_H */
/* vim: set sw=2 sts=2 et fdm=marker : */