root / plugins / minecraft / jsonapi / mcjsonplayers @ b6bf8712
Historique | Voir | Annoter | Télécharger (1,5 ko)
| 1 |
#!/usr/bin/php |
|---|---|
| 2 |
<?php |
| 3 |
########################################################### |
| 4 |
## - Bukkit player online 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 - players online
|
| 25 |
graph_category bukkit_jsonapi |
| 26 |
graph_vlabel players |
| 27 |
graph_args --base 1000 -l 0 |
| 28 |
players.type GAUGE |
| 29 |
players.label players |
| 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("getPlayerCount");
|
| 40 |
|
| 41 |
## Check for success |
| 42 |
if ($result['result'] == 'success'){
|
| 43 |
## Print values |
| 44 |
print('players.value ' . $result['success'] . "\n");
|
| 45 |
} |
| 46 |
?> |
