2018-07-11 18:58:23 +02:00
|
|
|
#!/usr/bin/env ruby
|
2011-03-18 09:33:24 +01:00
|
|
|
# Config:
|
2012-03-06 05:11:27 +01:00
|
|
|
# [minecraft_users]
|
|
|
|
# env.host awesomeserver.com
|
|
|
|
# env.port 25566
|
2011-03-18 09:33:24 +01:00
|
|
|
#
|
|
|
|
|
2012-03-06 05:11:27 +01:00
|
|
|
require 'socket'
|
|
|
|
|
|
|
|
if ARGV[0] == 'config'
|
|
|
|
puts "graph_title Connected players"
|
|
|
|
puts "graph_vlabel players"
|
|
|
|
puts "players.label players"
|
|
|
|
puts "graph_info Number of players connected to Minecraft"
|
2017-02-20 23:01:26 +01:00
|
|
|
puts "graph_category games"
|
2012-03-06 05:11:27 +01:00
|
|
|
exit
|
|
|
|
end
|
|
|
|
|
|
|
|
host = ENV['host']
|
|
|
|
host = 'localhost' unless host
|
|
|
|
|
|
|
|
port = ENV['port']
|
|
|
|
port = '25566' unless port
|
|
|
|
|
|
|
|
socket = TCPSocket.new(host, port)
|
|
|
|
socket.puts "QUERY"
|
|
|
|
|
|
|
|
response = socket.read
|
|
|
|
response = response.split("\n")
|
|
|
|
|
|
|
|
server_port = response[0].split(" ", 2)[1].to_i
|
|
|
|
player_count = response[1].split(" ", 2)[1].to_i
|
|
|
|
max_players = response[2].split(" ", 2)[1].to_i
|
|
|
|
player_list = response[3].split(" ", 2)[1].chomp[1..-2]
|
|
|
|
|
2017-02-20 23:01:26 +01:00
|
|
|
puts "players.value #{player_count}"
|