Skip to content

Commit 69a8344

Browse files
committed
Updates for Minecraft 1.19.4
Updates to the _lag and _users scripts to account for changes in the process of upgrading s2 to Minecraft 1.19.4, while preserving backwards compatibility. Fixes for the other scripts to come Eventually™. Change-Id: I2269727bbd77b41d5fb6488ece29a63d5522c6d7
1 parent 5c34158 commit 69a8344

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

minecraft_lag.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,36 @@
2929
*/
3030

3131
require_once("busybody.php");
32-
$data = dataPlz();
33-
34-
$res = array();
3532

3633
if($argv[1] == "config") {
3734
echo "graph_title " . ((empty($_ENV['customTitle'])) ? "Minecraft Server Lag" : $_ENV['customTitle'] . " Server Lag") . "\n";
3835
echo "graph_vlabel Ticks per second (TPS)\n";
3936
echo "graph_category minecraft\n";
40-
echo "tps.label Actual TPS\n";
37+
echo "tps.label Actual TPS (1-minute average)\n";
4138
echo "tps.colour ff0000\n";
4239
echo "normal.label Normal TPS\n";
4340
echo "normal.colour 0fc20f\n";
4441
die();
4542
}
4643

47-
if(preg_match('/\[[#_]+\] ([0-9,.]+) TPS/', $data, $matches)) {
44+
$data = dataPlz();
45+
46+
if (preg_match('/\[[#_]+] ([0-9,.]+) TPS/', $data, $matches)) {
4847
$tps = str_replace(',', '', $matches[1]);
4948

5049
echo "tps.value {$tps}\n";
5150
echo "normal.value 20.00\n";
5251
} else {
53-
echo "Error reading RCON data!\n";
54-
exit(1);
52+
$data = $data = dataPlz("tps");
53+
54+
if (preg_match('/TPS from last 1m, 5m, 15m: ([0-9.]+), ([0-9.]+), ([0-9.]+)/', $data, $matches)) {
55+
$tps = str_replace(',', '', $matches[1]);
56+
57+
echo "tps.value {$tps}\n";
58+
echo "normal.value 20.00\n";
59+
} else {
60+
echo "Error reading RCON data!\n";
61+
exit(1);
62+
}
5563
}
5664
?>

minecraft_users.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
$res = array();
3232

33-
if($argv[1] == "config") {
33+
if ($argv[1] == "config") {
3434
echo "graph_title " . ((empty($_ENV['customTitle'])) ? "Minecraft Users" : $_ENV['customTitle'] . " Users") . "\n";
3535
echo "graph_vlabel Users\n";
3636
echo "graph_category minecraft\n";
@@ -39,7 +39,13 @@
3939
die();
4040
}
4141

42-
if(preg_match('/There are ([0-9]+)\/([0-9]+) players online:/', $data, $matches)) {
42+
if (preg_match('/There are ([0-9]+)\/([0-9]+) players online:/', $data, $matches)) {
43+
$users = str_replace(',', '', $matches[1]);
44+
$maxusers = str_replace(',', '', $matches[2]);
45+
46+
echo "users.value {$users}\n";
47+
echo "maxusers.value {$maxusers}\n";
48+
} elseif (preg_match('/There are ([0-9]+) of a max of ([0-9]+) players online:/', $data, $matches)) {
4349
$users = str_replace(',', '', $matches[1]);
4450
$maxusers = str_replace(',', '', $matches[2]);
4551

0 commit comments

Comments
 (0)