-
Notifications
You must be signed in to change notification settings - Fork 1
Command Line Analytics Script
The transaction log of Auth Redux has always served a dual purpose. Besides protecting against data loss and corruption, it also permits efficient reporting and analysis. Therefore, I've included a command-line analytics script for just this purpose!
You can review wide variety of server and player metrics for any given 24-hour period:
-
Total Players
total number of unique players that joined per day -
Total New Players
total number of new players that joined per day -
Total Player Sessions
total number of player sessions per day -
Total Login Failures
total number of failed logins per day -
Total Login Attempts
total number of attempted logins per day -
Overall Server Uptime
aggregate uptime percentage of the server per day -
Maximum Connected Clients
maximum number of connected clients per day -
Minimum Connected Clients
minimum number of connected clients per day -
Maximum Player Lifetime
maximum session duration amongst all players per day -
Average Player Lifetime
average session duration amongst all players per day
Most of these statistics are also broken up into an hour-by-hour format. The following statistics are player-specific:
-
Total Sessions
total number of sessions of each player -
Total Lifetime
aggregate session duration of each player
Generating reports of player login activity is both quick and easy. It can even be accomplished while the server is still online. From the shell, change to the tools subdirectory and issue the following command:
cd auth_rx/tools
awk -f report.awk -v days=1 -v type=txt ~/.minetest/worlds/new_survival/auth.dbx
Given a "days" parameter of 1 and a type parameter of "txt" ,this will analyze the journal file in the "new_survival" world, and generate a plain-text report of player login activity for yesterday. Changing the "days" parameter to 0 will obtain data from today. So on and so forth.
Here is an example of the results for the JT2 server on April 7, 2018.
You can optionally redirect output to a file or even pipe to another command. This would be useful for receiving automated daily reports by email. Here's a quick tutorial on how to set this up as a cron job: Sending Email Alerts Through Cron
By changing the "type" parameter to "js, the results will be formatted as a JSON for embedding into a dynamic Website. Here is a very simple DHTML page with an AJAX request. Of course you are free to custom-tailor the output entirely to your needs.
The structure of the JSON is as follows (with some sample values included):
{
"global_stats": {
"total_players": 2,
"total_players_new": 0,
"total_sessions": 2,
"total_failures": 0,
"total_attempts": 2,
"server_uptime": 120,
"max_clients": 1,
"min_clients": 0,
"max_lifetime": 60,
"avg_lifetime:" 38
},
"player_stats": {
"test_user1": {
"sessions": 1,
"lifetime": 60
}
"test_user2": {
"sessions": 1,
"lifetime": 15
}
},
hourly_stats: [
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 2, failures: 0, attempts: 1, players: 2, clients_min: 0, clients_max: 1 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 },
{ sessions: 0, failures: 0, attempts: 0, players: 0, clients_min: 0, clients_max: 0 }
]
}
Copyright (c) 2018, Leslie Krause