2 * collection4 - graph_list.c
3 * Copyright (C) 2010 Florian octo Forster
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301 USA
21 * Florian octo Forster <ff at octo.it>
34 #include <sys/types.h>
37 #include <yajl/yajl_parse.h>
39 #include "graph_list.h"
41 #include "filesystem.h"
43 #include "graph_config.h"
44 #include "graph_def.h"
45 #include "graph_ident.h"
46 #include "graph_instance.h"
47 #include "utils_cgi.h"
48 #include "utils_search.h"
51 #include <fcgi_stdio.h>
56 #define UPDATE_INTERVAL 900
57 #define CACHE_FILE "/tmp/collection4.json"
62 static graph_config_t **gl_active = NULL;
63 static size_t gl_active_num = 0;
65 static graph_config_t **gl_staging = NULL;
66 static size_t gl_staging_num = 0;
68 /* Graphs created on-the-fly for files which don't match any existing graph
70 static graph_config_t **gl_dynamic = NULL;
71 static size_t gl_dynamic_num = 0;
73 static char **host_list = NULL;
74 static size_t host_list_len = 0;
76 static time_t gl_last_update = 0;
78 /* TODO: Turn this into an array for multiple data providers. */
79 static data_provider_t *data_provider = NULL;
84 static int gl_add_graph_internal (graph_config_t *cfg, /* {{{ */
85 graph_config_t ***gl_array, size_t *gl_array_num)
89 #define ARRAY_PTR (*gl_array)
90 #define ARRAY_SIZE (*gl_array_num)
95 tmp = realloc (ARRAY_PTR, sizeof (*ARRAY_PTR) * (ARRAY_SIZE + 1));
100 ARRAY_PTR[ARRAY_SIZE] = cfg;
107 } /* }}} int gl_add_graph_internal */
109 static void gl_destroy (graph_config_t ***gl_array, /* {{{ */
110 size_t *gl_array_num)
114 if ((gl_array == NULL) || (gl_array_num == NULL))
117 #define ARRAY_PTR (*gl_array)
118 #define ARRAY_SIZE (*gl_array_num)
120 for (i = 0; i < ARRAY_SIZE; i++)
122 graph_destroy (ARRAY_PTR[i]);
131 } /* }}} void gl_destroy */
133 static int gl_register_host (const char *host) /* {{{ */
141 for (i = 0; i < host_list_len; i++)
142 if (strcmp (host_list[i], host) == 0)
145 tmp = realloc (host_list, sizeof (*host_list) * (host_list_len + 1));
150 host_list[host_list_len] = strdup (host);
151 if (host_list[host_list_len] == NULL)
156 } /* }}} int gl_register_host */
158 static int gl_clear_hosts (void) /* {{{ */
162 for (i = 0; i < host_list_len; i++)
170 } /* }}} int gl_clear_hosts */
172 static int gl_compare_hosts (const void *v0, const void *v1) /* {{{ */
174 return (strcmp (*(char * const *) v0, *(char * const *) v1));
175 } /* }}} int gl_compare_hosts */
177 static int gl_register_file (const graph_ident_t *file, /* {{{ */
178 __attribute__((unused)) void *user_data)
184 for (i = 0; i < gl_active_num; i++)
186 graph_config_t *cfg = gl_active[i];
189 if (!graph_ident_matches (cfg, file))
192 status = graph_add_file (cfg, file);
205 cfg = graph_create (file);
206 gl_add_graph_internal (cfg, &gl_dynamic, &gl_dynamic_num);
207 graph_add_file (cfg, file);
210 gl_register_host (ident_get_host (file));
213 } /* }}} int gl_register_file */
215 static int gl_register_ident (const graph_ident_t *ident, /* {{{ */
216 __attribute__((unused)) void *user_data)
218 /* TODO: Check for duplicates if multiple data providers are used. */
220 return (gl_register_file (ident, user_data));
221 } /* }}} int gl_register_ident */
223 static const char *get_part_from_param (const char *prim_key, /* {{{ */
228 val = param (prim_key);
232 return (param (sec_key));
233 } /* }}} const char *get_part_from_param */
235 static int gl_clear_instances (void) /* {{{ */
239 for (i = 0; i < gl_active_num; i++)
240 graph_clear_instances (gl_active[i]);
243 } /* }}} int gl_clear_instances */
245 static void gl_dump_cb (void *ctx, /* {{{ */
246 const char *str, unsigned int len)
248 int fd = *((int *) ctx);
254 buffer_size = (size_t) len;
255 while (buffer_size > 0)
257 status = write (fd, buffer, buffer_size);
260 fprintf (stderr, "write(2) failed with status %i\n", errno);
265 buffer_size -= status;
267 } /* }}} void gl_dump_cb */
269 static int gl_update_cache (void) /* {{{ */
273 yajl_gen_config handler_config = { /* pretty = */ 1, /* indent = */ " " };
279 memset (&statbuf, 0, sizeof (statbuf));
280 status = stat (CACHE_FILE, &statbuf);
283 if (statbuf.st_mtime >= gl_last_update)
284 /* Not writing to cache because it's at least as new as our internal data */
290 fprintf (stderr, "gl_update_cache: stat(2) failed with status %i\n",
292 /* Continue writing the file if possible. */
295 fd = open (CACHE_FILE, O_WRONLY | O_TRUNC | O_CREAT,
296 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
300 fprintf (stderr, "gl_update_cache: open(2) failed with status %i\n",
305 memset (&lock, 0, sizeof (lock));
306 lock.l_type = F_WRLCK;
307 lock.l_whence = SEEK_SET;
309 lock.l_len = 0; /* lock everything */
313 status = fcntl (fd, F_SETLKW, &lock);
320 fprintf (stderr, "gl_update_cache: fcntl(2) failed with status %i\n", errno);
325 handler = yajl_gen_alloc2 (gl_dump_cb, &handler_config,
326 /* alloc funcs = */ NULL, /* ctx = */ &fd);
333 fprintf (stderr, "gl_update_cache: Start writing data\n");
336 yajl_gen_array_open (handler);
338 for (i = 0; i < gl_active_num; i++)
339 graph_to_json (gl_active[i], handler);
341 for (i = 0; i < gl_dynamic_num; i++)
342 graph_to_json (gl_dynamic[i], handler);
344 yajl_gen_array_close (handler);
346 yajl_gen_free (handler);
349 fprintf (stderr, "gl_update_cache: Finished writing data\n");
353 } /* }}} int gl_update_cache */
356 * JSON parsing functions
358 #define CTX_MASK 0xff000000
359 #define CTX_GRAPH 0x01000000
360 #define CTX_GRAPH_SELECT 0x02000000
361 #define CTX_INST 0x03000000
362 #define CTX_INST_SELECT 0x04000000
363 #define CTX_INST_FILE 0x05000000
365 #define CTX_IDENT_MASK 0x00ff0000
366 #define CTX_IDENT_HOST 0x00010000
367 #define CTX_IDENT_PLUGIN 0x00020000
368 #define CTX_IDENT_PLUGIN_INSTANCE 0x00030000
369 #define CTX_IDENT_TYPE 0x00040000
370 #define CTX_IDENT_TYPE_INSTANCE 0x00050000
372 struct gl_json_context_s
377 graph_instance_t *inst;
378 graph_ident_t *ident;
382 typedef struct gl_json_context_s gl_json_context_t;
384 static void set_state (gl_json_context_t *ctx, /* {{{ */
385 uint32_t new_state, uint32_t mask)
387 uint32_t old_state = ctx->state;
388 ctx->state = (old_state & ~mask) | (new_state & mask);
389 } /* }}} void set_state */
391 static int gl_json_string (void *user_data, /* {{{ */
392 const unsigned char *str,
393 unsigned int str_length)
395 gl_json_context_t *ctx = user_data;
396 char buffer[str_length + 1];
398 memcpy (buffer, str, str_length);
399 buffer[str_length] = 0;
401 if (((ctx->state & CTX_MASK) == CTX_GRAPH_SELECT)
402 || ((ctx->state & CTX_MASK) == CTX_INST_SELECT)
403 || ((ctx->state & CTX_MASK) == CTX_INST_FILE))
405 switch (ctx->state & CTX_IDENT_MASK)
408 ident_set_host (ctx->ident, buffer);
410 case CTX_IDENT_PLUGIN:
411 ident_set_plugin (ctx->ident, buffer);
413 case CTX_IDENT_PLUGIN_INSTANCE:
414 ident_set_plugin_instance (ctx->ident, buffer);
417 ident_set_type (ctx->ident, buffer);
419 case CTX_IDENT_TYPE_INSTANCE:
420 ident_set_type_instance (ctx->ident, buffer);
426 } /* }}} int gl_json_string */
428 static int gl_json_start_map (void *user_data) /* {{{ */
430 gl_json_context_t *ctx = user_data;
432 if (((ctx->state & CTX_MASK) == CTX_GRAPH_SELECT)
433 || ((ctx->state & CTX_MASK) == CTX_INST_SELECT)
434 || ((ctx->state & CTX_MASK) == CTX_INST_FILE))
436 assert (ctx->ident == NULL);
437 ctx->ident = ident_create (ANY_TOKEN,
438 ANY_TOKEN, ANY_TOKEN,
439 ANY_TOKEN, ANY_TOKEN);
443 } /* }}} int gl_json_start_map */
445 static int gl_json_end_map (void *user_data) /* {{{ */
447 gl_json_context_t *ctx = user_data;
449 if ((ctx->state & CTX_MASK) == CTX_GRAPH_SELECT)
453 /* ctx->ident should now hold the valid selector */
454 assert (ctx->cfg == NULL);
455 assert (ctx->inst == NULL);
456 assert (ctx->ident != NULL);
458 for (i = 0; i < gl_active_num; i++)
460 if (graph_compare (gl_active[i], ctx->ident) != 0)
463 ctx->cfg = gl_active[i];
464 ctx->dynamic_graph = 0;
468 if (ctx->cfg == NULL)
470 ctx->cfg = graph_create (ctx->ident);
471 ctx->dynamic_graph = 1;
474 ident_destroy (ctx->ident);
477 set_state (ctx, CTX_GRAPH, CTX_MASK);
479 else if ((ctx->state & CTX_MASK) == CTX_INST_SELECT)
481 /* ctx->ident should now hold the valid selector */
482 assert (ctx->cfg != NULL);
483 assert (ctx->inst == NULL);
484 assert (ctx->ident != NULL);
486 ctx->inst = inst_create (ctx->cfg, ctx->ident);
487 ident_destroy (ctx->ident);
490 set_state (ctx, CTX_INST, CTX_MASK);
492 else if ((ctx->state & CTX_MASK) == CTX_INST_FILE)
494 /* ctx->ident should now hold the valid file */
495 assert (ctx->cfg != NULL);
496 assert (ctx->inst != NULL);
497 assert (ctx->ident != NULL);
499 inst_add_file (ctx->inst, ctx->ident);
500 ident_destroy (ctx->ident);
503 /* Don't reset the state here, files are in an array. */
505 else if ((ctx->state & CTX_MASK) == CTX_INST)
507 /* ctx->inst should now hold a complete instance */
508 assert (ctx->cfg != NULL);
509 assert (ctx->inst != NULL);
510 assert (ctx->ident == NULL);
512 graph_add_inst (ctx->cfg, ctx->inst);
513 /* don't destroy / free ctx->inst */
516 /* Don't reset the state here, instances are in an array. */
518 else if ((ctx->state & CTX_MASK) == CTX_GRAPH)
520 /* ctx->cfg should now hold a complete graph */
521 assert (ctx->cfg != NULL);
522 assert (ctx->inst == NULL);
523 assert (ctx->ident == NULL);
525 if (ctx->dynamic_graph)
526 gl_add_graph_internal (ctx->cfg, &gl_dynamic, &gl_dynamic_num);
527 /* else: already contained in gl_active */
530 /* Don't reset the state here, graphs are in an array. */
534 } /* }}} int gl_json_end_map */
536 static int gl_json_end_array (void *user_data) /* {{{ */
538 gl_json_context_t *ctx = user_data;
540 if ((ctx->state & CTX_MASK) == CTX_INST_FILE)
541 set_state (ctx, CTX_INST, CTX_MASK);
542 else if ((ctx->state & CTX_MASK) == CTX_INST)
543 set_state (ctx, CTX_GRAPH, CTX_MASK);
544 else if ((ctx->state & CTX_MASK) == CTX_GRAPH)
550 } /* }}} int gl_json_end_array */
552 static int gl_json_key (void *user_data, /* {{{ */
553 const unsigned char *str,
554 unsigned int str_length)
556 gl_json_context_t *ctx = user_data;
557 char buffer[str_length + 1];
559 memcpy (buffer, str, str_length);
560 buffer[str_length] = 0;
562 if ((ctx->state & CTX_MASK) == CTX_GRAPH)
564 if (strcasecmp ("select", buffer) == 0)
565 set_state (ctx, CTX_GRAPH_SELECT, CTX_MASK);
566 else if (strcasecmp ("instances", buffer) == 0)
567 set_state (ctx, CTX_INST, CTX_MASK);
569 else if ((ctx->state & CTX_MASK) == CTX_INST)
571 if (strcasecmp ("select", buffer) == 0)
572 set_state (ctx, CTX_INST_SELECT, CTX_MASK);
573 else if (strcasecmp ("files", buffer) == 0)
574 set_state (ctx, CTX_INST_FILE, CTX_MASK);
576 else if (((ctx->state & CTX_MASK) == CTX_GRAPH_SELECT)
577 || ((ctx->state & CTX_MASK) == CTX_INST_SELECT)
578 || ((ctx->state & CTX_MASK) == CTX_INST_FILE))
580 assert (ctx->ident != NULL);
582 if (strcasecmp ("host", buffer) == 0)
583 set_state (ctx, CTX_IDENT_HOST, CTX_IDENT_MASK);
584 else if (strcasecmp ("plugin", buffer) == 0)
585 set_state (ctx, CTX_IDENT_PLUGIN, CTX_IDENT_MASK);
586 else if (strcasecmp ("plugin_instance", buffer) == 0)
587 set_state (ctx, CTX_IDENT_PLUGIN_INSTANCE, CTX_IDENT_MASK);
588 else if (strcasecmp ("type", buffer) == 0)
589 set_state (ctx, CTX_IDENT_TYPE, CTX_IDENT_MASK);
590 else if (strcasecmp ("type_instance", buffer) == 0)
591 set_state (ctx, CTX_IDENT_TYPE_INSTANCE, CTX_IDENT_MASK);
595 } /* }}} int gl_json_key */
597 yajl_callbacks gl_json_callbacks =
600 /* boolean = */ NULL,
601 /* integer = */ NULL,
604 /* string = */ gl_json_string,
605 /* start_map = */ gl_json_start_map,
606 /* map_key = */ gl_json_key,
607 /* end_map = */ gl_json_end_map,
608 /* start_array = */ NULL,
609 /* end_array = */ gl_json_end_array
612 static int gl_read_cache (_Bool block) /* {{{ */
615 gl_json_context_t context;
616 yajl_parser_config handle_config = { /* comments = */ 0, /* check UTF-8 */ 0 };
625 fd = open (CACHE_FILE, O_RDONLY);
628 fprintf (stderr, "gl_read_cache: open(2) failed with status %i\n", errno);
637 memset (&lock, 0, sizeof (lock));
638 lock.l_type = F_RDLCK;
639 lock.l_whence = SEEK_SET;
641 lock.l_len = 0; /* lock everything */
645 status = fcntl (fd, cmd, &lock);
649 if (!block && ((errno == EACCES) || (errno == EAGAIN)))
659 fprintf (stderr, "gl_read_cache: fcntl(2) failed with status %i\n",
665 fprintf (stderr, "gl_read_cache: Opening and locking "
666 "cache file successful\n");
668 memset (&statbuf, 0, sizeof (statbuf));
669 status = fstat (fd, &statbuf);
673 fprintf (stderr, "gl_read_cache: fstat(2) failed with status %i\n",
683 /* Read the file. No excuses. */
685 else if (statbuf.st_mtime <= gl_last_update)
687 /* Our current data is at least as new as the cache. Return. */
688 fprintf (stderr, "gl_read_cache: Not using cache because "
689 "the internal data is newer\n");
694 else if ((statbuf.st_mtime + UPDATE_INTERVAL) < now)
696 /* We'll scan the directory anyway, so there is no need to parse the cache
698 fprintf (stderr, "gl_read_cache: Not using cache because it's too old\n");
704 memset (&context, 0, sizeof (context));
705 context.state = CTX_GRAPH;
708 context.ident = NULL;
710 handle = yajl_alloc (&gl_json_callbacks,
712 /* alloc funcs = */ NULL,
715 fprintf (stderr, "gl_read_cache: Start parsing data\n");
721 char buffer[1024*1024];
723 rd_status = read (fd, buffer, sizeof (buffer));
726 if ((errno == EINTR) || (errno == EAGAIN))
730 fprintf (stderr, "gl_read_cache: read(2) failed with status %i\n",
735 else if (rd_status == 0)
737 yajl_parse_complete (handle);
743 (unsigned char *) &buffer[0],
744 (unsigned int) rd_status);
750 gl_last_update = statbuf.st_mtime;
753 fprintf (stderr, "gl_read_cache: Finished parsing data\n");
757 } /* }}} int gl_read_cache */
762 int gl_add_graph (graph_config_t *cfg) /* {{{ */
764 return (gl_add_graph_internal (cfg, &gl_staging, &gl_staging_num));
765 } /* }}} int gl_add_graph */
767 int gl_config_submit (void) /* {{{ */
769 graph_config_t **old;
773 old_num = gl_active_num;
775 gl_active = gl_staging;
776 gl_active_num = gl_staging_num;
781 gl_destroy (&old, &old_num);
784 } /* }}} int graph_config_submit */
786 int gl_register_data_provider (const char *name, data_provider_t *p) /* {{{ */
788 fprintf (stderr, "gl_register_data_provider (name = %s, ptr = %p)\n",
791 if (data_provider == NULL)
792 data_provider = malloc (sizeof (*data_provider));
793 if (data_provider == NULL)
799 } /* }}} int gl_register_data_provider */
801 int gl_graph_get_all (_Bool include_dynamic, /* {{{ */
802 graph_callback_t callback, void *user_data)
806 if (callback == NULL)
809 gl_update (/* request served = */ 0);
811 for (i = 0; i < gl_active_num; i++)
815 status = (*callback) (gl_active[i], user_data);
820 if (!include_dynamic)
823 for (i = 0; i < gl_dynamic_num; i++)
827 status = (*callback) (gl_dynamic[i], user_data);
833 } /* }}} int gl_graph_get_all */
835 graph_config_t *gl_graph_get_selected (void) /* {{{ */
837 const char *host = get_part_from_param ("graph_host", "host");
838 const char *plugin = get_part_from_param ("graph_plugin", "plugin");
839 const char *plugin_instance = get_part_from_param ("graph_plugin_instance", "plugin_instance");
840 const char *type = get_part_from_param ("graph_type", "type");
841 const char *type_instance = get_part_from_param ("graph_type_instance", "type_instance");
842 graph_ident_t *ident;
846 || (plugin == NULL) || (plugin_instance == NULL)
847 || (type == NULL) || (type_instance == NULL))
850 ident = ident_create (host, plugin, plugin_instance, type, type_instance);
852 gl_update (/* request served = */ 0);
854 for (i = 0; i < gl_active_num; i++)
856 if (graph_compare (gl_active[i], ident) != 0)
859 ident_destroy (ident);
860 return (gl_active[i]);
863 for (i = 0; i < gl_dynamic_num; i++)
865 if (graph_compare (gl_dynamic[i], ident) != 0)
868 ident_destroy (ident);
869 return (gl_dynamic[i]);
872 ident_destroy (ident);
874 } /* }}} graph_config_t *gl_graph_get_selected */
876 /* gl_instance_get_all, gl_graph_instance_get_all {{{ */
877 struct gl_inst_callback_data /* {{{ */
880 graph_inst_callback_t callback;
882 }; /* }}} struct gl_inst_callback_data */
884 static int gl_inst_callback_handler (graph_instance_t *inst, /* {{{ */
887 struct gl_inst_callback_data *data = user_data;
889 return ((*data->callback) (data->cfg, inst, data->user_data));
890 } /* }}} int gl_inst_callback_handler */
892 int gl_graph_instance_get_all (graph_config_t *cfg, /* {{{ */
893 graph_inst_callback_t callback, void *user_data)
895 struct gl_inst_callback_data data =
902 if ((cfg == NULL) || (callback == NULL))
905 return (graph_inst_foreach (cfg, gl_inst_callback_handler, &data));
906 } /* }}} int gl_graph_instance_get_all */
908 int gl_instance_get_all (graph_inst_callback_t callback, /* {{{ */
913 gl_update (/* request served = */ 0);
915 for (i = 0; i < gl_active_num; i++)
919 status = gl_graph_instance_get_all (gl_active[i], callback, user_data);
924 for (i = 0; i < gl_dynamic_num; i++)
928 status = gl_graph_instance_get_all (gl_dynamic[i], callback, user_data);
934 } /* }}} int gl_instance_get_all */
935 /* }}} gl_instance_get_all, gl_graph_instance_get_all */
937 int gl_search (search_info_t *si, /* {{{ */
938 graph_inst_callback_t callback, void *user_data)
941 graph_ident_t *ident;
943 if ((si == NULL) || (callback == NULL))
946 if (search_has_selector (si))
948 ident = search_to_ident (si);
951 fprintf (stderr, "gl_search: search_to_ident failed\n");
960 for (i = 0; i < gl_active_num; i++)
964 if ((ident != NULL) && !graph_ident_intersect (gl_active[i], ident))
967 status = graph_search_inst (gl_active[i], si,
968 /* callback = */ callback,
969 /* user data = */ user_data);
974 for (i = 0; i < gl_dynamic_num; i++)
978 if ((ident != NULL) && !graph_ident_intersect (gl_dynamic[i], ident))
981 status = graph_search_inst (gl_dynamic[i], si,
982 /* callback = */ callback,
983 /* user data = */ user_data);
989 } /* }}} int gl_search */
991 int gl_search_string (const char *term, graph_inst_callback_t callback, /* {{{ */
996 for (i = 0; i < gl_active_num; i++)
1000 status = graph_search_inst_string (gl_active[i], term,
1001 /* callback = */ callback,
1002 /* user data = */ user_data);
1007 for (i = 0; i < gl_dynamic_num; i++)
1011 status = graph_search_inst_string (gl_dynamic[i], term,
1012 /* callback = */ callback,
1013 /* user data = */ user_data);
1019 } /* }}} int gl_search_string */
1021 int gl_search_field (graph_ident_field_t field, /* {{{ */
1022 const char *field_value,
1023 graph_inst_callback_t callback, void *user_data)
1027 if ((field_value == NULL) || (callback == NULL))
1030 for (i = 0; i < gl_active_num; i++)
1034 status = graph_inst_search_field (gl_active[i],
1036 /* callback = */ callback,
1037 /* user data = */ user_data);
1042 for (i = 0; i < gl_dynamic_num; i++)
1046 status = graph_inst_search_field (gl_dynamic[i],
1048 /* callback = */ callback,
1049 /* user data = */ user_data);
1055 } /* }}} int gl_search_field */
1057 int gl_foreach_host (int (*callback) (const char *host, void *user_data), /* {{{ */
1063 for (i = 0; i < host_list_len; i++)
1065 status = (*callback) (host_list[i], user_data);
1071 } /* }}} int gl_foreach_host */
1073 int gl_update (_Bool request_served) /* {{{ */
1079 if (!request_served && (gl_last_update > 0))
1084 if ((gl_last_update + UPDATE_INTERVAL) >= now)
1086 /* Write data to cache if appropriate */
1093 gl_clear_instances ();
1095 gl_destroy (&gl_dynamic, &gl_dynamic_num);
1097 graph_read_config ();
1099 status = gl_read_cache (/* block = */ 1);
1100 /* We have *something* to work with. Even if it's outdated, just get on with
1101 * handling the request and take care of re-reading data later on. */
1102 if ((status == 0) && !request_served)
1106 || ((gl_last_update + UPDATE_INTERVAL) < now))
1108 if (data_provider == NULL)
1110 fprintf (stderr, "No data provider has been registered\n");
1115 gl_clear_instances ();
1117 gl_destroy (&gl_dynamic, &gl_dynamic_num);
1119 /* TODO: Iterate over all data providers */
1120 data_provider->get_idents (data_provider->private_data,
1121 gl_register_ident, /* user data = */ NULL);
1123 gl_last_update = now;
1126 if (host_list_len > 0)
1127 qsort (host_list, host_list_len, sizeof (*host_list),
1130 for (i = 0; i < gl_active_num; i++)
1131 graph_sort_instances (gl_active[i]);
1137 } /* }}} int gl_update */
1139 /* vim: set sw=2 sts=2 et fdm=marker : */