Inactive [INFO/WEB] Netstats v5.0.4 - Keeps track of player playtime and online status [RB 1.1-R3]

Discussion in 'Inactive/Unsupported Plugins' started by Valrix, Feb 13, 2011.

  1. Offline

    Valrix

    Netstats v5:
    COMPLETE!
    Keep up with development in BukkitDev!
    Netstats - Player Monitoring Plugin:
    Plugin Version: v5.0
    Web Version: v3.0

    Netstats watches players as they join and leave the server and keeps track of how long they've been logged into the server as well as keeping track of their current online/offline status while using very little system resources. The information is stored in a database which is defined by the user. First time using Netstats it will create the config file then disable itself until you change the config to match your database. Then you can reload or restart the server and it'll start collecting information immediately.
    Source Code: Netstats

    OLD CHANGELOG (open)

    Version 4.7
    • Bug fixes
    • If you don't supply a "database" in the config it will attempt to make it's own database named "NetStats" then create the table "netstats" inside it.
    • Fixed repetitive code and unnecessary MySQL connections when doing multiple queries one-after-another (reduces database calls, speeds up the code, and uses less resources).
    • Reduced code complexity (simplified certain calls and removed hacky functions to improve code performance by around 5-10% in my tests)
    Version 4.6
    • Fixed the bug that happened when trying to change the name of your stats table.
    • Fixed the bug that messed up everyone's total play time (sorry)
    • Code improvements and uses less code for database calls
    Version 4.5
    • Fixed the bug where folders weren't being made.
    Version 4.4
    • Converts the total play time to be saved as seconds instead of milliseconds to increase maximum play time. This will now match the PHP code, so if you changed it, change it back.
    • Now disables and re-enables itself instead of reloading the server when doing a wipe
    • Some code improvements
    Version 4.3
    • No longer requires the /lib/ folder since CB already contains the needed drivers
    • v5 is close to being ready and will bring large speed improvements
    Version 4.2
    • Fixes the bug that creates .stats folders instead of files.
    Version 4.1
    • Many code improvements to improve speed and memory usage.
    • Thanks to @jascotty2 for the code to fix how player and mob kills are handled
    Version 4.0
    • Many bug fixes
    • Changed how total play time was saved to the database
    • Fixed a bug with timed events
    • A new and improved Web update is nearly finished
    Version 3.9
    • Should work with RB 617
    Version 3.8
    • Fixed an issue with how files were handled.
    Version 3.7
    • Fixes issue of logged-in users being shown as offline after a reload
    • Fixed file creation bug where .stat files weren't being made properly
    Version 3.6
    • Fixed a bug where, depending on your region, your IP address was logged twice in the database. This was more of an issue with how the IP address was being grabbed than a problem with how it was stored.
    • Few other small fixes to prevent possible future bugs.
    Version 3.5
    • Changed how paths are managed by the plugin to be more OS-independent, hopefully fixing all "file not found" errors.
    • Removed checking if a database password exists or not.
    Version 3.4
    • Improved error logger that create a special log file with the exact info I'll need to find out what caused the problem.
    • Numerous bug fixes and speed tweaks
    Version 3.3
    • Added tracking of distance traveled
    • Added tracking of number of monsters a player has killed
    • Added tracking of number of other players a player has killed
    • Added the date of when the player first joined the server (after this version of Netstats has been installed, will only be correct after a full wipe of other stats)
    • Database will auto-build if it doesn't exist, otherwise it'll add columns if they're needed (so you don't have to do anything to update your database)
    • Config file now auto-updates and allows for comments (they need their own line however)
    • Many other code improvements and fixes to help it run faster and more efficiently.
    Version 3.2
    • Fixed the problem with saving to the database that everyone's been getting. (Only need the JAR)
    Version 3.1
    • Changed the namespace to com.sparkedia.valrix since I did the Java bit.
    Version 3.0
    • Rebuild of v1 to be more efficient.
    • Customized tracking based on "true" or "false"
    • What you don't want tracked won't be watched which improves performance
    • Timed updates (default is 90 seconds)
    • Fixed updating based on total actions user has done (default is 32)
    • Numerous performance tweaks
    • A "pretty" config file
    • Improved web script performance and added customized tracking (make it match your main config, variables are named the same for simplicity)
    • Web view tells when a player is still online and makes their name green if online, red if offline
    • Uses the "hybrid" method of player data saving like v1 to put less strain on the database
    • When saving to a database it is done dynamically so that only changed things are saved to cut down on the code needed and make smaller, faster calls to the database when saving (this was a big improvement on all previous versions)
    • Table name has been changed to "netstats" to not conflict with any other tables
    • NOTICE: You will need to remove your old data since it is outdated and the table is named differently with a few field name changes so make sure to use the .sql file to add it to your database. Please, before complaining about losing all the old data, realize that there's a 99% chance that it's wrong.
    Version 2.0
    • Complete revamp!
    • Now uses only flatfiles to store data, no more database issues!
    • Lots of code removed and improved for faster speed and less resource use
    • Customizable timed updates (default is every 30 seconds)
    • Customized tracking also reduces resource use by registering (or not registering) events as per your config so it only watches events that you want it to.
    • Web script will search for your CraftBukkit server when you first look at the web page.
    • You can choose where the server will save every player's .stats file by setting the "path" option in the config. The path is relative to your main server folder (where the world folder should be at). So if you set "path=../players/" then the .stats files will be in a folder called "players" in the folder that your server is in.
    • Table of player data is built depending on what your tracking and will change as you change the Netstats config file, nice and easy!
    • There are a few rules to setting paths that are listed above, make sure to read them!
    Version 1.8
    • Various code fixes and changes to improve how it runs.
    • Creates a new blank config file if it can't find one.
    • Only JAR has been changed. Get the newest one above, which I'll just reference from now on since it's faster than posting the same link over and over again.
    Version 1.7
    • Changed how files are accessed which should fix the "Too many files open" bug on Linux machines. Update the [JAR]
    Version 1.6
    • Hopefully fixed bug with connecting multiple times to a property file for each user. Only [JAR] needs updating.
    Version 1.5
    • Fixed a critical bug where user property files (where it saved your data before moving it to the database) wasn't re-defined when the plugin was reloaded. Now it looks for it after everything you do to make sure your data is always being recorded. Only the [JAR] needs to be updated.
    Version 1.4
    • Updated the files to work with the new constructor. You'll need only the [JAR] for this update.
    Version 1.3
    • Fixed a bug with how the plugin saves user data after a server crash
    • Added an Update.sql to add new columns to database table [Web.zip] (only for those upgrading from v1.2)
    Version 1.2
    • Added tracking of blocks broken
    • Added tracking of blocks placed
    • Added tracking of player deaths
    • Added more frequent tracking of total time online
    • Implemented new "safety" storage system
    • New storage system reduces number of database calls
    • Improved the way data is stored to database to take less code
    • The table of data is now ordered by who is online
    Version 1.1
    • Added tracking of player's last used IP address
    Version 1.0
    • Release of Netstats
    WEB CHANGELOG (open)

    Version 2.1
    • Some code cleanup and fixes as well as a better auto-updater that makes sure that the updater is the latest version before doing the actual update process.
    • Localization support for 7 different languages.
    • File name changes to be more netstats-specific which will prevent clashes of CSS and other pages.
    • Better include() and require() calls so a page is only added once which speeds up all the pages and keeps them from destroying each other.
    Version 2.0
    • Improved layout
    • Automatic code updates
    Version 1.0
    • Initial release of web code

    Donations: Don't forget to give amd3th some love too since he helped in making Netstats and came up with the idea (you rock!) as well as @marshall007 since he's been awesome by helping me in his spare time.
     
    Phaedrus, Niemand, D-Lew and 5 others like this.
  2. Offline

    NobodyOfNaught

    the numbers being recorded seem wildly inaccurate

    The number of placed blocks is close, but the number of broken block seems to be more like double what I actually broke.

    are way under what they should be, running the plugin for about 30 minutes the highest play time was 8 and my own playtime was still 0.
     
  3. Offline

    Valrix

    It's all accurate, but when it records your stats is based on how much you do, not how long you've been on. When you log in it creates your file and as you do stuff it saves to it until the rate is reached, then it saves to the database. Unless you hit the saveRate number, it won't save until you log out. If the server crashes the data is still safe but what is shown on the web will be inaccurate until the server is back up and the player as joined again so their previous data can be saved.
     
  4. Offline

    NobodyOfNaught

    ok so I've broken and placed alot of blocks and it seems to be accurate on those counts, however perhaps I'm not clear on what "Play Time" indicates, cause I've spent alot more then 4 minutes on the server since I installed the plugin
     
  5. Offline

    Valrix

    Play Time is calculated in milliseconds and the total is constantly being added to itself before saved to the database. As far as I can tell everything is working as it should.
     
  6. Offline

    NobodyOfNaught

    Does the play time get updated in the database at the same time block counts are updated?
     
  7. Offline

    Valrix

    Yes. The default rate of updates is every 32 actions. An action is when you either place or destroy a block. Your total time is constantly being watched and once you hit the action limit it does one last total of how long you've been on and gets the number of deaths, and blocks placed and broken then sends that to the database. Once the data is stored the data in your save file is reset until you reach 32 actions again. However, if the server crashes your data file will still be safe so the next time you log in that data is saved to the database before your file is reset to make sure everything is kept safe at all times.
     
  8. Offline

    Chojin

    Really nice plugin :)

    Btw, can you allow to disable seen files usage ? Because I have many players and I have too much open files (and files are sometimes opened twice or more).
    Thx.
     
  9. Offline

    Valrix

    I'm not sure what you mean..can you explain or show me a log file or something?
     
  10. Offline

    D-Kalck

    I don't know if it has been reported before, but Netstats can't connect to the MySQL database if it uses sockets.
    Whould it be possible to have an option to connect via sockets ?
     
  11. Offline

    Valrix

    What do you mean it doesn't work with sockets? My MySQL runs with a socket in /tmp/mysql.sock on the default port and it works just fine.
     
  12. Offline

    D-Kalck

    I mean it doesn't work if skip-networking is set.
     
  13. Offline

    Valrix

    EDIT: I looked it up to see if there was a workaround and there is not. Java doesn't support UNIX socket connections and has to rely on TCP/IP connections to the database. You'll have to disable --skip-networking to use Netstats.
     
  14. Offline

    NobodyOfNaught

    If you want to disable network access to mysql set the bind-address to the local ip address 127.0.0.1 (this is the default setting in current versions of mysql
    Code:
    bind-address            = 127.0.0.1
    
     
  15. Offline

    Pyroking

    I fixed it! :)
    http://www.epicmark.net/?page_id=76 runs perfect now, besides it count the block destroyed completly wrong, but thats okay, i dont need that. :)

    Thank you!
     
  16. Offline

    Chojin

    with lsof -n :

    COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
    java 30595 minecraft 366w REG 8,5 122 28331459 /home/minecraft/mc/plugins/Netstats/players/PltxVincentx.stats
    java 30595 minecraft 367w REG 8,5 122 28331459 /home/minecraft/mc/plugins/Netstats/players/PltxVincentx.stats
    java 30595 minecraft 368w REG 8,5 122 28331459 /home/minecraft/mc/plugins/Netstats/players/PltxVincentx.stats
    java 30595 minecraft 369w REG 8,5 122 28331459 /home/minecraft/mc/plugins/Netstats/players/PltxVincentx.stats
    [...]
    364 lines for this player for example :/
    Can't you disable stats file usage (and use only db) or fix that ? :)
     
  17. Offline

    Valrix

    Hmm, ok, I think I know why it's doing this and didn't think Java would do it like this. But I know how to fix this so it'll only have one connection to the stat file. Using only a DB would be much more intense than having all these open in fact, but I know how to fix this and will get right on it. Sorry for this, I should have tested that out a bit more, but I also thank you for finding this and bringing it to my attention because now I can fix all my plugins and remember this for future plugins.
    --- merged: Feb 27, 2011 11:31 PM ---
    Ok, well I fixed a few lines that may be responsible. I'll post the update in the changelog which will have the link to the .jar
     
  18. Offline

    vsTerminus

    I'm enjoying your plugin (I am using JSON-P to embed my stats in a page on another domain), although it did crash my server a couple times because of the too many files open problem (I just upgraded to 1.6 now, we'll see how that goes)

    I'm wondering, what are the concerns around storing stats in memory and making one dump to the MySQL database at a user-defined interval, such as once every 2 minutes? In the event of a crash the most you could lose is the length of that interval.

    When you base it on actions, I could have a user sit online for 12 hours AFK, and his total time won't change until he breaks or places a bunch of blocks. It leaves stats wildly out of sync if users aren't actively building or mining.

    Edit: 1.6 didn't help. "Too many open files".
     
  19. Offline

    Chojin

    Yep.
    Still the same problem:
    $ lsof -n | grep players
    java 1540 minecraft 49w REG 8,5 112 3670054 /home/minecraft/mc/plugins/Netstats/players/Martin.stats
    java 1540 minecraft 50w REG 8,5 112 3670054 /home/minecraft/mc/plugins/Netstats/players/Martin.stats
    java 1540 minecraft 51w REG 8,5 112 3670054 /home/minecraft/mc/plugins/Netstats/players/Martin.stats
    java 1540 minecraft 52w REG 8,5 112 3670054 /home/minecraft/mc/plugins/Netstats/players/Martin.stats
    java 1540 minecraft 56u REG 8,5 112 3670053 /home/minecraft/mc/plugins/Netstats/players/Robert.stats
    java 1540 minecraft 60r REG 8,5 112 3670053 /home/minecraft/mc/plugins/Netstats/players/Robert.stats
    java 1540 minecraft 62w REG 8,5 112 3670053 /home/minecraft/mc/plugins/Netstats/players/Robert.stats
    java 1540 minecraft 63w REG 8,5 112 3670053 /home/minecraft/mc/plugins/Netstats/players/Robert.stats
    java 1540 minecraft 65w REG 8,5 112 3670053 /home/minecraft/mc/plugins/Netstats/players/Robert.stats
    java 1540 minecraft 68w REG 8,5 112 3670053 /home/minecraft/mc/plugins/Netstats/players/Robert.stats
    java 1540 minecraft 69w REG 8,5 112 3670053 /home/minecraft/mc/plugins/Netstats/players/Robert.stats
    java 1540 minecraft 70w REG 8,5 112 3670053 /home/minecraft/mc/plugins/Netstats/players/Robert.stats
    java 1540 minecraft 74w REG 8,5 112 3670053 /home/minecraft/mc/plugins/Netstats/players/Robert.stats
    java 1540 minecraft 76r REG 8,5 112 3670053 /home/minecraft/mc/plugins/Netstats/players/Robert.stats
    java 1540 minecraft 83w REG 8,5 112 3670053 /home/minecraft/mc/plugins/Netstats/players/Robert.stats
    [...]
     
  20. Offline

    Valrix

    This is so weird...I'm not seeing this when I try to do testing on it and made sure the code only references the file once so it should never be opening the file more than one time per player, per login. I've also tried watching the plugin usage and files being opened and never saw any of this. What build and OS are you using?
    --- merged: Mar 2, 2011 6:08 PM ---
    I'm trying to figure out why it does this because I haven't heard of others having this issue and I wasn't able to replicate the problem myself. That along with changing the code to check if the file is already set should have kept it from making any more than one file reference per user. Unless CraftBukkit is acting up or Java isn't handling things right I don't know what could make it open up so many file references, but I'll try my best to figure it out.

    I was thinking a little about having timed events, though that would mean that java is constantly checking the time so things may slow down a bit. I'll see how hard it is to schedule events and may add a config option to have it save player data every X amount of time. I think the config would be "time=X" where X is the time in seconds until the player data is forcefully stored so that even inactive players are kept mostly up to date. Also, for those who don't want to have it check based on time then setting it to 0 (zero) will disable that. If and when I do it I will make sure to update the thread to let everyone know about the update.
     
  21. Offline

    Zorkin3

    We have a similar problem on our server. Bukkit build is about 430-440. OS = debian linux. This is the message which is repeating in server log and when it appears, it freeze the server. We use last version of NetStats, and its awesome plugin. But.. we need to help with this problem ^^
     
  22. Offline

    Valrix

    Hmm, thanks for posting that bit of the log. I think I have an idea now as to why it's doing that and I'll try to see if I can fix it. Since I don't have linux and I never run into this problem the most I can do is just change how it saves the property file and updates it. A user running linux would need to test it out for me and see if it's actually working as it should.
     
  23. Offline

    vsTerminus

    Thanks for looking into this. I should also mention that I'm running CraftBukkit-458 on Arch Linux 64bit, and the problem doesn't occur until there are 4 or 5 people Online at the same time.

    Maybe I'll dig around in the source code this weekend and see if I can get a java.util.Timer solution to work.
     
  24. Offline

    Valrix

    I think I found out the problem and once I finish the fix I'll post the update.
     
  25. Offline

    vsTerminus

    Awesome. I'll be sure to test it out when you do.
     
  26. Offline

    Valrix

    Awesome. As a side note I just learned how to attach all my repos to my twitter so anyone who follows me can watch the updates as they get pushed to the repo and even know what I recently did to it.

    EDIT: However, since I'm not the owner of the Netstats repo I can't tweet those updates.
    --- merged: Mar 3, 2011 10:32 PM ---
    Updates are ready and this should fix the issue with too many files being open at once. Which this should also speed things up a bit too. Sorry for those of you who've been battling this.
    --- merged: Mar 4, 2011 3:55 AM ---
    Ok, I've made my own repo of Netstats now so I can manage it a bit better as well as provide updates about it through my twitter. I've also made it available to have issues posted in the repo so if I don't see your problem here you can note it directly in the repo which should also send me an email.
     
  27. Offline

    goldseed

    Can I disable the block-tracking feature? I think it is bothersome to server's HDD.
     
  28. Offline

    Aro2220.com

    I haven't used mysql yet for any of my plugins but this one seems to be worth it.

    However, is it possible to turn some of the features off?

    Features:

    • Monitors player online/offline status
      • this is fantastic
    • Keeps track of last time they were on
      • also fantastic
    • Tracks total time they've been online
      • pretty good, but i would trade it for a way to track how long they've been on 'today'. (I'd say "this session" but there are so many chunk errors in the game that players often relog to fix them which would mess that stat up)
    • Tracks player's last used IP address
      • from an admin standpoint this isn't that important since i don't care too much if they are using the game from another ip and it would be irresponsible for me to post it publicly. at most i could probably find a way to resolve a country from their ip and have a flag next to their name, which could be cool.
    • Tracks number of blocks broken
      • I don't see why this is useful. Sounds like a server with 30 players on at once would be making changes to the mysql database like nuts for this one and the one below it.
    • Tracks number of blocks placed
      • I can't imagine what I'd need this for.
    • Tracks number of time the player has died
      • Not too useful by itself but if, say, you also tracked what they died for so we could have a list of 'most zombie deaths', etc.
     
  29. Offline

    Zorkin3

      • These are the best stats ever. Its awesome to see how many blocks have been placed, it has its own spirit :)
     
  30. Offline

    Jacob Honoré

    It would be very useful if it registered which blocks it broke/placed could be used for some nice stats.
     
  31. Offline

    Valrix

    I still need to add the feature of updating every certain amount of time. Once that's in then I can work on making it so you can turn off things you don't want to track. I'm still in the process of updating all my other plugins at the moment though so these things will have to wait until I've updated everything and added what I told others I will add. But thanks for the suggestion, I'll definitely get this implemented.
    --- merged: Mar 4, 2011 8:41 PM ---
    Although this would be really cool, it would put a bit too much strain on tracking and would put a lot of strain on the database and the server. Sorry, but I can't add this.
     

Share This Page