What is GameDig?
GameDig is a Node.js library that queries game servers for real-time status information including player counts, server names, maps, ping, and rules. It supports over 150 game protocols making it ideal for monitoring diverse game server infrastructure.
Installation
npm install gamedig
# Or globally
npm install -g gamedig
gamedig --type minecraft 127.0.0.1:25565
Basic Querying
const { GameDig } = require("gamedig");
async function queryServer() {
const state = await GameDig.query({
type: "minecraft",
host: "127.0.0.1",
port: 25565
});
console.log(`Server: ${state.name}`);
console.log(`Players: ${state.numplayers}/${state.maxplayers}`);
console.log(`Map: ${state.map}`);
console.log(`Ping: ${state.ping}ms`);
}
queryServer();
Monitoring Dashboard Script
const { GameDig } = require("gamedig");
const fs = require("fs");
const servers = [
{ name: "MC Survival", type: "minecraft", host: "127.0.0.1", port: 25565 },
{ name: "CS2 Comp", type: "csgo", host: "127.0.0.1", port: 27015 },
{ name: "Rust Main", type: "rust", host: "127.0.0.1", port: 28015 },
];
async function monitor() {
const results = [];
for (const server of servers) {
try {
const state = await GameDig.query(server);
results.push({
name: server.name,
status: "online",
players: state.numplayers,
maxPlayers: state.maxplayers,
ping: state.ping,
map: state.map
});
} catch (e) {
results.push({ name: server.name, status: "offline" });
}
}
return results;
}
// Run every 60 seconds
setInterval(async () => {
const status = await monitor();
console.table(status);
// Export as Prometheus metrics or save to database
}, 60000);
Prometheus Metrics Export
// Export GameDig data as Prometheus metrics
const express = require("express");
const { register, Gauge } = require("prom-client");
const playersGauge = new Gauge({
name: "gameserver_players",
help: "Current player count",
labelNames: ["server", "game"]
});
const pingGauge = new Gauge({
name: "gameserver_ping_ms",
help: "Server ping in ms",
labelNames: ["server", "game"]
});
// Update gauges in monitor loop
// Expose /metrics endpoint for Prometheus scraping
Alerting
# Alert when server is down or player count drops to zero
# Use with Healthchecks.io, Uptime Kuma, or Prometheus Alertmanager
# Send notifications via Discord webhook, Slack, or email
Supported Games
GameDig supports 150+ games including Minecraft, CS2, Rust, ARK, ARMA 3, Valheim, V Rising, Terraria, and many more. Check the GameDig documentation for the full list of supported game protocols.