Difference between revisions of "Live Stats"
m (→Examples) |
|||
Line 27: | Line 27: | ||
WHERE online = 1 AND a.service_id = b.service_id;</source> | WHERE online = 1 AND a.service_id = b.service_id;</source> | ||
− | Get the total number of players connected | + | Get the total number of players connected on each server: |
<source lang="sql">SELECT a.display_name, sum(b.players) as players | <source lang="sql">SELECT a.display_name, sum(b.players) as players | ||
FROM tc_servers a, tc_game_service_live_stats b, tc_services c | FROM tc_servers a, tc_game_service_live_stats b, tc_services c | ||
WHERE c.server_id=a.server_id AND b.service_id=c.service_id AND b.online=1 | WHERE c.server_id=a.server_id AND b.service_id=c.service_id AND b.online=1 | ||
GROUP BY a.server_id;</source> | GROUP BY a.server_id;</source> |
Revision as of 23:48, 11 August 2012
Every time the game monitors queries a service the stats are saved to the table named tc_game_service_live_stats. You can use this table to create a list of services on your website with their current status.
Information currently available in the table:
- Service Id
- Online (1/0)
- Process ID
- Bandwidth (bytes)
- CPU (%)
- Memory (bytes)
- Memory Limit (bytes) *Memory assigned to Minecraft and Craftbukkit services.
- Game
- Game type
- Map
- Name
- Html name
- Max players
- Number of current players
- Number of current spectators
- Player details in XML format
- Rules in XML format
- Query time (UTC/GMT)
Examples
Get a list of services that are currently running:
SELECT a.ip_address, a.game_port, b.* FROM tc_game_services a, tc_game_service_live_stats b WHERE online = 1 AND a.service_id = b.service_id;
Get the total number of players connected on each server:
SELECT a.display_name, sum(b.players) as players FROM tc_servers a, tc_game_service_live_stats b, tc_services c WHERE c.server_id=a.server_id AND b.service_id=c.service_id AND b.online=1 GROUP BY a.server_id;