2013-03-28 16:12:15 +01:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Bukkit RAM usage Munin plugin
|
|
|
|
* ---------------------------------
|
|
|
|
*
|
|
|
|
* Shows the current RAM usage of your Minecraft process
|
|
|
|
* an the total RAM (parsed via JSONAPI)
|
|
|
|
*
|
|
|
|
* Read more about my plugins on my blog:
|
|
|
|
* http://s.frd.mn/XJsryR
|
|
|
|
*
|
|
|
|
* Author: Jonas Friedmann (http://frd.mn)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* JSONAPI configuration
|
2013-04-19 21:56:07 +02:00
|
|
|
* (get the SDK php file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php)
|
2013-03-28 16:12:15 +01:00
|
|
|
*/
|
|
|
|
|
2013-04-19 21:56:07 +02:00
|
|
|
$apisdk = '/var/cache/munin/JSONAPI.php';
|
2013-03-28 16:12:15 +01:00
|
|
|
$hostname = 'your-hostname';
|
|
|
|
$username = 'your-username';
|
|
|
|
$password = 'your-password';
|
|
|
|
$salt = 'your-salt';
|
|
|
|
$port = 20059;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* !!! DO NOT EDIT THIS PART BELOW !!!
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((count($argv) > 1) && ($argv[1] == 'config'))
|
|
|
|
{
|
2013-04-19 21:56:07 +02:00
|
|
|
print("graph_title Bukkit / JSONAPI - RAM usage
|
2013-03-28 16:12:15 +01:00
|
|
|
graph_category bukkit_jsonapi
|
|
|
|
graph_vlabel RAM usage in GB
|
|
|
|
graph_args --base 1024 -l 0
|
|
|
|
total.label total
|
|
|
|
total.type GAUGE
|
|
|
|
used.label used
|
|
|
|
used.type GAUGE
|
|
|
|
");
|
2013-04-19 21:56:07 +02:00
|
|
|
exit();
|
2013-03-28 16:12:15 +01:00
|
|
|
}
|
|
|
|
|
2013-04-19 21:56:07 +02:00
|
|
|
// Include JSONAPI.php
|
|
|
|
require($apisdk);
|
2013-03-28 16:12:15 +01:00
|
|
|
|
|
|
|
// Prepare API call
|
|
|
|
$api = new JSONAPI($hostname, $port, $username, $password, $salt);
|
|
|
|
$result = $api->callMultiple(array(
|
|
|
|
"system.getJavaMemoryUsage",
|
|
|
|
"system.getJavaMemoryTotal"
|
|
|
|
), array(
|
|
|
|
array(),
|
|
|
|
array(),
|
|
|
|
));
|
|
|
|
|
|
|
|
// Check for success
|
|
|
|
if ($result['result'] == 'success'){
|
|
|
|
// Print values
|
|
|
|
print('used.value ' . round($result['success'][0]['success']/1000,2) . "\n");
|
|
|
|
print('total.value ' . round($result['success'][1]['success']/1000,2) . "\n");
|
|
|
|
}
|
|
|
|
?>
|