/* Check port range */
if ((vserver_port <= 0) || (vserver_port > 65535)) {
ERROR("teamspeak2 plugin: VServer port is invalid: %i", vserver_port);
/* Check port range */
if ((vserver_port <= 0) || (vserver_port > 65535)) {
ERROR("teamspeak2 plugin: VServer port is invalid: %i", vserver_port);
}
/* Allocate memory */
entry = calloc(1, sizeof(*entry));
if (entry == NULL) {
ERROR("teamspeak2 plugin: calloc failed.");
}
/* Allocate memory */
entry = calloc(1, sizeof(*entry));
if (entry == NULL) {
ERROR("teamspeak2 plugin: calloc failed.");
} /* int tss2_add_vserver */
static void tss2_submit_gauge(const char *plugin_instance, const char *type,
} /* int tss2_add_vserver */
static void tss2_submit_gauge(const char *plugin_instance, const char *type,
sstrncpy(vl.plugin, "teamspeak2", sizeof(vl.plugin));
if (plugin_instance != NULL)
sstrncpy(vl.plugin, "teamspeak2", sizeof(vl.plugin));
if (plugin_instance != NULL)
sstrncpy(vl.plugin, "teamspeak2", sizeof(vl.plugin));
if (plugin_instance != NULL)
sstrncpy(vl.plugin, "teamspeak2", sizeof(vl.plugin));
if (plugin_instance != NULL)
*ret_read_fh = global_read_fh;
if (ret_write_fh != NULL)
*ret_write_fh = global_write_fh;
*ret_read_fh = global_read_fh;
if (ret_write_fh != NULL)
*ret_write_fh = global_write_fh;
/* Create file objects from sockets */
global_read_fh = fdopen(sd, "r");
/* Create file objects from sockets */
global_read_fh = fdopen(sd, "r");
ERROR("teamspeak2 plugin: fdopen failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
close(sd);
ERROR("teamspeak2 plugin: fdopen failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
close(sd);
ERROR("teamspeak2 plugin: fdopen failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
tss2_close_socket();
ERROR("teamspeak2 plugin: fdopen failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
tss2_close_socket();
*ret_read_fh = global_read_fh;
if (ret_write_fh != NULL)
*ret_write_fh = global_write_fh;
*ret_read_fh = global_read_fh;
if (ret_write_fh != NULL)
*ret_write_fh = global_write_fh;
} /* int tss2_get_socket */
static int tss2_send_request(FILE *fh, const char *request) {
} /* int tss2_get_socket */
static int tss2_send_request(FILE *fh, const char *request) {
} /* int tss2_send_request */
static int tss2_receive_line(FILE *fh, char *buffer, int buffer_size) {
} /* int tss2_send_request */
static int tss2_receive_line(FILE *fh, char *buffer, int buffer_size) {
ERROR("teamspeak2 plugin: fgets failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
tss2_close_socket();
ERROR("teamspeak2 plugin: fgets failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
tss2_close_socket();
} /* int tss2_receive_line */
static int tss2_select_vserver(FILE *read_fh, FILE *write_fh,
} /* int tss2_receive_line */
static int tss2_select_vserver(FILE *read_fh, FILE *write_fh,
- ssnprintf(command, sizeof(command), "sel %i\r\n", vserver->port);
+ snprintf(command, sizeof(command), "sel %i\r\n", vserver->port);
status = tss2_send_request(write_fh, command);
if (status != 0) {
ERROR("teamspeak2 plugin: tss2_send_request (%s) failed.", command);
status = tss2_send_request(write_fh, command);
if (status != 0) {
ERROR("teamspeak2 plugin: tss2_send_request (%s) failed.", command);
}
/* Get answer */
status = tss2_receive_line(read_fh, response, sizeof(response));
if (status != 0) {
ERROR("teamspeak2 plugin: tss2_receive_line failed.");
}
/* Get answer */
status = tss2_receive_line(read_fh, response, sizeof(response));
if (status != 0) {
ERROR("teamspeak2 plugin: tss2_receive_line failed.");
}
response[sizeof(response) - 1] = 0;
/* Check answer */
if ((strncasecmp("OK", response, 2) == 0) &&
((response[2] == 0) || (response[2] == '\n') || (response[2] == '\r')))
}
response[sizeof(response) - 1] = 0;
/* Check answer */
if ((strncasecmp("OK", response, 2) == 0) &&
((response[2] == 0) || (response[2] == '\n') || (response[2] == '\r')))
ERROR("teamspeak2 plugin: Command ``%s'' failed. "
"Response received from server was: ``%s''.",
command, response);
ERROR("teamspeak2 plugin: Command ``%s'' failed. "
"Response received from server was: ``%s''.",
command, response);
} /* 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,
status = tss2_send_request(write_fh, "gapl\r\n");
if (status != 0) {
ERROR("teamspeak2 plugin: tss2_send_request (gapl) failed.");
status = tss2_send_request(write_fh, "gapl\r\n");
if (status != 0) {
ERROR("teamspeak2 plugin: tss2_send_request (gapl) failed.");
break;
} else if (strncasecmp("ERROR", buffer, 5) == 0) {
ERROR("teamspeak2 plugin: Server returned an error: %s", buffer);
break;
} else if (strncasecmp("ERROR", buffer, 5) == 0) {
ERROR("teamspeak2 plugin: Server returned an error: %s", buffer);
status = tss2_get_socket(&read_fh, &write_fh);
if (status != 0) {
ERROR("teamspeak2 plugin: tss2_get_socket failed.");
status = tss2_get_socket(&read_fh, &write_fh);
if (status != 0) {
ERROR("teamspeak2 plugin: tss2_get_socket failed.");
status = tss2_send_request(write_fh, "gi\r\n");
} else {
/* Request server information */
status = tss2_send_request(write_fh, "gi\r\n");
} else {
/* Request server information */
- ssnprintf(plugin_instance, sizeof(plugin_instance), "vserver%i",
- vserver->port);
+ snprintf(plugin_instance, sizeof(plugin_instance), "vserver%i",
+ vserver->port);
status = tss2_send_request(write_fh, "si\r\n");
}
if (status != 0) {
ERROR("teamspeak2 plugin: tss2_send_request failed.");
status = tss2_send_request(write_fh, "si\r\n");
}
if (status != 0) {
ERROR("teamspeak2 plugin: tss2_send_request failed.");
tss2_submit_gauge(plugin_instance, "gauge", "servers", servers);
if (valid == 0)
tss2_submit_gauge(plugin_instance, "gauge", "servers", servers);
if (valid == 0)
} /* int tss2_read_vserver */
static int tss2_config(const char *key, const char *value) {
} /* int tss2_read_vserver */
static int tss2_config(const char *key, const char *value) {
plugin_register_read("teamspeak2", tss2_read);
plugin_register_shutdown("teamspeak2", tss2_shutdown);
} /* void module_register */
plugin_register_read("teamspeak2", tss2_read);
plugin_register_shutdown("teamspeak2", tss2_shutdown);
} /* void module_register */