From b6bf87120c75652c711832d0c1ba084061568f17 Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Tue, 26 Mar 2013 20:58:31 +0100 Subject: [PATCH] first version of the plugins --- plugins/minecraft/jsonapi/mcjsonplayers | 46 ++++++++++++++++++++ plugins/minecraft/jsonapi/mcjsonramusage | 55 ++++++++++++++++++++++++ plugins/minecraft/jsonapi/mcjsontps | 46 ++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 plugins/minecraft/jsonapi/mcjsonplayers create mode 100644 plugins/minecraft/jsonapi/mcjsonramusage create mode 100644 plugins/minecraft/jsonapi/mcjsontps diff --git a/plugins/minecraft/jsonapi/mcjsonplayers b/plugins/minecraft/jsonapi/mcjsonplayers new file mode 100644 index 00000000..cb7fe1b8 --- /dev/null +++ b/plugins/minecraft/jsonapi/mcjsonplayers @@ -0,0 +1,46 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / JSONAPI - players online +graph_category bukkit_jsonapi +graph_vlabel players +graph_args --base 1000 -l 0 +players.type GAUGE +players.label players +"); +exit(); +} + +## Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php) +require('/var/cache/munin/JSONAPI.php'); + +## Prepare API call +$api = new JSONAPI($hostname, $port, $username, $password, $salt); +$result = $api->call("getPlayerCount"); + +## Check for success +if ($result['result'] == 'success'){ + ## Print values + print('players.value ' . $result['success'] . "\n"); +} +?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcjsonramusage b/plugins/minecraft/jsonapi/mcjsonramusage new file mode 100644 index 00000000..cdab345a --- /dev/null +++ b/plugins/minecraft/jsonapi/mcjsonramusage @@ -0,0 +1,55 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / JSONAPI - RAM usage +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 +"); +exit(); +} + +## Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php) +require('/var/cache/munin/JSONAPI.php'); + +## 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"); +} +?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcjsontps b/plugins/minecraft/jsonapi/mcjsontps new file mode 100644 index 00000000..bf483e88 --- /dev/null +++ b/plugins/minecraft/jsonapi/mcjsontps @@ -0,0 +1,46 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / JSONAPI - ticks per second (TPS) +graph_category bukkit_jsonapi +graph_vlabel ticks per second +graph_args --base 1000 -l 0 +tps.type GAUGE +tps.label TPS +"); +exit(); +} + +## Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php) +require('/var/cache/munin/JSONAPI.php'); + +## Prepare API call +$api = new JSONAPI($hostname, $port, $username, $password, $salt); +$result = $api->call("system.getServerClockDebug"); + +## Check for success +if ($result['result'] == 'success'){ + ## Print values + print('tps.value ' . round($result['success']['clockRate'], 2) . "\n"); +} +?> \ No newline at end of file