Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / minecraft / bukkit-jsonapi-players @ 17f78427

Historique | Voir | Annoter | Télécharger (1,19 ko)

1
#!/usr/bin/php
2
<?php
3
/**
4
 * Bukkit player online Munin plugin
5
 * ---------------------------------
6
 *
7
 * Shows the current online players
8
 * (parsed via JSONAPI)
9
 *
10
 * Read more about my plugins on my blog:
11
 * http://s.frd.mn/XJsryR
12
 *
13
 * Author: Jonas Friedmann (http://frd.mn)
14
 * GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins
15
 *
16
 */
17

    
18
/**
19
 * JSONAPI configuration
20
 */
21

    
22
$hostname = 'your-hostname';
23
$username = 'your-username';
24
$password = 'your-password';
25
$salt     = 'your-salt';
26
$port     = 20059;
27

    
28
/**
29
 * !!! DO NOT EDIT THIS PART BELOW !!!
30
 */
31

    
32
if ((count($argv) > 1) && ($argv[1] == 'config'))
33
{
34
print("graph_title Bukkit / JSONAPI - players online
35
graph_category games
36
graph_vlabel players
37
graph_args --base 1000 -l 0
38
players.type GAUGE
39
players.label players
40
");
41
exit();
42
}
43

    
44
// Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php)
45
require('/var/cache/munin/JSONAPI.php');
46

    
47
// Prepare API call
48
$api = new JSONAPI($hostname, $port, $username, $password, $salt);
49
$result = $api->call("getPlayerCount");
50

    
51
// Check for success
52
if ($result['result'] == 'success'){
53
  // Print values
54
  print('players.value ' . $result['success'] . "\n");
55
}
56
?>