root / plugins / minecraft / jsonapi / mcjsonramusage @ b6bf8712
Historique | Voir | Annoter | Télécharger (1,72 ko)
| 1 | b6bf8712 | Jonas Friedmann | #!/usr/bin/php |
|---|---|---|---|
| 2 | <?php |
||
| 3 | ########################################################### |
||
| 4 | ## - Bukkit RAM usage 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 - RAM usage
|
||
| 25 | graph_category bukkit_jsonapi |
||
| 26 | graph_vlabel RAM usage in GB |
||
| 27 | graph_args --base 1024 -l 0 |
||
| 28 | total.label total |
||
| 29 | total.type GAUGE |
||
| 30 | used.label used |
||
| 31 | used.type GAUGE |
||
| 32 | "); |
||
| 33 | exit(); |
||
| 34 | } |
||
| 35 | |||
| 36 | ## Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php) |
||
| 37 | require('/var/cache/munin/JSONAPI.php');
|
||
| 38 | |||
| 39 | ## Prepare API call |
||
| 40 | $api = new JSONAPI($hostname, $port, $username, $password, $salt); |
||
| 41 | $result = $api->callMultiple(array( |
||
| 42 | "system.getJavaMemoryUsage", |
||
| 43 | "system.getJavaMemoryTotal" |
||
| 44 | ), array( |
||
| 45 | array(), |
||
| 46 | array(), |
||
| 47 | )); |
||
| 48 | |||
| 49 | ## Check for success |
||
| 50 | if ($result['result'] == 'success'){
|
||
| 51 | ## Print values |
||
| 52 | print('used.value ' . round($result['success'][0]['success']/1000,2) . "\n");
|
||
| 53 | print('total.value ' . round($result['success'][1]['success']/1000,2) . "\n");
|
||
| 54 | } |
||
| 55 | ?> |
