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

    This has been suggested and I'll see how difficult it is since an "entity" is anything that can walk and the method to track deaths is ENTITY_DEATH.
    [MERGETIME="1299877910"][/MERGETIME]
    I need some info from you guys. What's the base structure of your server? By that I mean how are your folders set up so I'll know the best way to have the server script look for your user data without you having to set up a bunch of config options. If you can, please post the folders to show how your whole server would look and where you put the "Web" folder. Hopefully everyone will do it the same way or at least a similar way so everything will work effortlessly.

    EDIT: I ask this because I realize very few people use a home computer for their server so they don't have as much control over the environment and inner workings like I do over mine. You don't have to post, but the more people that do and the more detailed of a look I get the easier it will be on all of you in the end.
     
  3. Offline

    jascotty2

    for me, i have the minecraft server in a home folder: /home/jascotty2/minecraft_server
    apache dir: /var/www (and public minecraft data in /var/www/info)
    (but using mysql, don't need to write there)
     
  4. Offline

    FiZi

    Mine is similar

    Minecraft Server: /home/sa_minecraft/minecraft/
    Minecraft Plugins: /home/sa_minecraft/minecraft/plugins
    Web Directory: /data/wwwPublic/siteMinecraft

    If you were to create a flatfile where the plugins config files are "minecraft/plugins/Netstats" I'd honestly just configure my permissions in a way that the file were accessible via the website. Chances are I'd create a symbolic link for the flatfile in /data/wwwPublic/siteMinecraft and then have my PHP access the symbolic link.

    Something that make things simpler is just having a configurable path as to where the plugin dumps the flatfile.
     
  5. Offline

    Valrix

    So you're running it in a special way then like I do. Though all it would take is a symbolic link on any *nix machine and everything would work perfectly fine. Then for those running on a hosted server they won't be able to have anything away from their root directory so the method I worked on will solve that.

    Currently, here's how it works:
    I have the script run through the document root of your website recursively looking for the first .jar it can find. This way if people change the name of their server JAR to something else it won't make any difference. Once it finds this JAR it'll make note of that folder and use that as the main place to look for info. I think I'll even have it save that to its own config file so it'll only have to do this once and will speed up the rest. Then it grabs the data from every player and will format it just the same as when using the last version.

    For those with special cases, like you have full control, run it on your own computer, etc. Then it only takes one command to create an imaginary link (called a symbolic link) between your Webserver folder and your CraftBukkit folder. Though, if you're smart enough to be running it on your own and know how to keep them apart, you probably already know how to do this. Once I have the PHP ready to do this (which is 95% done as of this post) I will rewrite the plugin to use flatfiles instead, sorry but supporting MySQL is becoming too much of a hassle and my new method of handling the change should be sufficient enough to make it worth getting rid of MySQL support.

    Along with changing the format to flatfiles it will get rid of the config file (Yay!) so that Netstats will be even easier to use. It will be faster, more accurate, and more things will be tracked. I listen to your suggestions and do my best to add them as long as it's not too crazy and I'm sure I could add it without wanting to kill myself afterwards. If all goes well then the update will be out later today.
    [MERGETIME="1299885532"][/MERGETIME]
    Actually, after I just posted above this idea grabbed my interest. I didn't really think of that because it leaves open the possibility of error if you just miss a "/" or something simple like that. I was originally thinking that a scan would work best since it's automated, but I can leave the config file and just have a path property in it that the plugin will look for first and if it doesn't see one it'll just spit it out in my default of "/plugins/Netstats/players"
     
  6. Offline

    FiZi

    @Valrix: That sounds pretty good to me.
     
  7. Offline

    Valrix

    A new idea I've had is to have the PHP use the config data from the plugin that way depending on what you enable/disable to be tracked will show or hide that same data in the table so you won't have to mess with two different config files! I'm going to work on that a bit and see if I can make it more automated than the last one in order to make up for a complete revamp and the long downtime. Also, as I work on it more there will be advanced tracking as well as the page that displays the data being completely built and styled by me (which I'm actually a Web Developer/Designer and learned Java for fun). No more having to make your own pages, etc. Hopefully this will satisfy you guys at least for a little bit :p
     
  8. Offline

    FiZi

    Sounds like things will be easier for the average user which is always good. I personally like coding a bit. Using your current mod I thre w up a global death counter on my server (http://minecraft.fizi.ca). Sucks it isn't accurate yet ;)
     
  9. Offline

    Valrix

    Yeah, the current one really messes up the data. Though once I get this done a lot will be fixed and we'll even be able to track individual blocks. Maybe I should write down everything suggested...
     
  10. Offline

    PrivateAlpha

    Hi! please rename your table to something like 'ns-player' so that it wont clash with other tables >.<
     
  11. Offline

    Valrix

    It won't be using tables soon. It'll be using flatfiles instead.
     
  12. Offline

    needspeed10

    I get that if I start the Server.
    You can see just one Player in the table.
    Code:
    2011-03-13 01:28:56 [SEVERE] [Netstats]: Could not set data for com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'ip' at row 1
     
  13. Offline

    Valrix

    I've suggested to people to not use Netstats until I get v2.0 out since data isn't even accurately recorded to the database.
     
  14. Offline

    jascotty2

    but please leave MySQL as an option..

    another bug you may have to look into: if the server is stopped while players are still logged in, it will show that they are still logged in when it starts up again
     
  15. Offline

    Valrix

    That's not something that can really be fixed because how is the plugin supposed to store that the server has died? It only knows a player is gone when they quit or get kicked. However, I will be setting it up where as the user breaks/places blocks, dies, or triggers another event it will also do an update on their time as well as giving the option to set the server to update every player's statistics after a certain amount of time (which you will be able to set as you see fit). As I work on this I can tell you now that a lot of code is being gutted out and I'm using a new method to track players so it can be done a bit faster and more reliably.

    Also, I apologize but I'm completely removing MySQL support since it is causing WAY too many issues and is just a pain in my ass overall. Usually I'm all for MySQL but since I found a faster, more efficient way of doing this then I'm moving on and dropping all of it. If you want to work on the old "hybrid" version and get it all working you can do so over here. Just fork it and continue working on it.

    On a more positive note, I've already added the option of controlling what you want to track. You will also be able to set the path of the /players folder.
    [MERGETIME="1299998363"][/MERGETIME]
    Actually, if you go bother the guy who helped me make the first Netstats enough, he might work on a MySQL version for you. He's the maker of Spawnr named amd3th
     
  16. Offline

    Revenge

    I manually set the max length for the IP to 50 (it was 30 because of Netstats.sql file) with phpMyAdmin.
    Now it works =)
     
  17. Offline

    needspeed10

    Now it works perfectly thx.
     
  18. Offline

    kankan

    Hello.
    Thank you for the work.
    I am running Craftbukkit version git-Bukkit-0.0.0-497-gea319d1-b503jnks (MC: 1.3)
    I created the database on my local server, .sql imported.
    The script is tracking stats allright (written in /players)
    but as soon as a player connects, the link to the database do not work.
    21:58:48 [GRAVE] [Netstats]: Could not fetch data for mysql: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
    I checked my database info : OK (i am running other DB on this server without pb)
    Any clue ?
    regards
     
  19. Offline

    Valrix

    I'm not really able to help a whole lot and it's a bit stressful to help with the constant database issues. This is why I'm dropping support for it and switching over to a pure file setup.
    [MERGETIME="1300059762"][/MERGETIME]
    Ok, quick update everyone. I finished the Java bit and now I've just got to finish up the PHP script so I can test it out. I have timed updates set up to go off every 30 seconds by default as well as choosing what you want to be tracked which will actually keep things you don't want tracked from being registered by the plugin which greatly cuts down resource usage. The timed update script is also very, very small and fast so will barely even be noticed! You can disable timed updates if you want by setting the "rate" config option to 0 (number zero). Even better, I will have the PHP script watch for what you have enabled and disabled and alter your table accordingly so you'll only need one config file to manage. The PHP script is also automated in trying to find the location of where you store your player data. First it'll look at the config to see if you have the "path" option set and will make it's own local config file to store that path in as well as the path to the config so it can reference that for any changes. I'll explain it all better when it's all actually done.
     
  20. Offline

    jascotty2

    i was referring to onEnable() and onDisable().. have it set all players to "offline" [​IMG]
     
  21. Offline

    Valrix

    Hmm, that could work. But it doesn't help for if the server crashes. I'll add that anyway though since it helps.
    [MERGETIME="1300076807"][/MERGETIME]
    However, there's one issue with this: I'm not sure how to iterate through all files in a folder using Java. Once I figure that out (which will slow down release a bit more) I'll add that. As it is right now, I have the server run one last save when onDisable fires so if the server is forced to go down while players are on it'll do one last save of their total playtime before it goes down.
    [MERGETIME="1300091079"][/MERGETIME]
    Okay everybody, v2.0 is out and working perfectly! Remove your old install and get the new one which takes less files and is much faster and customizable. Check out the changelog for all the cool new things I've done. It took a LOT of work, but I'm pretty proud! :D
     
  22. Offline

    IndianaX

    The index.php miss to read the IP key into the array. ($TrackIP = true => cause error)
    Also I find it confusing what to write into the config.php so I removed all code before the table and just replaced $path in the foreach with the path to players.
     
  23. Offline

    Valrix

    You don't have to write anything in the config.php, it writes everyone on it's own when you first run it, that's why I said it doesn't take any extra configuring except the config.txt in the Netstats folder. I'll double-check the PHP and will update.
    [MERGETIME="1300098200"][/MERGETIME]
    Okay, I added trackIP to the main config and fixed the bug with showing it on the table. Just download it again and move the files into place, start it up, then as soon as someone logs in the player.stats files will start being written and once you view the PHP page it'll do the rest. But it's best to do things in that order otherwise there'll be errors.
     
  24. Offline

    IndianaX

    My problem is that the web-server have it's own user (and a total different location) and php have safemode + openbasedir enabled.
    So I set the path of the plugin to point into a subdirectory of the webserver and changed the directory permissions there.

    But thx for the plugin, good job.
    I modified it so that it works for me. The comment from me was not a bug-report more a information that it could be more easy for special cases where only the players-directory is readable.
     
  25. Offline

    Valrix

    You did catch a bug though which was good. I tried to reach the most people I could with the script but I know that it won't work perfect for everyone and the people with the special cases are usually savvy enough to know what to change to get it to work.
     
  26. Offline

    gothroach

    Darn, I've been eyeing this plugin for a while but when I go to download it, I find the primary feature that attracted me has since been removed.

    Is there any way to read the statistics now from multiple remote servers without mounting up NFS shares or rsync'ing a ridiculous amount?

    I guess I could write a PHP script that would act as a bridge, but I really don't want to install a webserver on that box >.<.
     
  27. Offline

    FiZi

    You'd only need to install php on your other boxes.

    You could write a PHP bridge and then execute if via the command line using a cron job. I was actually thinking of writing a bridge for shits and giggles. First I'm re-writing a chunk of the new PHP Valrix released with v2.0 to try and make things slightly simpler for the more anal of us server admins :)
     
  28. Offline

    xPaw

    ... That's just stupid, i think that's the reason mysql was invented =/
     
  29. Offline

    FiZi

    Guess I wasn't clear....

    The PHP file would read the flatfiles and import the data into a central MySQL server which you could then pull the data from using a web server.... or am I missing something?
     
  30. Offline

    Valrix

    Sorry that taking away the MySQL support makes things a bit difficult on a few of you, but the source of the original is still in tact so another developer could continue work on that or if I happen to get bored enough then I might keep up on two versions. The only problem is how differently each one has to be handled since you don't want the MySQL-based one to save to the database after each block is broken/placed, etc. otherwise resource usage will skyrocket and the server will start lagging a ton. That's why I created the "hybrid" system was so that wouldn't be an issue. However, with what I've learned while making 2.0 I might be able to work that in with v1 Netstats to possibly fix all the problems. I can't have support for both in one plugin or else things will get WAY too messy, so when I can I may try to fix the original.
     
  31. Offline

    stoneLeaf

    Please do try to fix it, I hate the flatfile solution...
    Dropping MySQL was bad idea IMO.

    I hope amd3th will work on a MySQL version. Is he really willing to do so ?
     

Share This Page