summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin/spigotmc
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/python.d.plugin/spigotmc')
-rw-r--r--collectors/python.d.plugin/spigotmc/README.md4
-rw-r--r--collectors/python.d.plugin/spigotmc/spigotmc.chart.py19
-rw-r--r--collectors/python.d.plugin/spigotmc/spigotmc.conf2
3 files changed, 19 insertions, 6 deletions
diff --git a/collectors/python.d.plugin/spigotmc/README.md b/collectors/python.d.plugin/spigotmc/README.md
index c38930558..8b74913de 100644
--- a/collectors/python.d.plugin/spigotmc/README.md
+++ b/collectors/python.d.plugin/spigotmc/README.md
@@ -9,7 +9,7 @@ active users.
This is not compatible with Spigot plugins which change the format of
the data returned by the `tps` or `list` console commands.
-### configuration
+## configuration
```yaml
host: localhost
@@ -21,4 +21,4 @@ By default, a connection to port 25575 on the local system is attempted with an
---
-[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2Fpython.d.plugin%2Fspigotmc%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]()
+[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2Fpython.d.plugin%2Fspigotmc%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>)
diff --git a/collectors/python.d.plugin/spigotmc/spigotmc.chart.py b/collectors/python.d.plugin/spigotmc/spigotmc.chart.py
index 536fbe6a8..79d17058c 100644
--- a/collectors/python.d.plugin/spigotmc/spigotmc.chart.py
+++ b/collectors/python.d.plugin/spigotmc/spigotmc.chart.py
@@ -52,7 +52,13 @@ _TPS_REGEX = re.compile(
re.X
)
_LIST_REGEX = re.compile(
- r'(\d+)', # Current user count.
+ # Examples:
+ # There are 4 of a max 50 players online: player1, player2, player3, player4
+ # §6There are §c4§6 out of maximum §c50§6 players online.
+ # §6There are §c3§6/§c1§6 out of maximum §c50§6 players online.
+ # §6当前有 §c4§6 个玩家在线,最大在线人数为 §c50§6 个玩家.
+ # §c4§6 人のプレイヤーが接続中です。最大接続可能人数\:§c 50
+ r'[^§](\d+)(?:.*?(?=/).*?[^§](\d+))?', # Current user count.
re.X
)
@@ -85,6 +91,7 @@ class Service(SimpleService):
self.console.connect(self.host, self.port, self.password)
def reconnect(self):
+ self.error('try reconnect.')
try:
try:
self.console.disconnect()
@@ -99,7 +106,7 @@ class Service(SimpleService):
return True
def is_alive(self):
- if not any(
+ if any(
[
not self.alive,
self.console.socket.getsockopt(socket.IPPROTO_TCP, socket.TCP_INFO, 0) != 1
@@ -139,7 +146,13 @@ class Service(SimpleService):
raw = self.console.command(COMMAND_ONLINE)
match = _LIST_REGEX.search(raw)
if match:
- data['users'] = int(match.group(1))
+ users = int(match.group(1))
+ hidden_users = match.group(2)
+ if hidden_users:
+ hidden_users = int(hidden_users)
+ else:
+ hidden_users = 0
+ data['users'] = users + hidden_users
else:
if not raw:
self.error("'{0}' and '{1}' commands returned no value, make sure you set correct password".format(
diff --git a/collectors/python.d.plugin/spigotmc/spigotmc.conf b/collectors/python.d.plugin/spigotmc/spigotmc.conf
index ccb5e2636..f0064ea2f 100644
--- a/collectors/python.d.plugin/spigotmc/spigotmc.conf
+++ b/collectors/python.d.plugin/spigotmc/spigotmc.conf
@@ -62,5 +62,5 @@
# In addition to the above, spigotmc supports the following:
#
# host: localhost # The host to connect to. Defaults to the local system.
-# port: 25575 # THe port the remote console is listening on.
+# port: 25575 # The port the remote console is listening on.
# password: '' # The remote console password. Most be set correctly.