Difference between revisions of "Live Stats"
Line 34: | Line 34: | ||
Get the total RAM assigned to Minecraft/Craftbukkit services per server. The results are ordered from lowest to highest. | Get the total RAM assigned to Minecraft/Craftbukkit services per server. The results are ordered from lowest to highest. | ||
− | <source lang="sql">SELECT a.server_id ,a.display_name, ROUND(SUM(b.memory_limit)/1024/1024, 0) AS | + | <source lang="sql">SELECT a.server_id ,a.display_name, ROUND(SUM(b.memory_limit)/1024/1024, 0) AS memory_limit_mb |
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 | WHERE c.server_id=a.server_id AND b.service_id=c.service_id | ||
GROUP BY a.server_id | GROUP BY a.server_id | ||
ORDER BY SUM(b.memory_limit) ASC</source> | ORDER BY SUM(b.memory_limit) ASC</source> |
Latest revision as of 12:07, 17 June 2014
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;
Get the total RAM assigned to Minecraft/Craftbukkit services per server. The results are ordered from lowest to highest.
SELECT a.server_id ,a.display_name, ROUND(SUM(b.memory_limit)/1024/1024, 0) AS memory_limit_mb 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 GROUP BY a.server_id ORDER BY SUM(b.memory_limit) ASC