Forum


Notice to all users

We are migrating towards a new forum system located at community.teamspeak.com, as such this forum will become read-only on January 29, 2020

Results 1 to 12 of 12
  1. #1
    Join Date
    August 2014
    Posts
    27

    Solved Get all clients from all server groups

    So here's the deal:
    I need to get all clients from all server groups. Getting all the server groups is not a problem, I simply use requestServerGroupList and store the IDs. What is a bit problematic is getting all the clients from a particular server group. There is a function called requestServerGroupClientList, which shows it's results via a method onServerGroupClientListEvent, which is all cool etc, but the problem is that I can't tell if it actually results in scanning through all the server groups or not. Since I have the request in a loop for each server group, I can't tell if it actually scans through all the groups because the output I see only shows the last of server groups which kinda suggests is actually scans through all of them, but does it really? The server group I'm worried about has a smaller ID than others, which means it comes earlier than others (and I can't see it in the output) and it has thousands of clients (an this is where most of the dead clients reside). It would be ideal if I could use onServerGroupClientListFinishedEvent, so I could move to the next server group once it's done with the one at hand, but unfortunately there is no such thing.
    Can anyone shed some light on this? Do all the server groups get scanned or do some of them get interrupted? Perhaps any suggestions on how to guarantee a successful scan through all server groups?

    Here's the situation if anyone is interested:
    Over time, our clientbase has grown a lot and we have a lot of clients that have breached the 30 day clientkeeptime, but are not deleted simply because they are in a server group or two. While the server manages to get rid of clients that are in no groups whatsoever, the problem of the dead clients that are in server groups is ever growing and I believe we all agree that a regular clean up is a good thing.
    So I came up with an idea to create a script (in C) that finds all the server groups on the server and all the clients in them. I'd then provide a list of dead clients' unique identities, pulled directly from the database, and the script would then compare every single unique identity that comes up while scanning through server groups to the list that I've provided and if a positive match is found, remove that particular client from that server group, thus giving the server the ability to finally get rid of those dead clients.

  2. #2
    Join Date
    September 2012
    Posts
    6,079
    Code:
    void ts3plugin_onServerGroupClientListEvent(uint64 serverConnectionHandlerID, uint64 serverGroupID, uint64 clientDatabaseID, const char* clientNameIdentifier, const char* clientUniqueID) {
    }
    you do have the servergroupID in there so you know whether or not a particular group got scanned. It shouldn't get interrupted but then again I never personally tried that function, certainly not with a larger dataset.

    In any case this would be easier done using serverquery as there you can just use clientdblist which gives you the list of all clients in the database for the currently selected server including the last time they connected. You could then check to see if the last connection time is within a certain time period and if not use servergroupsbyclientid to get all the server groups that client is in and call servergroupdelclient for each group that client is in.
    You could even just call clientdbdelete for every client that hasn't connected in the time period you care about to instantly wipe that client, instead of going through the server groups of the client and removing them from the groups, which would speed up the process even further and doesn't require a server restart to actually get rid of them.

    Unlike a plugin this is not limited to a client and can be run in intervals through a cronjob directly on the server, is fully automatic and likely even faster.
    Last edited by Chris; November 27th, 2014 at 04:05 PM.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  3. #3
    Join Date
    August 2014
    Posts
    27
    Ok, I must say I'm completely new to crons (had never even actually heard of them before). The server does run on Linux though (CentOS). So it's possible to create a cronjob that logs in to the server via serverquery, pulls the list of all the clients, checks their last online time and then deletes them if they have been offline for too long? Just trying to see if I understood correctly.
    In the mean time, I'll try to invent something with the servergroupID to see if all the groups actually do get scanned for anyone that might be wondering the same thing in the future. Using a plugin gives me the option to make exceptions in few cases, not sure if that's possible with the cronjob management.

  4. #4
    Join Date
    August 2014
    Posts
    27
    So to anyone wondering the same thing in the future, don't worry - all the groups get scanned 100%. I guess it's just that by the time the plugin is free to show output in the console it has already scanned through quite a lot (because server will start feeding you all the clients in the server group upon request and every time data is received for a client the method onServerGroupClientListEvent is called) and something probably decides to not show 100% of it (or it just prints it and skips over it so fast it's impossible to notice). However, I forced it to print everything into the file and all the clients were in there.
    The script I designed worked wonders. In total there were 3255 dead clients and in total there were 3600 server group removals. A few minutes later the server got rid of ~800 dead clients, I guess the rest will go a bit later (actually, how often does the server check if a client has passed the clientkeep deadline?).

  5. #5
    Join Date
    June 2011
    Location
    Germany
    Posts
    4,368
    Ehm, what's the problem with simply deleting everyone who's offline for longer than 30 days?

  6. #6
    Join Date
    August 2014
    Posts
    27
    I'd then have to copy the database, delete everyone that has been offline longer than 30 days, put the database back and restart the server. I figured that freeing all the troublesome clients from their groups and letting the server worry about the rest was safer and doesn't require a restart.

  7. #7
    Join Date
    September 2012
    Posts
    6,079
    There is the List all clients dialog which can delete clients from the database too, but given the amount of clients you had, automating it like this is faster, easier and far less tedious than doing it all manually.

    Plus modifying the database directly is not supported so yeah
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  8. #8
    Join Date
    June 2011
    Location
    Germany
    Posts
    4,368
    clientdbdelete

  9. #9
    Join Date
    August 2014
    Posts
    27
    That was already said, but not how to use it on 3000+ clients.

  10. #10
    Join Date
    September 2012
    Posts
    6,079
    Quote Originally Posted by numma_cway View Post
    clientdbdelete
    Just in case you didn't realize: This topic was already done with before you started chiming in
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  11. #11
    Join Date
    June 2011
    Location
    Germany
    Posts
    4,368
    He asked how to do that, and in my opinion, there are easier ways to do that (e.g. in the way deleted by you). If 3000 inactive people are in server groups, simple math tells you that you must run servergroupclientdel at least as often as clientdbdelete, plus multiple queries of servergroupclient. So his original solution made no sense at all by the means of efficiency.

    This is so silly.

  12. #12
    Join Date
    September 2012
    Posts
    6,079
    Quote Originally Posted by numma_cway View Post
    He asked how to do that, and in my opinion, there are easier ways to do that (e.g. in the way deleted by you). If 3000 inactive people are in server groups, simple math tells you that you must run servergroupclientdel at least as often as clientdbdelete, plus multiple queries of servergroupclient. So his original solution made no sense at all by the means of efficiency.

    This is so silly.
    I agree on the inefficiency part, hence my very first reply to this topic mentions using clientdbdelete to save calls and make it more efficient. It also focuses on doing this through serverquery as it's generally the better / faster / easier way for this sort of things.

    I included an explanation / answer to his original question for explanation / completeness.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. I can not see the Clients list for any of my server groups
    By Whimpykids in forum Permission System
    Replies: 0
    Last Post: July 7th, 2015, 06:43 PM
  2. Getting Server Groups of Clients
    By Dione in forum Client Plugins / Lua Scripts
    Replies: 2
    Last Post: July 28th, 2014, 08:52 PM
  3. Replies: 7
    Last Post: April 17th, 2012, 06:07 PM
  4. Server Groups Filter for Clients
    By house in forum Suggestions and Feedback
    Replies: 1
    Last Post: February 17th, 2010, 08:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •