Projet

Général

Profil

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

root / plugins / minecraft / minecraft-jsonapi-players @ 9066b8ff

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

1 bed58152 Jonas Friedmann
#!/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
 * 
15
 */
16
17
/**
18
 * JSONAPI configuration
19 007c2825 Jonas Friedmann
 * (get the SDK php file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php)
20 bed58152 Jonas Friedmann
 */
21
22 007c2825 Jonas Friedmann
$apisdk   = '/var/cache/munin/JSONAPI.php';
23 bed58152 Jonas Friedmann
$hostname = 'your-hostname';
24
$username = 'your-username';
25
$password = 'your-password';
26
$salt     = 'your-salt';
27
$port     = 20059;
28
29
/**
30
 * !!! DO NOT EDIT THIS PART BELOW !!!
31
 */
32
33
if ((count($argv) > 1) && ($argv[1] == 'config'))
34
{
35 007c2825 Jonas Friedmann
  print("graph_title Bukkit / JSONAPI - players online
36 bed58152 Jonas Friedmann
graph_category bukkit_jsonapi
37
graph_vlabel players
38
graph_args --base 1000 -l 0
39
players.type GAUGE
40
players.label players
41
");
42 007c2825 Jonas Friedmann
  exit();
43 bed58152 Jonas Friedmann
}
44
45 007c2825 Jonas Friedmann
// Include JSONAPI.php
46
require($apisdk);
47 bed58152 Jonas Friedmann
48
// Prepare API call
49
$api = new JSONAPI($hostname, $port, $username, $password, $salt);
50
$result = $api->call("getPlayerCount");
51
52
// Check for success
53
if ($result['result'] == 'success'){
54
  // Print values
55
  print('players.value ' . $result['success'] . "\n");
56
}
57
?>