Projet

Général

Profil

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

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

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

1
#!/usr/bin/php
2
<?php
3
/**
4
 * Bukkit RAM usage Munin plugin
5
 * ---------------------------------
6
 *
7
 * Shows the current RAM usage of your Minecraft process
8
 * an the total RAM (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 - RAM usage
35
graph_category games
36
graph_vlabel RAM usage in GB
37
graph_args --base 1024 -l 0
38
total.label total
39
total.type GAUGE
40
used.label used
41
used.type GAUGE
42
");
43
exit();
44
}
45

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

    
49
// Prepare API call
50
$api = new JSONAPI($hostname, $port, $username, $password, $salt);
51
$result = $api->callMultiple(array(
52
  "system.getJavaMemoryUsage",
53
  "system.getJavaMemoryTotal"
54
  ), array(
55
  array(),
56
  array(),
57
));
58

    
59
// Check for success
60
if ($result['result'] == 'success'){
61
  // Print values
62
  print('used.value ' . round($result['success'][0]['success']/1000,2) . "\n");
63
  print('total.value ' . round($result['success'][1]['success']/1000,2) . "\n");
64
}
65
?>