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

    Ubersaint

    Server has been restarted and has information being added to the DB but nothing shows up on the get.php.
     
  3. Offline

    Valrix

    Ok, download the zip again and get the new files from the web folder. I've made sure they're the most recent.
     
  4. Offline

    Ubersaint

    hmm ok uploaded and checked the database settings now nothing shows up for the webpage.
     
  5. Offline

    Valrix

    Since I can't really see for myself I'm not able to help. Others have it working just fine. Make sure to double-check the settings.
     
  6. Offline

    maxsteele

    But, you said in the description:
    That doesn't sound like it's all set up. Unless I can just go to the php page you have created already instead of messing with an index file. I'll install the plugin and try that out.

    EDIT:

    I import the netstats.sql file through phpmyadmin, and I get this string of errors:
    Code:
    [B]SQL query:[/B]
    # Dump of table players
    # ------------------------------------------------------------
    CREATE TABLE `players` (
    `id` int( 3 ) NOT NULL AUTO_INCREMENT ,
    `name` text NOT NULL ,
    `enter` bigint( 20 ) NOT NULL ,
    `logout` bigint( 20 ) NOT NULL ,
    `total` bigint( 20 ) NOT NULL DEFAULT '0',
    `status` tinyint( 1 ) NOT NULL ,
    `ip` varchar( 30 ) NOT NULL ,
    PRIMARY KEY ( `id` )
    ) ENGINE = MYISAM DEFAULT CHARSET = latin1;
    
    [B]MySQL said: [/B][URL='http://dev.mysql.com/doc/refman/5.1/en/error-messages-server.html'][IMG]http://forums.bukkit.org/themes/original/img/b_help.png[/IMG][/URL]
    #1046 - No database selected 
    MySQL is set up, and I'm using it for BigBrother and our phpBB3 forums. I used the "download netstats' link you have at the top.
     
  7. Offline

    Valrix

    You can just use the get.php if you want, it just won't look pretty, but it works. It says you didn't choose which database to add the table to. You must first choose the database, then import the .sql
     
  8. Offline

    xPaw

  9. Offline

    Valrix

    Yes, the plugin itself actually grabs the time in milliseconds from the UNIX epoch, January 1, 1970 and stores that in the database. The PHP grabs it and puts it in a time format that makes sense for people, however if you feel like change the PHP, you can have it in any format that you like. Also note that we did add what you suggested, but it's not viewable from the start since most people don't normally need to see their IP address, but if you want it so be shown in the table you only need to uncomment two lines in the get.php file to make it show.
     
  10. Offline

    xPaw

    If you didn't see, i already use the IP part in my page by showing their country flag :)
    About milliseconds.. I dont think that is necessary, seconds would be perfectly fine.

    Also, maybe add something like delayed updating of online time? Like each 10 minutes for example.
     
  11. Offline

    Valrix

    Very nice, and doing it in milliseconds is just how Java does it and it helps it be more precise. I purposefully didn't have it update that from the plugin since it would take more resources than is truly needed and that can actually be done with javascript instead. You would have the PHP print out the time they last logged in, compare it to the javascript timestamp of the current time the user is viewing the page and calculate the total time played that way without taking a performance hit on the server for no reason.
     
  12. Offline

    amd3th

    Maxsteele I did not create an index.php for users, because what I make the style of the webpage may not be what other users want, so I created the web setup to be easily implemented into an existing page of your own formatting. and if you don't want to go through that trouble, you can just link people to the get.php and it will work but it won't look pretty. It would just be a plain table with the data contained in it with no styles applied.
     
  13. Offline

    xPaw

    I personally think that milliseconds are not helping for this case and just the numbers to be bigger.
     
  14. Offline

    Jobsti

    Hey nice. Do you want to add more statistics like deaths, killed monsters, placed blocks etc.?
    Very good idea with SQL!

    And a question, if i have two servers with this plugin (mainworld and Nether), will the data been summate on one db?
     
  15. Offline

    Valrix

    Well that's just how most systems do it by default, it's not like I specifically told it to be that small and to have it do the math to be in seconds would be more unnecessary stuff for it to do before storing it in the database. Besides, it's just as easy for PHP to do the changes on it's end instead of taxing the MC server. It may be small, but in the case of other plugins performing actions as a player logs in and out, I wanted mine to be the least of anyone's worries.
     
  16. Offline

    xPaw

    Well okay! We can live with this ;)

    This is actually interesting idea!
     
  17. Offline

    Valrix

    Thanks. I could add more, but so far all it's meant to do is track play time. But if enough people end up liking this and ask for the same things I can add them to the plugin over time. Placed/broken blocks would be a bit much though since those would fire each time any player would break or place a block, meaning this would happen:

    Player breaks block -> get total blocks broken from database for user -> add one to that number -> store that number.

    Tracking killed monsters could also go wrong since if that's being tracked for everyone, if a bunch of mobs are killed by people that's a bunch of database calls going on which will heavily tax the server which is NOT what I want to happen. However, things that don't happen a lot like deaths and such are more possible.


    To answer the last question, it really depends on how you make the config file. If you choose the same database, then yes. If not, then they will each have their own. I tried to make sure and leave as much open for the user as I could while keeping it lean and simple.
     
  18. Offline

    xPaw

    SQL allows you to increase data without selecting it by doing something like this:
    Code:
    `Anything` = `Anything` + 555
    Also, you can save how much blocks placed/destroyed and when player disconnects, or after some period just update the count without making the high load with live update.
     
  19. Offline

    Valrix

    True, but if the server crashes the data has a very large chance if not 100% chance of being lost which is just as bad. This also means that the plugin is then having to store the data which takes up more resources from the server than needed. Remember, I made this making sure it would do it's job while being very lean, otherwise it would be like the other monitoring plugins that are slow and take up a lot of resources to work. Sometimes less is more.
     
  20. Offline

    Jobsti

    On hey0 I used MCStats
    I loved it, but no one ports it to bukkit. So my statsare very old ;)

    And yep, I mean the same db, if it works, I'm happy ;)
    Will test it on my testserver this evening.
     
  21. Offline

    Valrix

    Yeah, if you use the same DB it'll think both servers are the same.

    I'm willing to add a few things, but not ones that'll fire too many times while the server is running, otherwise it's doing more harm than being useful. So tracking the number of deaths would be fine seeing how a "normal" server doesn't have people dying constantly so the DB calls would be rather few. It's also the point of what would people really care to see from the web. Personally I wouldn't really think anyone could care about how many blocks another player has broken or placed.
     
  22. Offline

    Jobsti

    My members love the stats incl. blocks placed and kilometers traveled, me too ;)

    Whats with a local cachefile (like mcstats), which collect all the data/stats and sync with the db at a fixed time (every 30 min), or command like /syncstats.?!
     
  23. Offline

    Valrix

    Well, the source code is freely available so if another dev wanted to use the methods I use and add those things you'd like then that would be fine. But getting distance traveled is a bit much and tracking the others still seems a bit too much, so I won't be adding them. After a bit I may add a death count though since that seems easy and would be interesting to keep track of.
     
  24. Offline

    niftyapple

    is there a way to program this without the use of SQL? I wouldnt even mind a slight performance hit, i have plenty of room to spare before it is noticeable.
     
  25. Offline

    amd3th

    @niftyapple That's the way I had originally envisioned it so that users wouldn't have to deal with SQL even as simple as it is. I considered Flatfile at first, but that seemed very messy having a bunch of .txt files representing table data. I also considered an XML file which would be clean and simple. It could be possible for people to choose between storage mediums for their data. I'll consult with Valrix and see how hard that would be to implement in the plugin and I'll work on seeing if you can load XML data into an html table.
     
  26. Offline

    niftyapple

    Thanks! I have seen other plugins like LevelCraft that allow you to choose your storage solution. I think he even put it out in a simple update, so i dont imagine it could be too complicated, but then again im not behind your keyboard. Thanks for checking into this!
     
  27. Offline

    amd3th

    Well it looks like XML is out of the question, according to Val it's too much work than it's worth. If we think of any other options we'll let you know.
     
  28. I like your plugin, but, it is a bit to simple :D, what you think to make it easier to see who is online to make Offline in RED and Online in GREEN.
    Mine looks like this cos i just made my tables a bit bigger: http://sapphira.org/minecraft/
     
  29. Offline

    Valrix

    I checked out XML and it takes at least 3 times more code and space per user. Plus, it's not easy for PHP to grab individual files and read the data, that's why I chose a database. Usually databases are frowned upon, especially when making plugins (you can find the large debate thread about it rather quickly) and this would be an example of a time where a database is acceptable.
     
  30. Hi, all for all who like Online in Green and Offline in Red can use what i made out of mine.
    the files are attached i hope Valrix is fine with it :D
    Demo: http://sapphira.org/minecraft/
     
  31. Offline

    nakashimakun

    Thanks for that ItsCriminal. I hadn't had time to look at the files to code anything yet but I was gunna do that now it saves me doing it :)
     

Share This Page