diff --git a/src/teamspeak2.c b/src/teamspeak2.c
index 52a1007ed4fcddd300955d3dbd55c40268830e53..2552ad305ffcaa51decb9ab490764a1cc907e4fb 100644 (file)
--- a/src/teamspeak2.c
+++ b/src/teamspeak2.c
#include "common.h"
#include "plugin.h"
#include "common.h"
#include "plugin.h"
-#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
vl.values = values;
vl.values_len = 1;
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.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));
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,
} /* 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
{
/*
* Submits the io rx/tx tuple to the collectd daemon
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
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.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));
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)
} /* void tss2_submit_gauge */
static void tss2_close_socket (void)
char *buffer_ptr;
buffer_ptr = fgets (buffer, sizeof (buffer), global_read_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)
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 */
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)
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,
} /* 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.
{
/*
* Reads the vserver's average packet loss and submits it to collectd.
gauge_t users = NAN;
gauge_t channels = NAN;
gauge_t servers = NAN;
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;
gauge_t packet_loss = NAN;
int valid = 0;
else
{
/* Request server information */
else
{
/* Request server information */
- snprintf (plugin_instance, sizeof (plugin_instance), "vserver%i",
+ ssnprintf (plugin_instance, sizeof (plugin_instance), "vserver%i",
vserver->port);
vserver->port);
- plugin_instance[sizeof (plugin_instance) - 1] = 0;
/* Select the server */
status = tss2_select_vserver (read_fh, write_fh, vserver);
/* Select the server */
status = tss2_select_vserver (read_fh, write_fh, vserver);
* with an error. */
if ((status == 0) && (vserver != NULL))
{
* 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;
if (status == 0)
{
valid |= 0x20;