Skip to main content
Wings continuously monitors server resource usage and provides real-time statistics through websockets and API endpoints.

Resource Statistics

Stats Structure

Environment-level statistics:
Source: environment/stats.go:4-31

Resource Usage Structure

Server-level resource tracking:
Source: server/resources.go:14-28

Statistics Collection

Getting Server Stats

Features:
  • Thread-safe access
  • Automatic disk usage update
  • Returns copy of resource data
Source: server/resources.go:32-39

Updating Stats

Called by: Environment monitoring loops Frequency: Continuously during server operation Source: server/resources.go:42-46

API Endpoints

Get Server Details

Source: router/router_server.go:21-23

API Response Structure

Source: server/server.go:373-389

Real-Time Monitoring

Websocket Stats Events

Stats are published to websockets when updated:
Event Name: stats Frequency: Continuous during server operation Source: Referenced in server/server.go:334

State Change Events

Events Published:
  • status - When server state changes
  • stats - When server goes offline (reset to 0)
Source: server/server.go:317-359

Resource Metrics

Memory Tracking

Memory Usage:
Memory Limit:
Calculation:
  • Calculated from container stats
  • Includes all memory used by container
  • Compared against configured limit
Source: environment/stats.go:9-14

CPU Tracking

CPU Absolute:
Description:
  • Percentage of total system CPU used
  • Not limited to server’s CPU allocation
  • Can exceed 100% on multi-core systems
Example Values:
  • 25.5 - Using 25.5% of one CPU core
  • 150.0 - Using 1.5 CPU cores fully
  • 400.0 - Using 4 CPU cores fully
Source: environment/stats.go:18

Network Tracking

Received Bytes:
Transmitted Bytes:
Measurement:
  • Total bytes since container start
  • Cumulative counters (not rates)
  • Resets when container restarts
Source: environment/stats.go:27-30

Disk Tracking

Disk Usage:
Characteristics:
  • Cached value from filesystem
  • Updated when Proc() is called
  • Not real-time (for performance)
Update Method:
Source: server/resources.go:36

Uptime Tracking

Uptime:
Unit: Milliseconds Description: Time since container started Source: environment/stats.go:24

Resource Reset

Reset on Stop

When Called:
  • Server stops
  • Server crashes
  • Container is destroyed
Not Reset:
  • Disk - Persists across restarts
  • State - Updated to offline state
  • MemoryLimit - Configuration value
Source: server/resources.go:50-59

Performance Monitoring

Server State Tracking

States:
  • ProcessOfflineState - Server stopped
  • ProcessStartingState - Server starting
  • ProcessRunningState - Server running
  • ProcessStoppingState - Server stopping
Source: server/server.go:364-368

Atomic State Storage

Benefits:
  • Thread-safe reads/writes
  • No mutex needed for state checks
  • Concurrent access safe
Source: server/resources.go:21

Monitoring Best Practices

Reading Statistics

Good:
Avoid:

Websocket Monitoring

Subscribe to stats events for real-time monitoring:

Polling Interval

For API polling: Recommended:
  • 1-5 seconds for active monitoring
  • 10-30 seconds for dashboards
  • 60+ seconds for historical data
Avoid:
  • Sub-second polling (use websockets)
  • Polling stopped servers
  • Excessive concurrent requests

Metric Visualization

Memory Usage

CPU Usage

Network Rate

Calculate network rate from deltas:

Disk Usage

Uptime

Integration Examples

Prometheus Metrics

Convert Wings stats to Prometheus format:

Grafana Dashboards

Query Wings API for metrics:

Alert Thresholds

Example monitoring alerts:

Troubleshooting

Stats Not Updating

Check:
  1. Server is running (state === "running")
  2. Websocket connection is active
  3. No errors in Wings logs
  4. Container is healthy in Docker

Incorrect Memory Values

Reasons:
  • Container overhead included
  • Shared memory counted
  • Cache/buffers included
Verify:

High CPU Values

Expected:
  • Values can exceed 100%
  • Each core can contribute 100%
  • 400% on 4-core system is normal
Investigate if:
  • Sustained over limit
  • Server unresponsive
  • Other processes affected

Network Counters Reset

Causes:
  • Container restart
  • Server reinstall
  • Network driver reload
Expected behavior:
  • Counters are cumulative
  • Reset on container recreation