Projet

Général

Profil

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

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

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

1 b6bf8712 Jonas Friedmann
#!/usr/bin/php
2
<?php
3 4192c14f Jonas Friedmann
/**
4
 * Bukkit TPS Munin plugin
5
 * ---------------------------------
6
 *
7
 * Shows the current TPS (ticks per second) of your
8
 * Minecraft server (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 92abf3e3 Jonas Friedmann
 * GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins
15 17f78427 Lars Kruse
 *
16 4192c14f Jonas Friedmann
 */
17
18
/**
19
 * JSONAPI configuration
20
 */
21 b6bf8712 Jonas Friedmann
22
$hostname = 'your-hostname';
23
$username = 'your-username';
24
$password = 'your-password';
25
$salt     = 'your-salt';
26
$port     = 20059;
27
28 4192c14f Jonas Friedmann
/**
29
 * !!! DO NOT EDIT THIS PART BELOW !!!
30
 */
31
32 b6bf8712 Jonas Friedmann
if ((count($argv) > 1) && ($argv[1] == 'config'))
33
{
34
print("graph_title Bukkit / JSONAPI - ticks per second (TPS)
35 25673f6c dipohl
graph_category games
36 b6bf8712 Jonas Friedmann
graph_vlabel ticks per second
37
graph_args --base 1000 -l 0
38
tps.type GAUGE
39
tps.label TPS
40
");
41
exit();
42
}
43
44 4192c14f Jonas Friedmann
// Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php)
45 b6bf8712 Jonas Friedmann
require('/var/cache/munin/JSONAPI.php');
46
47 4192c14f Jonas Friedmann
// Prepare API call
48 b6bf8712 Jonas Friedmann
$api = new JSONAPI($hostname, $port, $username, $password, $salt);
49
$result = $api->call("system.getServerClockDebug");
50
51 4192c14f Jonas Friedmann
// Check for success
52 b6bf8712 Jonas Friedmann
if ($result['result'] == 'success'){
53 4192c14f Jonas Friedmann
  // Print values
54 b6bf8712 Jonas Friedmann
  print('tps.value ' . round($result['success']['clockRate'], 2) . "\n");
55
}
56 92abf3e3 Jonas Friedmann
?>