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)
285 fprintf (stderr, "gl_update_cache: Not writing to cache because it's "
286 "at least as new as our internal data\n");
293 fprintf (stderr, "gl_update_cache: stat(2) failed with status %i\n",
295 /* Continue writing the file if possible. */
298 fd = open (CACHE_FILE, O_WRONLY | O_TRUNC | O_CREAT,
299 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
303 fprintf (stderr, "gl_update_cache: open(2) failed with status %i\n",
308 memset (&lock, 0, sizeof (lock));
309 lock.l_type = F_WRLCK;
310 lock.l_whence = SEEK_SET;
312 lock.l_len = 0; /* lock everything */
316 status = fcntl (fd, F_SETLKW, &lock);
323 fprintf (stderr, "gl_update_cache: fcntl(2) failed with status %i\n", errno);
328 handler = yajl_gen_alloc2 (gl_dump_cb, &handler_config,
329 /* alloc funcs = */ NULL, /* ctx = */ &fd);
336 fprintf (stderr, "gl_update_cache: Start writing data\n");
339 yajl_gen_array_open (handler);
341 for (i = 0; i < gl_active_num; i++)
342 graph_to_json (gl_active[i], handler);
344 for (i = 0; i < gl_dynamic_num; i++)
345 graph_to_json (gl_dynamic[i], handler);
347 yajl_gen_array_close (handler);
349 yajl_gen_free (handler);
352 fprintf (stderr, "gl_update_cache: Finished writing data\n");
356 } /* }}} int gl_update_cache */
359 * JSON parsing functions
361 #define CTX_MASK 0xff000000
362 #define CTX_GRAPH 0x01000000
363 #define CTX_GRAPH_SELECT 0x02000000
364 #define CTX_INST 0x03000000
365 #define CTX_INST_SELECT 0x04000000
366 #define CTX_INST_FILE 0x05000000
368 #define CTX_IDENT_MASK 0x00ff0000
369 #define CTX_IDENT_HOST 0x00010000
370 #define CTX_IDENT_PLUGIN 0x00020000
371 #define CTX_IDENT_PLUGIN_INSTANCE 0x00030000
372 #define CTX_IDENT_TYPE 0x00040000
373 #define CTX_IDENT_TYPE_INSTANCE 0x00050000
375 struct gl_json_context_s
380 graph_instance_t *inst;
381 graph_ident_t *ident;
385 typedef struct gl_json_context_s gl_json_context_t;
387 static void set_state (gl_json_context_t *ctx, /* {{{ */
388 uint32_t new_state, uint32_t mask)
390 uint32_t old_state = ctx->state;
391 ctx->state = (old_state & ~mask) | (new_state & mask);
392 } /* }}} void set_state */
394 static int gl_json_string (void *user_data, /* {{{ */
395 const unsigned char *str,
396 unsigned int str_length)
398 gl_json_context_t *ctx = user_data;
399 char buffer[str_length + 1];
401 memcpy (buffer, str, str_length);
402 buffer[str_length] = 0;
404 if (((ctx->state & CTX_MASK) == CTX_GRAPH_SELECT)
405 || ((ctx->state & CTX_MASK) == CTX_INST_SELECT)
406 || ((ctx->state & CTX_MASK) == CTX_INST_FILE))
408 switch (ctx->state & CTX_IDENT_MASK)
411 ident_set_host (ctx->ident, buffer);
413 case CTX_IDENT_PLUGIN:
414 ident_set_plugin (ctx->ident, buffer);
416 case CTX_IDENT_PLUGIN_INSTANCE:
417 ident_set_plugin_instance (ctx->ident, buffer);
420 ident_set_type (ctx->ident, buffer);
422 case CTX_IDENT_TYPE_INSTANCE:
423 ident_set_type_instance (ctx->ident, buffer);
429 } /* }}} int gl_json_string */
431 static int gl_json_start_map (void *user_data) /* {{{ */
433 gl_json_context_t *ctx = user_data;
435 if (((ctx->state & CTX_MASK) == CTX_GRAPH_SELECT)
436 || ((ctx->state & CTX_MASK) == CTX_INST_SELECT)
437 || ((ctx->state & CTX_MASK) == CTX_INST_FILE))
439 assert (ctx->ident == NULL);
440 ctx->ident = ident_create (ANY_TOKEN,
441 ANY_TOKEN, ANY_TOKEN,
442 ANY_TOKEN, ANY_TOKEN);
446 } /* }}} int gl_json_start_map */
448 static int gl_json_end_map (void *user_data) /* {{{ */
450 gl_json_context_t *ctx = user_data;
452 if ((ctx->state & CTX_MASK) == CTX_GRAPH_SELECT)
456 /* ctx->ident should now hold the valid selector */
457 assert (ctx->cfg == NULL);
458 assert (ctx->inst == NULL);
459 assert (ctx->ident != NULL);
461 for (i = 0; i < gl_active_num; i++)
463 if (graph_compare (gl_active[i], ctx->ident) != 0)
466 ctx->cfg = gl_active[i];
467 ctx->dynamic_graph = 0;
471 if (ctx->cfg == NULL)
473 ctx->cfg = graph_create (ctx->ident);
474 ctx->dynamic_graph = 1;
477 ident_destroy (ctx->ident);
480 set_state (ctx, CTX_GRAPH, CTX_MASK);
482 else if ((ctx->state & CTX_MASK) == CTX_INST_SELECT)
484 /* ctx->ident should now hold the valid selector */
485 assert (ctx->cfg != NULL);
486 assert (ctx->inst == NULL);
487 assert (ctx->ident != NULL);
489 ctx->inst = inst_create (ctx->cfg, ctx->ident);
490 ident_destroy (ctx->ident);
493 set_state (ctx, CTX_INST, CTX_MASK);
495 else if ((ctx->state & CTX_MASK) == CTX_INST_FILE)
497 /* ctx->ident should now hold the valid file */
498 assert (ctx->cfg != NULL);
499 assert (ctx->inst != NULL);
500 assert (ctx->ident != NULL);
502 inst_add_file (ctx->inst, ctx->ident);
503 ident_destroy (ctx->ident);
506 /* Don't reset the state here, files are in an array. */
508 else if ((ctx->state & CTX_MASK) == CTX_INST)
510 /* ctx->inst should now hold a complete instance */
511 assert (ctx->cfg != NULL);
512 assert (ctx->inst != NULL);
513 assert (ctx->ident == NULL);
515 graph_add_inst (ctx->cfg, ctx->inst);
516 /* don't destroy / free ctx->inst */
519 /* Don't reset the state here, instances are in an array. */
521 else if ((ctx->state & CTX_MASK) == CTX_GRAPH)
523 /* ctx->cfg should now hold a complete graph */
524 assert (ctx->cfg != NULL);
525 assert (ctx->inst == NULL);
526 assert (ctx->ident == NULL);
528 if (ctx->dynamic_graph)
529 gl_add_graph_internal (ctx->cfg, &gl_dynamic, &gl_dynamic_num);
530 /* else: already contained in gl_active */
533 /* Don't reset the state here, graphs are in an array. */
537 } /* }}} int gl_json_end_map */
539 static int gl_json_end_array (void *user_data) /* {{{ */
541 gl_json_context_t *ctx = user_data;
543 if ((ctx->state & CTX_MASK) == CTX_INST_FILE)
544 set_state (ctx, CTX_INST, CTX_MASK);
545 else if ((ctx->state & CTX_MASK) == CTX_INST)
546 set_state (ctx, CTX_GRAPH, CTX_MASK);
547 else if ((ctx->state & CTX_MASK) == CTX_GRAPH)
553 } /* }}} int gl_json_end_array */
555 static int gl_json_key (void *user_data, /* {{{ */
556 const unsigned char *str,
557 unsigned int str_length)
559 gl_json_context_t *ctx = user_data;
560 char buffer[str_length + 1];
562 memcpy (buffer, str, str_length);
563 buffer[str_length] = 0;
565 if ((ctx->state & CTX_MASK) == CTX_GRAPH)
567 if (strcasecmp ("select", buffer) == 0)
568 set_state (ctx, CTX_GRAPH_SELECT, CTX_MASK);
569 else if (strcasecmp ("instances", buffer) == 0)
570 set_state (ctx, CTX_INST, CTX_MASK);
572 else if ((ctx->state & CTX_MASK) == CTX_INST)
574 if (strcasecmp ("select", buffer) == 0)
575 set_state (ctx, CTX_INST_SELECT, CTX_MASK);
576 else if (strcasecmp ("files", buffer) == 0)
577 set_state (ctx, CTX_INST_FILE, CTX_MASK);
579 else if (((ctx->state & CTX_MASK) == CTX_GRAPH_SELECT)
580 || ((ctx->state & CTX_MASK) == CTX_INST_SELECT)
581 || ((ctx->state & CTX_MASK) == CTX_INST_FILE))
583 assert (ctx->ident != NULL);
585 if (strcasecmp ("host", buffer) == 0)
586 set_state (ctx, CTX_IDENT_HOST, CTX_IDENT_MASK);
587 else if (strcasecmp ("plugin", buffer) == 0)
588 set_state (ctx, CTX_IDENT_PLUGIN, CTX_IDENT_MASK);
589 else if (strcasecmp ("plugin_instance", buffer) == 0)
590 set_state (ctx, CTX_IDENT_PLUGIN_INSTANCE, CTX_IDENT_MASK);
591 else if (strcasecmp ("type", buffer) == 0)
592 set_state (ctx, CTX_IDENT_TYPE, CTX_IDENT_MASK);
593 else if (strcasecmp ("type_instance", buffer) == 0)
594 set_state (ctx, CTX_IDENT_TYPE_INSTANCE, CTX_IDENT_MASK);
598 } /* }}} int gl_json_key */
600 yajl_callbacks gl_json_callbacks =
603 /* boolean = */ NULL,
604 /* integer = */ NULL,
607 /* string = */ gl_json_string,
608 /* start_map = */ gl_json_start_map,
609 /* map_key = */ gl_json_key,
610 /* end_map = */ gl_json_end_map,
611 /* start_array = */ NULL,
612 /* end_array = */ gl_json_end_array
615 static int gl_read_cache (_Bool block) /* {{{ */
618 gl_json_context_t context;
619 yajl_parser_config handle_config = { /* comments = */ 0, /* check UTF-8 */ 0 };
628 fd = open (CACHE_FILE, O_RDONLY);
631 fprintf (stderr, "gl_read_cache: open(2) failed with status %i\n", errno);
640 memset (&lock, 0, sizeof (lock));
641 lock.l_type = F_RDLCK;
642 lock.l_whence = SEEK_SET;
644 lock.l_len = 0; /* lock everything */
648 status = fcntl (fd, cmd, &lock);
652 if (!block && ((errno == EACCES) || (errno == EAGAIN)))
662 fprintf (stderr, "gl_read_cache: fcntl(2) failed with status %i\n",
668 fprintf (stderr, "gl_read_cache: Opening and locking "
669 "cache file successful\n");
671 memset (&statbuf, 0, sizeof (statbuf));
672 status = fstat (fd, &statbuf);
676 fprintf (stderr, "gl_read_cache: fstat(2) failed with status %i\n",
686 /* Read the file. No excuses. */
688 else if (statbuf.st_mtime <= gl_last_update)
690 /* Our current data is at least as new as the cache. Return. */
691 fprintf (stderr, "gl_read_cache: Not using cache because "
692 "the internal data is newer\n");
697 else if ((statbuf.st_mtime + UPDATE_INTERVAL) < now)
699 /* We'll scan the directory anyway, so there is no need to parse the cache
701 fprintf (stderr, "gl_read_cache: Not using cache because it's too old\n");
707 memset (&context, 0, sizeof (context));
708 context.state = CTX_GRAPH;
711 context.ident = NULL;
713 handle = yajl_alloc (&gl_json_callbacks,
715 /* alloc funcs = */ NULL,
718 fprintf (stderr, "gl_read_cache: Start parsing data\n");
724 char buffer[1024*1024];
726 rd_status = read (fd, buffer, sizeof (buffer));
729 if ((errno == EINTR) || (errno == EAGAIN))
733 fprintf (stderr, "gl_read_cache: read(2) failed with status %i\n",
738 else if (rd_status == 0)
740 yajl_parse_complete (handle);
746 (unsigned char *) &buffer[0],
747 (unsigned int) rd_status);
753 gl_last_update = statbuf.st_mtime;
756 fprintf (stderr, "gl_read_cache: Finished parsing data\n");
760 } /* }}} int gl_read_cache */
765 int gl_add_graph (graph_config_t *cfg) /* {{{ */
767 return (gl_add_graph_internal (cfg, &gl_staging, &gl_staging_num));
768 } /* }}} int gl_add_graph */
770 int gl_config_submit (void) /* {{{ */
772 graph_config_t **old;
776 old_num = gl_active_num;
778 gl_active = gl_staging;
779 gl_active_num = gl_staging_num;
784 gl_destroy (&old, &old_num);
787 } /* }}} int graph_config_submit */
789 int gl_register_data_provider (const char *name, data_provider_t *p) /* {{{ */
791 fprintf (stderr, "gl_register_data_provider (name = %s, ptr = %p)\n",
794 if (data_provider == NULL)
795 data_provider = malloc (sizeof (*data_provider));
796 if (data_provider == NULL)
802 } /* }}} int gl_register_data_provider */
804 int gl_graph_get_all (_Bool include_dynamic, /* {{{ */
805 graph_callback_t callback, void *user_data)
809 if (callback == NULL)
812 gl_update (/* request served = */ 0);
814 for (i = 0; i < gl_active_num; i++)
818 status = (*callback) (gl_active[i], user_data);
823 if (!include_dynamic)
826 for (i = 0; i < gl_dynamic_num; i++)
830 status = (*callback) (gl_dynamic[i], user_data);
836 } /* }}} int gl_graph_get_all */
838 graph_config_t *gl_graph_get_selected (void) /* {{{ */
840 const char *host = get_part_from_param ("graph_host", "host");
841 const char *plugin = get_part_from_param ("graph_plugin", "plugin");
842 const char *plugin_instance = get_part_from_param ("graph_plugin_instance", "plugin_instance");
843 const char *type = get_part_from_param ("graph_type", "type");
844 const char *type_instance = get_part_from_param ("graph_type_instance", "type_instance");
845 graph_ident_t *ident;
849 || (plugin == NULL) || (plugin_instance == NULL)
850 || (type == NULL) || (type_instance == NULL))
853 ident = ident_create (host, plugin, plugin_instance, type, type_instance);
855 gl_update (/* request served = */ 0);
857 for (i = 0; i < gl_active_num; i++)
859 if (graph_compare (gl_active[i], ident) != 0)
862 ident_destroy (ident);
863 return (gl_active[i]);
866 for (i = 0; i < gl_dynamic_num; i++)
868 if (graph_compare (gl_dynamic[i], ident) != 0)
871 ident_destroy (ident);
872 return (gl_dynamic[i]);
875 ident_destroy (ident);
877 } /* }}} graph_config_t *gl_graph_get_selected */
879 /* gl_instance_get_all, gl_graph_instance_get_all {{{ */
880 struct gl_inst_callback_data /* {{{ */
883 graph_inst_callback_t callback;
885 }; /* }}} struct gl_inst_callback_data */
887 static int gl_inst_callback_handler (graph_instance_t *inst, /* {{{ */
890 struct gl_inst_callback_data *data = user_data;
892 return ((*data->callback) (data->cfg, inst, data->user_data));
893 } /* }}} int gl_inst_callback_handler */
895 int gl_graph_instance_get_all (graph_config_t *cfg, /* {{{ */
896 graph_inst_callback_t callback, void *user_data)
898 struct gl_inst_callback_data data =
905 if ((cfg == NULL) || (callback == NULL))
908 return (graph_inst_foreach (cfg, gl_inst_callback_handler, &data));
909 } /* }}} int gl_graph_instance_get_all */
911 int gl_instance_get_all (graph_inst_callback_t callback, /* {{{ */
916 gl_update (/* request served = */ 0);
918 for (i = 0; i < gl_active_num; i++)
922 status = gl_graph_instance_get_all (gl_active[i], callback, user_data);
927 for (i = 0; i < gl_dynamic_num; i++)
931 status = gl_graph_instance_get_all (gl_dynamic[i], callback, user_data);
937 } /* }}} int gl_instance_get_all */
938 /* }}} gl_instance_get_all, gl_graph_instance_get_all */
940 int gl_search (search_info_t *si, /* {{{ */
941 graph_inst_callback_t callback, void *user_data)
944 graph_ident_t *ident;
946 if ((si == NULL) || (callback == NULL))
949 if (search_has_selector (si))
951 ident = search_to_ident (si);
954 fprintf (stderr, "gl_search: search_to_ident failed\n");
963 for (i = 0; i < gl_active_num; i++)
967 if ((ident != NULL) && !graph_ident_intersect (gl_active[i], ident))
970 status = graph_search_inst (gl_active[i], si,
971 /* callback = */ callback,
972 /* user data = */ user_data);
977 for (i = 0; i < gl_dynamic_num; i++)
981 if ((ident != NULL) && !graph_ident_intersect (gl_dynamic[i], ident))
984 status = graph_search_inst (gl_dynamic[i], si,
985 /* callback = */ callback,
986 /* user data = */ user_data);
992 } /* }}} int gl_search */
994 int gl_search_string (const char *term, graph_inst_callback_t callback, /* {{{ */
999 for (i = 0; i < gl_active_num; i++)
1003 status = graph_search_inst_string (gl_active[i], term,
1004 /* callback = */ callback,
1005 /* user data = */ user_data);
1010 for (i = 0; i < gl_dynamic_num; i++)
1014 status = graph_search_inst_string (gl_dynamic[i], term,
1015 /* callback = */ callback,
1016 /* user data = */ user_data);
1022 } /* }}} int gl_search_string */
1024 int gl_search_field (graph_ident_field_t field, /* {{{ */
1025 const char *field_value,
1026 graph_inst_callback_t callback, void *user_data)
1030 if ((field_value == NULL) || (callback == NULL))
1033 for (i = 0; i < gl_active_num; i++)
1037 status = graph_inst_search_field (gl_active[i],
1039 /* callback = */ callback,
1040 /* user data = */ user_data);
1045 for (i = 0; i < gl_dynamic_num; i++)
1049 status = graph_inst_search_field (gl_dynamic[i],
1051 /* callback = */ callback,
1052 /* user data = */ user_data);
1058 } /* }}} int gl_search_field */
1060 int gl_foreach_host (int (*callback) (const char *host, void *user_data), /* {{{ */
1066 for (i = 0; i < host_list_len; i++)
1068 status = (*callback) (host_list[i], user_data);
1074 } /* }}} int gl_foreach_host */
1076 int gl_update (_Bool request_served) /* {{{ */
1082 if (!request_served && (gl_last_update > 0))
1087 if ((gl_last_update + UPDATE_INTERVAL) >= now)
1089 /* Write data to cache if appropriate */
1096 gl_clear_instances ();
1098 gl_destroy (&gl_dynamic, &gl_dynamic_num);
1100 graph_read_config ();
1102 status = gl_read_cache (/* block = */ 1);
1103 /* We have *something* to work with. Even if it's outdated, just get on with
1104 * handling the request and take care of re-reading data later on. */
1105 if ((status == 0) && !request_served)
1109 || ((gl_last_update + UPDATE_INTERVAL) < now))
1111 if (data_provider == NULL)
1113 fprintf (stderr, "No data provider has been registered\n");
1118 gl_clear_instances ();
1120 gl_destroy (&gl_dynamic, &gl_dynamic_num);
1122 /* TODO: Iterate over all data providers */
1123 data_provider->get_idents (data_provider->private_data,
1124 gl_register_ident, /* user data = */ NULL);
1126 gl_last_update = now;
1129 if (host_list_len > 0)
1130 qsort (host_list, host_list_len, sizeof (*host_list),
1133 for (i = 0; i < gl_active_num; i++)
1134 graph_sort_instances (gl_active[i]);
1140 } /* }}} int gl_update */
1142 /* vim: set sw=2 sts=2 et fdm=marker : */