-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,332 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: CI | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
Test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
|
||
- name: Run Test | ||
run: make test | ||
|
||
Lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run Lint | ||
uses: golangci/golangci-lint-action@v2 | ||
|
||
Docker: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- Test | ||
- Lint | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Extract metadata | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: armsnyder/a2s-exporter | ||
|
||
- name: Log in to Docker Hub | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | ||
uses: docker/login-action@v1 | ||
with: | ||
username: armsnyder | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Docker build | ||
if: github.event_name != 'push' || !startsWith(github.ref, 'refs/tags/v') | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: false | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: Docker build and push | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: Sync Docker readme | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | ||
uses: meeDamian/[email protected] | ||
with: | ||
pass: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
description: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,3 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
# IDE | ||
.idea | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# https://golangci-lint.run/usage/configuration/ | ||
|
||
linters-settings: | ||
goimports: | ||
local-prefixes: github.com/armsnyder/a2s-exporter | ||
|
||
linters: | ||
enable: | ||
- gocritic | ||
- gofmt | ||
- goimports | ||
- golint | ||
- misspell | ||
- testpackage | ||
- unconvert | ||
- whitespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM golang:1.16 AS builder | ||
WORKDIR /build | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
COPY internal internal | ||
COPY *.go . | ||
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -s" -o /bin/a2s-exporter . | ||
|
||
FROM scratch | ||
COPY --from=builder /bin/a2s-exporter /bin/a2s-exporter | ||
ENTRYPOINT ["/bin/a2s-exporter"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
default: build test | ||
|
||
lint: | ||
golangci-lint run | ||
|
||
fix: | ||
golangci-lint run --fix | ||
|
||
build: | ||
go build ./... | ||
|
||
test: | ||
go test -v -race ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,69 @@ | ||
# a2s-exporter | ||
A Prometheus exporter for Steam game servers | ||
[![CI](https://github.com/armsnyder/a2s-exporter/actions/workflows/ci.yaml/badge.svg)](https://github.com/armsnyder/a2s-exporter/actions/workflows/ci.yaml) | ||
|
||
# A2S Exporter | ||
|
||
A Prometheus exporter for Steam game server info. | ||
|
||
Supports all Steam game servers which speak the UDP-based A2S query protocol, for example: | ||
|
||
* Counter-Strike | ||
* The Forrest | ||
* Rust | ||
* Team Fortress 2 | ||
* Valheim | ||
|
||
## Usage | ||
|
||
The image is hosted on Docker Hub. | ||
|
||
``` | ||
docker run --rm -p 9856:9856 armsnyder/a2s-exporter --address myserver.example.com:12345 | ||
``` | ||
|
||
### Arguments | ||
|
||
Arguments may be provided using commandline flags or environment variables. | ||
|
||
#### Required | ||
|
||
Flag | Variable | Help | ||
--- | --- | --- | ||
--address | A2S_EXPORTER_QUERY_ADDRESS | Address of the A2S query server as host:port (This is a separate port from the main server port). | ||
|
||
#### Optional | ||
|
||
Flag | Variable | Default | Help | ||
--- | --- | --- | --- | ||
--port | A2S_EXPORTER_PORT | 9856 | Port for the metrics exporter. | ||
--path | A2S_EXPORTER_PATH | /metrics | Path for the metrics exporter. | ||
--namespace | A2S_EXPORTER_NAMESPACE | a2s | Namespace prefix for all exported a2s metrics. | ||
--a2s-only-metrics | A2S_EXPORTER_A2S_ONLY_METRICS | false | If true, excludes Go runtime and promhttp metrics. | ||
|
||
## Exported Metrics | ||
|
||
Metrics names are prefixed with a namespace (default `a2s_`). | ||
|
||
Name | Help | Labels | ||
--- | --- | --- | ||
player_count | Total number of connected players. | server_name | ||
player_duration | Time (in seconds) player has been connected to the server. | server_name player_name player_index | ||
player_score | Player's score (usually \"frags\" or \"kills\"). | server_name player_name player_index | ||
player_the_ship_deaths | Player's deaths in a The Ship server. | server_name player_name player_index | ||
player_the_ship_money | Player's money in a The Ship server. | server_name player_name player_index | ||
player_up | Was the last player info query successful. | | ||
server_bots | Number of bots on the server. | server_name | ||
server_info | Non-numerical server info, including server_steam_id and version. The value is 1, and info is in the labels. | server_name map folder game server_type server_os version server_id keywords server_game_id server_steam_id the_ship_mode source_tv_name | ||
server_max_players | Maximum number of players the server reports it can hold. | server_name | ||
server_players | Number of players on the server. | server_name | ||
server_port | The server's game port number. | server_name | ||
server_protocol | Protocol version used by the server. | server_name | ||
server_source_tv_port | Spectator port number for SourceTV. | server_name | ||
server_the_ship_duration | Time (in seconds) before a player is arrested while being witnessed in a The Ship server. | server_name | ||
server_the_ship_witnesses | The number of witnesses necessary to have a player arrested in a The Ship server. | server_name | ||
server_up | Was the last server info query successful. | | ||
server_vac | Specifies whether the server uses VAC (0 for unsecured, 1 for secured). | server_name | ||
server_visibility | Indicates whether the server requires a password (0 for public, 1 for private). | server_name | ||
|
||
## Credits | ||
|
||
This exporter depends on [rumblefrog/go-a2s](https://github.com/rumblefrog/go-a2s) (MIT). Big thanks to them! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module github.com/armsnyder/a2s-exporter | ||
|
||
go 1.16 | ||
|
||
require ( | ||
github.com/prometheus/client_golang v1.11.0 | ||
github.com/prometheus/client_model v0.2.0 | ||
github.com/rumblefrog/go-a2s v1.0.0 | ||
) |
Oops, something went wrong.