projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-4.4' into collectd-4.5
[collectd.git]
/
src
/
teamspeak2.c
diff --git
a/src/teamspeak2.c
b/src/teamspeak2.c
index
3bad6b0
..
5cd427a
100644
(file)
--- a/
src/teamspeak2.c
+++ b/
src/teamspeak2.c
@@
-136,12
+136,14
@@
static void tss2_submit_gauge (const char *plugin_instance,
if (plugin_instance != NULL)
sstrncpy (vl.plugin_instance, plugin_instance,
sizeof (vl.plugin_instance));
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,
@@
-165,8
+167,10
@@
static void tss2_submit_io (const char *plugin_instance, const char *type,
if (plugin_instance != NULL)
sstrncpy (vl.plugin_instance, plugin_instance,
sizeof (vl.plugin_instance));
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)
@@
-371,11
+375,8
@@
static int tss2_select_vserver (FILE *read_fh, FILE *write_fh, vserver_list_t *v
char response[128];
int status;
char response[128];
int status;
- DEBUG("teamspeak2 plugin: Select server %i", vserver->port);
-
/* Send request */
/* 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)
@@
-391,10
+392,10
@@
static int tss2_select_vserver (FILE *read_fh, FILE *write_fh, vserver_list_t *v
ERROR ("teamspeak2 plugin: tss2_receive_line failed.");
return (-1);
}
ERROR ("teamspeak2 plugin: tss2_receive_line failed.");
return (-1);
}
- response[sizeof (response)] = 0;
+ response[sizeof (response)
- 1
] = 0;
/* Check answer */
/* Check answer */
- if ((strncmp ("OK", response, 2) == 0)
+ if ((strnc
asec
mp ("OK", response, 2) == 0)
&& ((response[2] == 0)
|| (response[2] == '\n')
|| (response[2] == '\r')))
&& ((response[2] == 0)
|| (response[2] == '\n')
|| (response[2] == '\r')))
@@
-417,9
+418,6
@@
static int tss2_vserver_gapl (FILE *read_fh, FILE *write_fh,
gauge_t packet_loss = NAN;
int status;
gauge_t packet_loss = NAN;
int status;
- DEBUG("teamspeak2 plugin: Get average packet loss (VServer: %i)",
- vserver->port);
-
status = tss2_send_request (write_fh, "gapl\r\n");
if (status != 0)
{
status = tss2_send_request (write_fh, "gapl\r\n");
if (status != 0)
{
@@
-442,7
+440,7
@@
static int tss2_vserver_gapl (FILE *read_fh, FILE *write_fh,
ERROR ("teamspeak2 plugin: tss2_receive_line failed.");
return (-1);
}
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)
if (strncmp ("average_packet_loss=", buffer,
strlen ("average_packet_loss=")) == 0)
@@
-471,7
+469,7
@@
static int tss2_vserver_gapl (FILE *read_fh, FILE *write_fh,
continue;
}
}
continue;
}
}
- else if (strncmp ("OK", buffer, 2) == 0)
+ else if (strnc
asec
mp ("OK", buffer, 2) == 0)
{
break;
}
{
break;
}
@@
-525,8
+523,6
@@
static int tss2_read_vserver (vserver_list_t *vserver)
if (vserver == NULL)
{
/* Request global information */
if (vserver == NULL)
{
/* Request global information */
- DEBUG("teamspeak2 plugin: Read global server information");
-
memset (plugin_instance, 0, sizeof (plugin_instance));
status = tss2_send_request (write_fh, "gi\r\n");
memset (plugin_instance, 0, sizeof (plugin_instance));
status = tss2_send_request (write_fh, "gi\r\n");
@@
-534,11
+530,8
@@
static int tss2_read_vserver (vserver_list_t *vserver)
else
{
/* Request server information */
else
{
/* Request server information */
- DEBUG("teamspeak2 plugin: Read vserver's %i information!", vserver->port);
-
- 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);
@@
-573,13
+566,13
@@
static int tss2_read_vserver (vserver_list_t *vserver)
break;
}
break;
}
- if (strncmp ("ERROR", buffer, 5) == 0)
+ if (strnc
asec
mp ("ERROR", buffer, 5) == 0)
{
ERROR ("teamspeak2 plugin: Server returned an error: %s",
buffer);
break;
}
{
ERROR ("teamspeak2 plugin: Server returned an error: %s",
buffer);
break;
}
- else if (strncmp ("OK", buffer, 2) == 0)
+ else if (strnc
asec
mp ("OK", buffer, 2) == 0)
{
break;
}
{
break;
}
@@
-780,8
+773,6
@@
static int tss2_read (void)
int success = 0;
int status;
int success = 0;
int status;
- DEBUG("teamspeak2 plugin: Poll everything");
-
/* Handle global server variables */
status = tss2_read_vserver (NULL);
if (status == 0)
/* Handle global server variables */
status = tss2_read_vserver (NULL);
if (status == 0)
@@
-808,7
+799,6
@@
static int tss2_read (void)
continue;
}
}
continue;
}
}
- DEBUG("teamspeak2 plugin: Poll done");
if (success == 0)
return (-1);
if (success == 0)
return (-1);