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

    Valrix

    You'll also need to set the newTable=player_stats to match your .php config's table. It should alter the default table name of netstats, then you won't have to change it again.

    That exception looks like it wasn't able to increment the number of blocks you've broken, but doesn't seem to have said it can't find the .stats file...try checking out your .stats file to see if it has default values of 0 (zero) or if the .stats even exists. That's the only thing I can think of right now. I had someone point out a bug, so I'm fixing that now.

    A user found a bug in the code that I never noticed and if you noticed inaccurate values showing up, that would be the cause of it. Basically the code that would save everyone's info just before shutting down or when the timed update went off it would only update one player instead of everyone. That means in the next update if you want accurate data you'll have to wipe the table of everyone's info (except the join date, that should be fine), but blocks broken/placed, mobs/players killed, distance traveled, total time played, those will all have to be wiped. To keep everything accurate though it's just best to wipe the whole table clean then make sure you delete all the .stats files inside the players folder. At some point I may make a command that'll do the whole wipe process for you and rebuild everything to make it easier for admins to do this whole process. Actually...I think I'll add that in with the next update, but I'm not sure the most secure way to do it except having a new config option that is called wipePass and Netstats will generate a random password that (hopefully) only the admin will ever know, and to wipe all data from the database table and erase all .stats files the admin will be able to type in /netstats wipe <password> where <password> is whatever you set wipePass to and it'll do the wipe, remove the files, then do a server reload. Since it'll all be in the same function, you'll notice that server may slow down or stop for a brief second to do all this which is perfectly fine because it will prevent anyone from gaining any statistics before it's ready to track them. I'm also gonna see if I can make it a command line command too so the admin won't have to log in. There will also be another config option called admin= where you put in your name (since I'm assuming you're the admin of the server) and you'll be the ONLY person allowed to do the wipe. This way, regardless of whoever tries the password if they happen to figure it out, if they're not you, they can't wipe anything. The admin will also have a the command: /netstats pass which will show you what the current randomly-generated password is. Each time Netstats starts up it'll change the password needed to wipe the database to make sure it stays secure since we know people can already make the server think they're someone else.

    As a notice, it's advisable to have everyone leave the server BEFORE doing the wipe to make sure everything doesn't blow up or something. I'm only human, so I know my code can't be perfect, no matter how hard I try to make it that way. If you can't do that, then rest assured that will all this I'll have plenty of "catches" to be ready for anything you guys can throw at me. It would probably be wise to do the wipe using a different thread to make the memory more efficient, but having it use the same one means it'll force the plugin to wait until the wipe is done before allowing anything else to happen. That's bad when it comes to smooth gameplay, but good when it comes to keeping all the stats nice and accurate. In the future I will have multi-threading set up to manage heavier tasks, but at the moment Netstats is still very lean and quick, so until it starts getting too bloated, which may happen soon depending on how Mojang does stats, it'll remain as a single-threaded plugin.

    TL;DR: I'm fixing bugs, you'll have to wipe all data but I'm making a command for it that requires a password. The password changes every time Netstats starts up/is reloaded. Sorry for the inconvenience, I'm only human.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  3. Offline

    Pyroking

    After buying and reinstall my server i managed to get netstats working again. Now my question is this: is it possible to convert the players ip to a country flag instead with a fast code remake?
     
  4. Offline

    Valrix

    There was one user who was doing this and I'm sure there is a way, though I'll have to figure one out.

    EDIT: I just found a website with an API to do exactly what you want and will be adding it to the code. If you know PHP then you should know where to put this.
    Code:
    <?php
    echo '<img src="http://api.hostip.info/flag.php?ip="'.$ip.'" />';
    ?>
     
  5. Offline

    Pyroking

    For some reason im getting: Error: Your Netstat configuration file cannot be read. Please check the permissions and reload this page.
    Eventho i have permission from root to file on 777... ? I really cant tell why.

    I see, well im not the greatest at php, i know how to tweak a little but implanting is not my game. Would be nice tho to know how! :) Thanks, but maybe i will find a way somehow.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  6. Offline

    Letalis

    I changed to this, but I'm not there quite yet:
    PHP:
        echo '<td>'.date("D, M d g:i A"$login/1000).'</td>';
        echo 
    '<td>'.$atime.'</td>';
        echo 
    '<td>'.$time.'</td>';
        if (
    $trackIP) {
        echo 
    '<td><img src="http://api.hostip.info/flag.php?ip="'.$trackIP .'" /></td>';
        }
        echo 
    '</tr>';
    }
    echo 
    '</table>';
    ?>
     
  7. Offline

    Valrix

    Should be this:
    PHP:
        echo '<td>'.date("D, M d g:i A"$login/1000).'</td>';
        echo 
    '<td>'.$atime.'</td>';
        echo 
    '<td>'.$time.'</td>';
        if (
    $trackIP) {
        echo 
    '<td><img src="http://api.hostip.info/flag.php?ip="'.$ip .'" /></td>';
        }
        echo 
    '</tr>';
    }
    echo 
    '</table>';
    ?>
     
  8. Offline

    Letalis

    I tried that one aswell. but not working :-/
    after the page has loaded it shows "http://api.hostip.info/images/flags/xx.gif"
    [​IMG]
    Its like its not replacing it with IP so it hshows the "not shown picture."
     
  9. Offline

    Valrix

    Try going to their website, maybe your IP isn't recognized or something so they don't know what flag to give.
     
  10. Offline

    Pyroking

    Works! Thank you Letalis and Valrix!
     
  11. Offline

    Valrix

    Glad to hear it :D
     
  12. Offline

    SyPi

    I Modified Netstats a little bit: http://vu2007.admin.hoolsys.de/?page_id=313

    Its now possible to order every row. I also "included" a little feature to highlight selected player as member and track their online Status in an extra Wordpress Widget :).

    [​IMG]

    rudimentary admin panel:
    [​IMG]

    Keep up your good work :)
     
  13. Offline

    Letalis

    Care to share?
     
  14. Offline

    Valrix

    Nice! I was planning on adding that too where you'd be able to sort by each row and possibly multiple rows. Good job on getting a version out first. I hope to get the newest version out sometime soon, but class has been getting in the way. However, I can say that most of the features are already in and I've just got to get the last few in, do a few more tweaks, then do some testing to make sure it'll at least work before deploying a beta version for people to test for me.

    I'm now looking for some help from any graphic artists. If you're interested in helping out with Netstats's web portion (the special surprise that I'm working on) please send me a PM telling me about your interest and any samples you're willing to provide is a big plus. The design work isn't much, but it may be a little tedious, especially for a person like me who's a developer, not a designer.

    Otherwise, if I can get a few suggestions on how achievements should look, that would be helpful too

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  15. Offline

    AreLam

    Looks like 3.9 is working on #670. I had fun seeing the server being up for it's first 24 hours, before glitching for some weird reason, not out of memory either.. :/

    Anyways, thought I'd share with you I show my stats :)
    http://studioare.net/hub/mc (press the graph image.. yeah. don't ask me)
     
  16. Offline

    Valrix

    Pretty sweet. The next update will require a wipe (which I'm going to tweak to be a bit nicer than it is now) but will fix any accuracy issues and the PHP part will have sorting and a design already supplied which of course can be changed. The sorting is done with jQuery so it's fast and is done completely client-side. I've also got to fix a few other things before the web part is ready.
     
  17. Offline

    AreLam

    Require a wipe... I'll be looking forward to go around having to wipe so the server doesn't look all dead :p
     
  18. Offline

    Valrix

    Well by wipe I mean wiping player data. You can decide on a normal wipe that just deletes the .stat files and removes everything except the join data, IP, and name from the database or a full wipe that will remove all data from the database as well as all the .stat files.
     
  19. Offline

    Direct1221

    Possible Features:

    XYZ location
    World they are in
    Home XYZ location

    Thinking these options cause I have 4 sets of stats, Public, Online, Private & Staff.

    I would like to add world they are in to online, XYZ to private, and home XYZ to staff.
     
  20. Offline

    Lord Chaos

    Damn, that sucks...can't you make some sort of import function or something? I don't want to have all the data we've collected for so long be wiped. :(
     
  21. Offline

    Valrix

    Well nearly all the data, if not all of it, is wrong anyway due to past bugs that wouldn't save data correctly. I know it sucks, but isn't it better to have accurate data? Especially if there's going to be achievements.
     
  22. Offline

    Lord Chaos

    Its close to not being worth it. :/ Can't you in some way import the data or at least most of it? The past data does represent quite a bit of achievement for people already, so a bit hard to tell them that they're just going to lose it all.
     
  23. Offline

    Valrix

    Even when it's completely wrong? You won't have to erase the database info, but at the least you will have to bring the server to a halt, delete everyone's .stat files, then start the server again. If you don't do it in that order then the database data will either get corrupted or will be ever more wrong than it is now. As with any plugin you don't HAVE to follow what the dev says, but anything that goes wrong if you don't is purely your own fault.

    If you want to save the data then you can always export the tables or just rename the table to something else and the netstats table will be made again and you can hand copy the data over and adjust it as you want. If you leave it up to me then I will force each field to lose at least half of it's data to try and make it more accurate. So it's your choice now to decide whether to handle it myself or put it upon the admins to handle it.
     
  24. Offline

    marshall007

    This is a fantastic plugin. All the other statistics tracking solutions pale in comparison to the robustness and ease of use this one provides. You seem to keep everything well maintained as well. I have a couple questions regarding the config file. What is the unit of measure for the 'updateRate' parameter, and what does the 'actions' parameter control?

    As for feature requests, what do you think of adding GroupManager/Permissions integration in order for the player's group to be extracted? I'd also like to be able to get the number blocks mined by ore type, which would be fairly easy to implement if you like the idea.

    Thanks for making such a great plugin! Reading through this thread, I hope you decide to stick with this plugin even with the introduction of Mojang's statistics tracking. They probably won't be storing player data unique to individual servers, anyway and they CERTAINLY won't be integrating with Bukkit plugins like you have the potential to do. Thanks again, keep it up!
     
  25. Offline

    SyPi

    "Added Playerheads"

    PHP:
    function create_player_head($name){
        
    $image imagecreatefrompng ("http://s3.amazonaws.com/MinecraftSkins/".$name.".png");
        
    $image1 imagecreate (20,20);
        
    imagecolorallocate($image1255255255);
        
    imagecopyresampled ($image1$image,0,0,8,8,20,20,8,8);
        
    imagepng ($image1,"$absolut_path".$name.".png");
    }
    works with GD (default apache mod)

    [​IMG]
     
  26. Offline

    Valrix

    Thank you for the kind words and support! I've been planning on trying to implement getting data from the Permissions table and iConomy as well so servers running either/both of those plugins can show a player's balance and the group their in, etc.

    If I were to track the types of blocks it would have to wait until the next big update (after this upcoming one) since it'll take a good amount of time to add the individual tracking, then add the way to display that in a nice-looking way on the PHP page. Since I'm also a stickler for using as few resources as possible, I would probably have the block types in a different table and when saved it would use a different memory thread since it would have to iterate through every single block and store the number of blocks of that type that were broken/placed which is hundreds of blocks and would stress out the server. I don't know how to do different memory threads yet though, so that's why it'll have to wait until the next update. Rest assured that many of these ideas are planned but I'm working around classes and having to work on other plugins a lot as well.

    Very nice! I'll add an option to show that and improve the code a little so it won't have to generate a new face each time. We can call this a sneak peek of the next update.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  27. Offline

    marshall007

    Oh, I wasn't trying to suggest logging every single block break, but rather simply the ore blocks. In fact, I doubt many server admins have interest in tracking blocks other than the six different ores, unless they are trying to setup some sort of achievement system. The FoundDiamonds plugin illustrates more of what I was referring to, except only the logging aspect. I modified that plugin to generate an XML file instead of the plain text file it would normally generate, which fits my needs, but isn't nearly as convenient as having that data stored in a database.
    I think you missed this question in my original post. I believe I've figured out the first question, it seems to update in seconds, but I'm still unclear as to what the 'actions' paramater affects. I assume it's something along the lines of the maximum number of writes the plugin can make to the database in a given interval?
     
  28. Offline

    Valrix

    An achievement system is in the works actually and logging all the blocks was also planned.

    Sorry for missing that, I replied shortly after waking up. Your guess was right for updateRate, it's the time in seconds until a command runs to save every player's stat info to the database. The 'actions' option is the number of actions a player must perform in order to have their data saved to the database, this is so active players have their data saved more often while those who don't do much of anything (when it comes to breaking/placing blocks or fighting mobs/players) will have their data saved whenever the plugin runs the function to update everyone. This is a method I came up with to reduce stress on the server.
     
  29. Offline

    Lord Chaos

    There's at least some of the data which is right. Even just the logins that have happened. Currently it also keeps track of everyone who has visited over the last 2 months, which is a really nice thing to have and keep tally of, as it also gives an overview of how many actually visited and used the server. The death count also seems right. I don't know about some of the other data, as I can't use it yet, as I can't connect to the MySQL DB from the web.

    Though honestly, even if the data is wrong in many ways, why not have the option to import data or not. Simply have an option in the options file that says "Convert 3.x version DB=Yes/No", is that really such a big trouble?

    Or at least convert some of the more sure ones, like the name, join date and such.
     
  30. Offline

    Valrix

    The plan was to keep the data that I know would be correct like the first time they joined, their name, and IP. But things that are wrong (everything else at this point due to a few stupid bugs), will need to be wiped. There will be the option of either the full wipe which removes everything, or a normal wipe that will keep the base information like what I mentioned above. Regardless of which wipe you do the .stat files will have to be erased and you'll want to make sure nobody is online when doing all this otherwise problems can occur, even a server crash if not careful.
     
  31. Offline

    SyPi

    Forgot to post. I already have a little "cache check".

    PHP:
    if (file_exists($absolut_path.$name.".png")){
            
    $filetime time() - filemtime($absolut_path.$name.".png");
            if(
    $filetime $cachetime){
                
    create_player_head($name);
            }
     

Share This Page