Skip to content

Provides same basic information about your Valheim dedicated server and optionally sends messages to a Telegram group.

License

Notifications You must be signed in to change notification settings

Aldjinn/valheim-server-status

Repository files navigation

valheim-server-status

Fetches some basic informations from your Valheim server and sends (optionally) messages to Telegram if a player joins or leaves your server.

Used libraries:

Development

First, install Node.js locally. Then create an .env file to override values from .env.defaults.

npm install
node server.js

Now open http://localhost:13080/status in your browser.

Docker

First create a docker-compose.yml file based on the docker-compose.example.yml. Adjust the environment variables to your needs.

docker-compose up

Alternatively you can use docker run as well:

docker run -e VALHEIM_HOST='my.valheim.host' \
    -e VALHEIM_PORT='2457' \
    -e VALHEIM_QUERY_CRON='*/5 * * * *' \
    -e TELEGRAM_CHAT_ID='*-123456789' \
    -e TELEGRAM_BOT='bot123456789:nuG0iuy7ae9eVah5eef8tahXee6eij8nieD' \
    -e TELEGRAM_ENABLED='false' \
    -e TELEGRAM_STARTUP_MESSAGE='false' \
    -e METRICS_ENABLED='true' \
    -e WEBHOOK_ENABLED='false' \
    -e CORS_ENABLED='true' \
    -e CORS_ALLOW_ORIGIN='*' \
    -p 13080:13080 \
    aldjinn/valheim-server-status:latest

Now open http://localhost:13080/status in your browser again.

Telegram

If you have configured the Telegram settings correctly and TELEGRAM_STARTUP_MESSAGE='true', a message should be sent to your chat after the application has started. As well if someone joines or leaves the server.

telegram.png)

Webhook

If WEBHOOK_ENABLED='true', a webhook is available via http://localhost:13080/webhook which accepts any kind of JSON data via POST. The only functionality implemented yet is to forward the payload to Telegram. In this case, you must have configured the Telegram settings correctly and set TELEGRAM_ENABLED='true.'

For example, this can be used with the webhook support of valheim-docker.

# test webhook with curl
curl -d "{\"key1\":\"value1\", \"key2\":\"value2\"}" \
    -H "Content-Type: application/json" \
    -X POST http://localhost:13080/webhook

CORS Header

In order to use the output of http://localhost:13080/status in a XMLHttpRequest (i.e. to embed server status in a website using javascript), you need to set the "Access-Control-Allow-Origin" header to either '*' or any other origin like 'example.com'.

You can enable this feature by setting ENABLE_CORS=true and CORS_ALLOW_ORIGIN=<origin>

see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS for further information.

Prometheus

Some metrics are available for scraping via http://localhost:13080/metrics if the application is started with METRICS_ENABLED='true'.

# HELP player_count number of players
# TYPE player_count gauge
player_count 1

# HELP server_info server info
# TYPE server_info gauge
server_info{version="0.146.11",name="TheBigBadWolf",map="TheBigBadWolf"} 1

prometheus.png

About

Provides same basic information about your Valheim dedicated server and optionally sends messages to a Telegram group.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published