Giter VIP home page Giter VIP logo

srcds_exporter's Introduction

srcds_exporter

build_release

SRCDS Gameserver Prometheus exporter.

Container Image available from:

Container Image Tags:

Compatibility

Tested Games

If you have any issues with a game, please create an issue containing the RCON output of status command and we'll see what we can do to fix compatibility.

Collectors

A collector is collecting certain metrics. Which collectors are enabled is controlled by the --collectors.enabled flag.

Enabled by default

Name Description
playercount Current player count
map Current map played

Disabled by default

Name Description
players Report all players by with their Steam ID label as a metric.

Usage

Create the srcds_exporter config file (see srcds.example.yml for an example). The config file can be named whatever you want, the path to the config must be passed to the srcds_exporter through the -config.file=FILE_PATH flag (default: ./srcds.yaml (current directoy file srcds.yaml)).

Then just run the srcds_exporter binary, through Docker (don't forget to add a mount so the config is available in the container), directly or by having it in your PATH.

Flags

To get a list of all available flags, use the --help flag (e.g., srcds_exporter --help).

Example output:

$ srcds_exporter --help
Usage of srcds_exporter:
      --collectors.enabled string   Comma separated list of active collectors (default "map,playercount")
      --collectors.print            If true, print available collectors and exit.
      --config.file string          Config file to use. (default "./srcds.yaml")
      --log-level string            Set log level (default "INFO")
      --version                     Show version information
      --web.listen-address string   The address to listen on for HTTP requests (default ":9137")
      --web.telemetry-path string   Path the metrics will be exposed under (default "/metrics")
pflag: help requested
exit status 2

srcds_exporter's People

Contributors

galexrt avatar renovate[bot] avatar soliddowant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

srcds_exporter's Issues

Wrong Data / Data is not plausible

The exporter delivers data that is not plausible.

Examples:

Map="Max Players"
srcds_playercount_humans=83
srcds_playercount_limit=245
srcds_playercount_bots=66

`# HELP srcds_map The current map on the server.
# TYPE srcds_map gauge
srcds_map{map="Max Players",server="192.168.1.152:27015"} 1
srcds_map{map="de_dust2",server="192.168.1.153:27015"} 1
# HELP srcds_playercount_bots The current count of bot players on the server.
# TYPE srcds_playercount_bots gauge
srcds_playercount_bots{server="192.168.1.152:27015"} 66
srcds_playercount_bots{server="192.168.1.153:27015"} 0
# HELP srcds_playercount_current The current count players on the server.
# TYPE srcds_playercount_current gauge
srcds_playercount_current{server="192.168.1.152:27015"} 83
srcds_playercount_current{server="192.168.1.153:27015"} 0
# HELP srcds_playercount_humans The current count of humans players on the server.
# TYPE srcds_playercount_humans gauge
srcds_playercount_humans{server="192.168.1.152:27015"} 83
srcds_playercount_humans{server="192.168.1.153:27015"} 0
# HELP srcds_playercount_limit The limit of players on the server.
# TYPE srcds_playercount_limit gauge
srcds_playercount_limit{server="192.168.1.152:27015"} 245
srcds_playercount_limit{server="192.168.1.153:27015"} 20
# HELP srcds_scrape_collector_duration_seconds srcds_exporter: Duration of a collector scrape.
# TYPE srcds_scrape_collector_duration_seconds gauge
srcds_scrape_collector_duration_seconds{collector="map"} 3.2361e-05
srcds_scrape_collector_duration_seconds{collector="playercount"} 2.5077e-05
srcds_scrape_collector_duration_seconds{collector="players"} 6.292e-06
# HELP srcds_scrape_collector_success srcds_exporter: Whether a collector succeeded.
# TYPE srcds_scrape_collector_success gauge
srcds_scrape_collector_success{collector="map"} 1
srcds_scrape_collector_success{collector="playercount"} 1
srcds_scrape_collector_success{collector="players"} 1`

Counter-Strike: Source

Hi mate, to get this to work nicely for CS:S, I had to change:

playerCountRegex = regexp.MustCompile(`(?m)^players : (?P<current1>([0-9]+)) humans, (?P<bots>[0-9]+) bots \((?P<max2>[0-9]+) max\)`)
playerRegex      = regexp.MustCompile(`(?m)^#[ ]+(\d+)\s\"(.+)\"\s+?(\[.+\])\s+([\d|\:]+)\s+(\d+)\s+(\d+)\s+(\w+)\s+([\d|\.]+)\:(\d+)$`)

and for the extraction part:

for _, m := range matches {
        userID, _ := strconv.Atoi(m[1])
        ping, _ := strconv.Atoi(m[5])
        loss, _ := strconv.Atoi(m[6])
        connPort, _ := strconv.Atoi(m[9])
        players[m[3]] = &models.Player{
                Username: m[2],
                UserID:   userID,
                SteamID:  m[3],
                State:    m[7],
                Ping:     ping,
                Loss:     loss,
                IP:       m[8],
                ConnPort: connPort,
        }
}

Just leaving this here in case you want to officially add support for it.

Rework Source server information querying to use A2S instead of RCON

I would like to propose that this library start using A2S queries instead of RCON commands to gather its data, or at least provide an option to do so.

I help manage a TF2 server with some other admins. One of them is using this container to gather statistics on how often certain maps are played, etc.

Every 5 seconds or so, the server console gets sent a status command, which dumps a paragraph of information in the server console. Since I use the console quite a bit to recompile and test Sourcemod plugins, this constant spam is incredibly annoying to work with, and I've had to tell the other admin to turn off the exporter.

I am not entirely sure what information this project gathers and displays, but the information you get from an A2S query is mostly the same as the output of status, minus the edict count.

For example, here is an equivalent Python library that allows for A2S queries:
https://github.com/Yepoleb/python-a2s (Demo)

Pros of A2S:

  • Doesn't spam the console with status command output
  • Works on any Source/Goldsrc server, regardless of mod (I believe some other Steam games might support A2S as well, but I can't confirm at this time)
  • Doesn't require authentication on the server's side
  • Doesn't require setting an rcon password

Cons of A2S:

  • Doesn't report the edict count

Team Fortress 2

Trying to run it against a TF2 server - getting the following:
FATA[0000] rcon: could not parse timeout duration err="time: invalid duration \"\""

status from console is as follows:

] rcon status
hostname: fruit server
version : 6809746/24 6809746 secure
udp/ip  : 10.65.65.61:27015
account : not logged in  (No account specified)
map     : ctf_2fort at: 0 x, 0 y, 0 z
tags    : ctf
players : 0 humans, 0 bots (24 max)
edicts  : 1048 used of 2048 max
# userid name                uniqueid            connected ping loss state  adr

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

dockerfile
Dockerfile
github-actions
.github/workflows/build_release.yml
  • actions/checkout v4
  • actions/setup-go v5
  • elgohr/Publish-Docker-Github-Action v5
  • elgohr/Publish-Docker-Github-Action v5
.github/workflows/test.yml
  • actions/checkout v4
  • actions/setup-go v5
gomod
go.mod
  • go 1.21
  • go 1.22.3
  • github.com/galexrt/go-rcon v0.0.3
  • github.com/kardianos/service v1.2.2
  • github.com/patrickmn/go-cache v2.1.0+incompatible
  • github.com/prometheus/client_golang v1.19.1
  • github.com/prometheus/common v0.53.0
  • github.com/sirupsen/logrus v1.9.3
  • github.com/spf13/pflag v1.0.5
  • github.com/stretchr/testify v1.9.0
  • github.com/xv-chang/rconGo v0.0.0-20210706051530-221338f352d6@221338f352d6
  • gopkg.in/yaml.v3 v3.0.1

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.