- else if (is_eq(TELNET_OK, buff) == 0) {
- /*
- * VServer selected, now request its information
- */
- collected = 0; /* Counts the number of variables found in the reply */
-
- if (do_request(S_REQUEST) == -1) {
- /* Failed */
- WARNING("teamspeak2 plugin: Collect info about server '%d' failed", tmp->port);
- tmp = tmp->next;
- continue;
- }
-
- for(;;) {
- /* Request a line with a timeout of 200ms */
- if (do_recv_line(buff, TELNET_BUFFSIZE, 200000) !=0 ) {
- ERROR("teamspeak2 plugin: Connection error");
- return -1;
- }
-
- /*
- * Collect the received data
- */
- if (is_eq(S_USERS_ONLINE, buff) == 0) {
- /* Number of users online */
- users_online = (int)eval_eq(S_USERS_ONLINE, buff);
- collected += 1;
- }
- else if (is_eq(S_PACKETS_SEND, buff) == 0) {
- /* Number of packets send */
- packets_send = eval_eq(S_PACKETS_SEND, buff);
- collected += 1;
- }
- else if (is_eq(S_PACKETS_REC, buff) == 0) {
- /* Number of packets received */
- packets_received = eval_eq(S_PACKETS_REC, buff);
- collected += 1;
- }
- else if (is_eq(S_BYTES_SEND, buff) == 0) {
- /* Number of bytes send */
- bytes_send = eval_eq(S_BYTES_SEND, buff);
- collected += 1;
- }
- else if (is_eq(S_BYTES_REC, buff) == 0) {
- /* Number of bytes received */
- bytes_received = eval_eq(S_BYTES_REC, buff);
- collected += 1;
- }
- else if (is_eq(TELNET_OK, buff) == 0) {
- /*
- * Received end of transmission flag, break the loop
- */
- break;
- }
- else if (is_eq(TELNET_ERROR, buff) == 0) {
- /* Error, not good */
- ERROR("teamspeak2 plugin: server '%d' reported error '%s'", tmp->port, buff);
- return -1;
- }
- }
-
- if (collected < 5) {
- /* Not all expected values were received */
- ERROR("teamspeak2 plugin: Couldn't collect all values of server '%d' (%d)", tmp->port, collected);
- tmp = tmp->next;
- continue; /* Continue with the next VServer */
- }
-
- /* Forward values to connectd */
- sprintf(buff,"%d",tmp->port);
- tss2_submit(users_online, bytes_send, bytes_received, packets_send, packets_received, buff);
+ sfree (config_port);
+ config_port = temp;
+ }
+ else if (strcasecmp ("Server", key) == 0)
+ {
+ /* Server variable found */
+ int status;
+
+ status = tss2_add_vserver (atoi (value));
+ if (status != 0)
+ return (1);
+ }
+ else
+ {
+ /* Unknow variable found */
+ return (-1);
+ }
+
+ return 0;
+} /* int tss2_config */
+
+static int tss2_read (void)
+{
+ vserver_list_t *vserver;
+ int success = 0;
+ int status;
+
+ /* Handle global server variables */
+ status = tss2_read_vserver (NULL);
+ if (status == 0)
+ {
+ success++;
+ }
+ else
+ {
+ WARNING ("teamspeak2 plugin: Reading global server variables failed.");
+ }