2013-03-26 20:58:31 +01:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
2013-03-28 16:06:49 +01:00
|
|
|
/**
|
|
|
|
* Bukkit player online Munin plugin
|
|
|
|
* ---------------------------------
|
|
|
|
*
|
|
|
|
* Shows the current online players
|
|
|
|
* (parsed via JSONAPI)
|
|
|
|
*
|
|
|
|
* Read more about my plugins on my blog:
|
|
|
|
* http://s.frd.mn/XJsryR
|
|
|
|
*
|
|
|
|
* Author: Jonas Friedmann (http://frd.mn)
|
2014-09-06 15:11:07 +02:00
|
|
|
* GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins
|
|
|
|
*
|
2013-03-28 16:06:49 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* JSONAPI configuration
|
|
|
|
*/
|
2013-03-26 20:58:31 +01:00
|
|
|
|
|
|
|
$hostname = 'your-hostname';
|
|
|
|
$username = 'your-username';
|
|
|
|
$password = 'your-password';
|
|
|
|
$salt = 'your-salt';
|
|
|
|
$port = 20059;
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
/**
|
|
|
|
* !!! DO NOT EDIT THIS PART BELOW !!!
|
|
|
|
*/
|
|
|
|
|
2013-03-26 20:58:31 +01:00
|
|
|
if ((count($argv) > 1) && ($argv[1] == 'config'))
|
|
|
|
{
|
|
|
|
print("graph_title Bukkit / JSONAPI - players online
|
2017-02-20 23:53:04 +01:00
|
|
|
graph_category games
|
2013-03-26 20:58:31 +01:00
|
|
|
graph_vlabel players
|
|
|
|
graph_args --base 1000 -l 0
|
|
|
|
players.type GAUGE
|
|
|
|
players.label players
|
|
|
|
");
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
// Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php)
|
2013-03-26 20:58:31 +01:00
|
|
|
require('/var/cache/munin/JSONAPI.php');
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
// Prepare API call
|
2013-03-26 20:58:31 +01:00
|
|
|
$api = new JSONAPI($hostname, $port, $username, $password, $salt);
|
|
|
|
$result = $api->call("getPlayerCount");
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
// Check for success
|
2013-03-26 20:58:31 +01:00
|
|
|
if ($result['result'] == 'success'){
|
2013-03-28 16:06:49 +01:00
|
|
|
// Print values
|
2013-03-26 20:58:31 +01:00
|
|
|
print('players.value ' . $result['success'] . "\n");
|
|
|
|
}
|
2014-09-06 15:11:07 +02:00
|
|
|
?>
|