Skip to content

Commit 415f055

Browse files
committed
status: add support for JSON formatted output
1 parent 3c931ec commit 415f055

File tree

7 files changed

+187
-80
lines changed

7 files changed

+187
-80
lines changed

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
build:
1212
uses: itzg/github-workflows/.github/workflows/go-with-releaser-image.yml@main
1313
with:
14-
go-version: "1.22.7"
14+
go-version: "1.23.3"
1515
secrets:
1616
image-registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
1717
image-registry-password: ${{ secrets.DOCKERHUB_TOKEN }}

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ jobs:
1515
build:
1616
uses: itzg/github-workflows/.github/workflows/go-test.yml@main
1717
with:
18-
go-version: "1.22.7"
18+
go-version: "1.23.3"

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22 as builder
1+
FROM golang:1.23 as builder
22

33
WORKDIR /build
44

README.md

+85
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,91 @@ Subcommands for status:
2929
status-bedrock Retrieves and displays the status of the given Minecraft Bedrock Dedicated server
3030
```
3131

32+
Usage for any of the sub-commands can be displayed by add `--help` after each, such as:
33+
34+
```shell
35+
mc-monitor status --help
36+
```
37+
38+
### status
39+
40+
```
41+
-host string
42+
hostname of the Minecraft server (env MC_HOST) (default "localhost")
43+
-json
44+
output server status as JSON
45+
-port int
46+
port of the Minecraft server (env MC_PORT) (default 25565)
47+
-retry-interval duration
48+
if retry-limit is non-zero, status will be retried at this interval (default 10s)
49+
-retry-limit int
50+
if non-zero, failed status will be retried this many times before exiting
51+
-show-player-count
52+
show just the online player count
53+
-skip-readiness-check
54+
returns success when pinging a server without player info, or with a max player count of 0
55+
-timeout duration
56+
the timeout the ping can take as a maximum (default 15s)
57+
-use-mc-utils
58+
(experimental) try using mcutils to query the server
59+
-use-proxy
60+
supports contacting Bungeecord when proxy_protocol enabled
61+
-use-server-list-ping
62+
indicates the legacy, server list ping should be used for pre-1.12
63+
```
64+
65+
### status-bedrock
66+
67+
```
68+
-host string
69+
(default "localhost")
70+
-port int
71+
(default 19132)
72+
-retry-interval duration
73+
if retry-limit is non-zero, status will be retried at this interval (default 10s)
74+
-retry-limit int
75+
if non-zero, failed status will be retried this many times before exiting
76+
```
77+
78+
### export-for-prometheus
79+
80+
```
81+
-bedrock-servers host:port
82+
one or more host:port addresses of Bedrock servers to monitor, when port is omitted 19132 is used (env EXPORT_BEDROCK_SERVERS)
83+
-port int
84+
HTTP port where Prometheus metrics are exported (env EXPORT_PORT) (default 8080)
85+
-servers host:port
86+
one or more host:port addresses of Java servers to monitor, when port is omitted 25565 is used (env EXPORT_SERVERS)
87+
-timeout duration
88+
timeout when checking each servers (env TIMEOUT) (default 1m0s)
89+
```
90+
91+
### gather-for-telegraf
92+
93+
```
94+
-interval duration
95+
gathers and sends metrics at this interval (env GATHER_INTERVAL) (default 1m0s)
96+
-servers host:port
97+
one or more host:port addresses of servers to monitor (env GATHER_SERVERS)
98+
-telegraf-address host:port
99+
host:port of telegraf accepting Influx line protocol (env GATHER_TELEGRAF_ADDRESS) (default "localhost:8094")
100+
```
101+
102+
### collect-otel
103+
104+
```
105+
-bedrock-servers host:port
106+
one or more host:port addresses of Bedrock servers to monitor, when port is omitted 19132 is used (env EXPORT_BEDROCK_SERVERS)
107+
-interval duration
108+
Collect and sends OpenTelemetry data at this interval (env EXPORT_INTERVAL) (default 10s)
109+
-otel-collector-endpoint string
110+
OpenTelemetry gRPC endpoint to export data (env EXPORT_OTEL_COLLECTOR_ENDPOINT) (default "localhost:4317")
111+
-otel-collector-timeout duration
112+
Timeout for collecting OpenTelemetry data (env EXPORT_OTEL_COLLECTOR_TIMEOUT) (default 35s)
113+
-servers host:port
114+
one or more host:port addresses of Java servers to monitor, when port is omitted 25565 is used (env EXPORT_SERVERS)
115+
```
116+
32117
## Examples
33118

34119
### Checking the status of a server

go.mod

+26-25
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,56 @@
11
module github.com/itzg/mc-monitor
22

3-
go 1.21
3+
go 1.23
44

5-
toolchain go1.22.6
5+
toolchain go1.23.3
66

77
require (
88
github.com/Raqbit/mc-pinger v0.2.4
99
github.com/avast/retry-go v3.0.0+incompatible
1010
github.com/google/subcommands v1.2.0
11-
github.com/itzg/go-flagsfiller v1.14.0
11+
github.com/itzg/go-flagsfiller v1.15.0
1212
github.com/itzg/line-protocol-sender v0.1.1
1313
github.com/itzg/zapconfigs v0.1.0
14-
github.com/prometheus/client_golang v1.19.1
15-
github.com/sandertv/go-raknet v1.12.1
14+
github.com/prometheus/client_golang v1.20.5
15+
github.com/sandertv/go-raknet v1.14.2
1616
github.com/stretchr/testify v1.9.0
1717
github.com/xrjr/mcutils v1.5.1
18-
go.opentelemetry.io/contrib/instrumentation/runtime v0.53.0
19-
go.opentelemetry.io/otel v1.28.0
20-
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0
21-
go.opentelemetry.io/otel/metric v1.28.0
22-
go.opentelemetry.io/otel/sdk/metric v1.28.0
18+
go.opentelemetry.io/contrib/instrumentation/runtime v0.57.0
19+
go.opentelemetry.io/otel v1.32.0
20+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0
21+
go.opentelemetry.io/otel/metric v1.32.0
22+
go.opentelemetry.io/otel/sdk/metric v1.32.0
2323
go.uber.org/zap v1.27.0
2424
)
2525

2626
require (
2727
github.com/beorn7/perks v1.0.1 // indirect
2828
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
29-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
29+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
3030
github.com/davecgh/go-spew v1.1.1 // indirect
31-
github.com/df-mc/atomic v1.10.0 // indirect
3231
github.com/go-logr/logr v1.4.2 // indirect
3332
github.com/go-logr/stdr v1.2.2 // indirect
3433
github.com/google/uuid v1.6.0 // indirect
35-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
34+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect
3635
github.com/iancoleman/strcase v0.3.0 // indirect
3736
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect
37+
github.com/klauspost/compress v1.17.9 // indirect
38+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
3839
github.com/pires/go-proxyproto v0.7.0 // indirect
3940
github.com/pmezard/go-difflib v1.0.0 // indirect
40-
github.com/prometheus/client_model v0.5.0 // indirect
41-
github.com/prometheus/common v0.48.0 // indirect
42-
github.com/prometheus/procfs v0.12.0 // indirect
43-
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
44-
go.opentelemetry.io/otel/trace v1.28.0 // indirect
41+
github.com/prometheus/client_model v0.6.1 // indirect
42+
github.com/prometheus/common v0.55.0 // indirect
43+
github.com/prometheus/procfs v0.15.1 // indirect
44+
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
45+
go.opentelemetry.io/otel/trace v1.32.0 // indirect
4546
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
4647
go.uber.org/multierr v1.10.0 // indirect
47-
golang.org/x/net v0.26.0 // indirect
48-
golang.org/x/sys v0.21.0 // indirect
49-
golang.org/x/text v0.16.0 // indirect
50-
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
51-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
52-
google.golang.org/grpc v1.64.0 // indirect
53-
google.golang.org/protobuf v1.34.2 // indirect
48+
golang.org/x/net v0.30.0 // indirect
49+
golang.org/x/sys v0.27.0 // indirect
50+
golang.org/x/text v0.20.0 // indirect
51+
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
52+
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
53+
google.golang.org/grpc v1.67.1 // indirect
54+
google.golang.org/protobuf v1.35.1 // indirect
5455
gopkg.in/yaml.v3 v3.0.1 // indirect
5556
)

0 commit comments

Comments
 (0)