-static void
-init_value_list (value_list_t *vl, time_t t, virDomainPtr dom)
-{
- int i, n;
- const char *name;
- char uuid[VIR_UUID_STRING_BUFLEN];
- char *host_ptr;
- size_t host_len;
-
- vl->time = t;
- vl->interval = interval_g;
-
- strncpy (vl->plugin, "libvirt", sizeof (vl->plugin));
- vl->plugin[sizeof (vl->plugin) - 1] = '\0';
-
- vl->host[0] = '\0';
- host_ptr = vl->host;
- host_len = sizeof (vl->host);
-
- /* Construct the hostname field according to HostnameFormat. */
- for (i = 0; i < HF_MAX_FIELDS; ++i) {
- if (hostname_format[i] == hf_none)
- continue;
-
- n = DATA_MAX_NAME_LEN - strlen (vl->host) - 2;
-
- if (i > 0 && n >= 1) {
- strcat (vl->host, ":");
- n--;
- }
-
- switch (hostname_format[i]) {
- case hf_none: break;
- case hf_hostname:
- strncat (vl->host, hostname_g, n);
- break;
- case hf_name:
- name = virDomainGetName (dom);
- if (name)
- strncat (vl->host, name, n);
- break;
- case hf_uuid:
- if (virDomainGetUUIDString (dom, uuid) == 0)
- strncat (vl->host, uuid, n);
- break;
- }
- }
-
- vl->host[sizeof (vl->host) - 1] = '\0';
-} /* void init_value_list */
-
-static void
-cpu_submit (unsigned long long cpu_time,
- time_t t,
- virDomainPtr dom, const char *type)
-{
- value_t values[1];
- value_list_t vl = VALUE_LIST_INIT;
-
- init_value_list (&vl, t, dom);
-
- values[0].counter = cpu_time;
-
- vl.values = values;
- vl.values_len = 1;
-
- plugin_dispatch_values (type, &vl);
-}
-
-static void
-vcpu_submit (counter_t cpu_time,
- time_t t,
- virDomainPtr dom, int vcpu_nr, const char *type)
-{
- value_t values[1];
- value_list_t vl = VALUE_LIST_INIT;
-
- init_value_list (&vl, t, dom);
-
- values[0].counter = cpu_time;
- vl.values = values;
- vl.values_len = 1;
-
- snprintf (vl.type_instance, sizeof (vl.type_instance), "%d", vcpu_nr);
- vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
-
- plugin_dispatch_values (type, &vl);
-}
-
-static void
-submit_counter2 (const char *type, counter_t v0, counter_t v1,
- time_t t,
- virDomainPtr dom, const char *devname)
-{
- value_t values[2];
- value_list_t vl = VALUE_LIST_INIT;
-
- init_value_list (&vl, t, dom);
-
- values[0].counter = v0;
- values[1].counter = v1;
- vl.values = values;
- vl.values_len = 2;
-
- strncpy (vl.type_instance, devname, sizeof (vl.type_instance));
- vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
-
- plugin_dispatch_values (type, &vl);
-} /* void submit_counter2 */
-