X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fteamspeak2.c;h=502145d36dc89bd459be4f32636da13747510665;hp=52a1007ed4fcddd300955d3dbd55c40268830e53;hb=61a1fa91ba73e4fe3a34949f77c5f017056f2b7a;hpb=59ede0a59ff1c409ec04bd38de7d0058639d5aa9 diff --git a/src/teamspeak2.c b/src/teamspeak2.c index 52a1007e..502145d3 100644 --- a/src/teamspeak2.c +++ b/src/teamspeak2.c @@ -129,19 +129,20 @@ 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, @@ -158,15 +159,16 @@ static void tss2_submit_io (const char *plugin_instance, const char *type, 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) @@ -297,6 +299,13 @@ static int tss2_get_socket (FILE **ret_read_fh, FILE **ret_write_fh) char *buffer_ptr; buffer_ptr = fgets (buffer, sizeof (buffer), global_read_fh); + if (buffer_ptr == NULL) + { + WARNING ("teamspeak2 plugin: Unexpected EOF received " + "from remote host %s:%s.", + config_host ? config_host : DEFAULT_HOST, + config_port ? config_port : DEFAULT_PORT); + } buffer[sizeof (buffer) - 1] = 0; if (memcmp ("[TS]\r\n", buffer, 6) != 0) @@ -372,8 +381,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) @@ -405,7 +413,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. @@ -527,9 +535,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 +684,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;