X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fteamspeak2.c;h=7528406cc61a131e9fa276dcdacb1fe3345f23fc;hb=aff80830f1154a5b6c4da16a0b1033aafde14e24;hp=b7992d808524ded44b81678cd8da890a8970546f;hpb=409d90064967451241f5fcc672a26269142e1735;p=collectd.git diff --git a/src/teamspeak2.c b/src/teamspeak2.c index b7992d80..7528406c 100644 --- a/src/teamspeak2.c +++ b/src/teamspeak2.c @@ -129,23 +129,24 @@ static void tss2_submit_gauge (const char *plugin_instance, vl.values = values; vl.values_len = 1; - vl.time = time (NULL); sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "teamspeak2", sizeof (vl.plugin)); if (plugin_instance != NULL) sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); - + + sstrncpy (vl.type, type, sizeof (vl.type)); + if (type_instance != NULL) sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void tss2_submit_gauge */ static void tss2_submit_io (const char *plugin_instance, const char *type, - counter_t rx, counter_t tx) + derive_t rx, derive_t tx) { /* * Submits the io rx/tx tuple to the collectd daemon @@ -153,20 +154,21 @@ static void tss2_submit_io (const char *plugin_instance, const char *type, value_t values[2]; value_list_t vl = VALUE_LIST_INIT; - values[0].counter = rx; - values[1].counter = tx; + values[0].derive = rx; + values[1].derive = tx; vl.values = values; vl.values_len = 2; - vl.time = time (NULL); sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "teamspeak2", sizeof (vl.plugin)); if (plugin_instance != NULL) sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); - - plugin_dispatch_values (type, &vl); + + sstrncpy (vl.type, type, sizeof (vl.type)); + + plugin_dispatch_values (&vl); } /* void tss2_submit_gauge */ static void tss2_close_socket (void) @@ -372,8 +374,7 @@ static int tss2_select_vserver (FILE *read_fh, FILE *write_fh, vserver_list_t *v int status; /* Send request */ - snprintf (command, sizeof (command), "sel %i\r\n", vserver->port); - command[sizeof (command) - 1] = 0; + ssnprintf (command, sizeof (command), "sel %i\r\n", vserver->port); status = tss2_send_request (write_fh, command); if (status != 0) @@ -389,7 +390,7 @@ static int tss2_select_vserver (FILE *read_fh, FILE *write_fh, vserver_list_t *v ERROR ("teamspeak2 plugin: tss2_receive_line failed."); return (-1); } - response[sizeof (response)] = 0; + response[sizeof (response) - 1] = 0; /* Check answer */ if ((strncasecmp ("OK", response, 2) == 0) @@ -405,7 +406,7 @@ static int tss2_select_vserver (FILE *read_fh, FILE *write_fh, vserver_list_t *v } /* int tss2_select_vserver */ static int tss2_vserver_gapl (FILE *read_fh, FILE *write_fh, - vserver_list_t *vserver, gauge_t *ret_value) + gauge_t *ret_value) { /* * Reads the vserver's average packet loss and submits it to collectd. @@ -437,7 +438,7 @@ static int tss2_vserver_gapl (FILE *read_fh, FILE *write_fh, ERROR ("teamspeak2 plugin: tss2_receive_line failed."); return (-1); } - buffer[sizeof (buffer)] = 0; + buffer[sizeof (buffer) - 1] = 0; if (strncmp ("average_packet_loss=", buffer, strlen ("average_packet_loss=")) == 0) @@ -497,10 +498,10 @@ static int tss2_read_vserver (vserver_list_t *vserver) gauge_t users = NAN; gauge_t channels = NAN; gauge_t servers = NAN; - counter_t rx_octets = 0; - counter_t tx_octets = 0; - counter_t rx_packets = 0; - counter_t tx_packets = 0; + derive_t rx_octets = 0; + derive_t tx_octets = 0; + derive_t rx_packets = 0; + derive_t tx_packets = 0; gauge_t packet_loss = NAN; int valid = 0; @@ -527,9 +528,8 @@ static int tss2_read_vserver (vserver_list_t *vserver) else { /* Request server information */ - snprintf (plugin_instance, sizeof (plugin_instance), "vserver%i", + ssnprintf (plugin_instance, sizeof (plugin_instance), "vserver%i", vserver->port); - plugin_instance[sizeof (plugin_instance) - 1] = 0; /* Select the server */ status = tss2_select_vserver (read_fh, write_fh, vserver); @@ -677,7 +677,7 @@ static int tss2_read_vserver (vserver_list_t *vserver) * with an error. */ if ((status == 0) && (vserver != NULL)) { - status = tss2_vserver_gapl (read_fh, write_fh, vserver, &packet_loss); + status = tss2_vserver_gapl (read_fh, write_fh, &packet_loss); if (status == 0) { valid |= 0x20;