root / plugins / minecraft / jsonapi / mcjsontps @ 9066b8ff
Historique | Voir | Annoter | Télécharger (1,54 ko)
| 1 | b6bf8712 | Jonas Friedmann | #!/usr/bin/php |
|---|---|---|---|
| 2 | <?php |
||
| 3 | ########################################################### |
||
| 4 | ## - Bukkit TPS Munin plugin - ## |
||
| 5 | ########################################################### |
||
| 6 | ## Script by: ## |
||
| 7 | ## Jonas Friedmann (@frdmn) ## |
||
| 8 | ## http://blog.frd.mn ## |
||
| 9 | ########################################################### |
||
| 10 | ## JSONAPI ## |
||
| 11 | ########################################################### |
||
| 12 | |||
| 13 | $hostname = 'your-hostname'; |
||
| 14 | $username = 'your-username'; |
||
| 15 | $password = 'your-password'; |
||
| 16 | $salt = 'your-salt'; |
||
| 17 | $port = 20059; |
||
| 18 | |||
| 19 | ########################################################### |
||
| 20 | ## DON'T EDIT THIS ## |
||
| 21 | ########################################################### |
||
| 22 | if ((count($argv) > 1) && ($argv[1] == 'config')) |
||
| 23 | {
|
||
| 24 | print("graph_title Bukkit / JSONAPI - ticks per second (TPS)
|
||
| 25 | graph_category bukkit_jsonapi |
||
| 26 | graph_vlabel ticks per second |
||
| 27 | graph_args --base 1000 -l 0 |
||
| 28 | tps.type GAUGE |
||
| 29 | tps.label TPS |
||
| 30 | "); |
||
| 31 | exit(); |
||
| 32 | } |
||
| 33 | |||
| 34 | ## Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php) |
||
| 35 | require('/var/cache/munin/JSONAPI.php');
|
||
| 36 | |||
| 37 | ## Prepare API call |
||
| 38 | $api = new JSONAPI($hostname, $port, $username, $password, $salt); |
||
| 39 | $result = $api->call("system.getServerClockDebug");
|
||
| 40 | |||
| 41 | ## Check for success |
||
| 42 | if ($result['result'] == 'success'){
|
||
| 43 | ## Print values |
||
| 44 | print('tps.value ' . round($result['success']['clockRate'], 2) . "\n");
|
||
| 45 | } |
||
| 46 | ?> |
