root / plugins / minecraft / bukkit-statistician-killshostile @ 17f78427
Historique | Voir | Annoter | Télécharger (5,38 ko)
| 1 |
#!/usr/bin/php |
|---|---|
| 2 |
<?php |
| 3 |
/** |
| 4 |
* Bukkit/MySQL Munin plugin |
| 5 |
* --------------------------------- |
| 6 |
* Hostile mob kills per day |
| 7 |
* |
| 8 |
* Shows the daily kills of hostile mobs |
| 9 |
* via Statistician (http://s.frd.mn/14qKXTM) |
| 10 |
* |
| 11 |
* Read more about my plugins on my blog: |
| 12 |
* http://s.frd.mn/XJsryR |
| 13 |
* |
| 14 |
* Author: Jonas Friedmann (http://frd.mn) |
| 15 |
* GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins |
| 16 |
* |
| 17 |
*/ |
| 18 |
|
| 19 |
/** |
| 20 |
* MySQL configuration |
| 21 |
*/ |
| 22 |
|
| 23 |
$hostname = 'localhost'; |
| 24 |
$username = 'sql'; |
| 25 |
$password = 'pass'; |
| 26 |
$database = 'sql'; |
| 27 |
$port = 3306; |
| 28 |
|
| 29 |
/** |
| 30 |
* !!! DO NOT EDIT THIS PART BELOW !!! |
| 31 |
*/ |
| 32 |
|
| 33 |
if ((count($argv) > 1) && ($argv[1] == 'config')) |
| 34 |
{
|
| 35 |
print("graph_title Bukkit / Statistician - hostile mob kills per day
|
| 36 |
graph_category games |
| 37 |
graph_vlabel hostile mob kills per day |
| 38 |
graph_args --base 1000 -l 0 |
| 39 |
blaze.type GAUGE |
| 40 |
blaze.label killed blazes |
| 41 |
spider.type GAUGE |
| 42 |
spider.label killed spiders |
| 43 |
creeper.type GAUGE |
| 44 |
creeper.label killed creepers |
| 45 |
ghast.type GAUGE |
| 46 |
ghast.label killed ghasts |
| 47 |
magmacube.type GAUGE |
| 48 |
magmacube.label killed magma cubes |
| 49 |
silverfish.type GAUGE |
| 50 |
silverfish.label killed silverfish |
| 51 |
skeleton.type GAUGE |
| 52 |
skeleton.label killed skeletons |
| 53 |
slime.type GAUGE |
| 54 |
slime.label killed slimes |
| 55 |
witch.type GAUGE |
| 56 |
witch.label killed witches |
| 57 |
zombie.type GAUGE |
| 58 |
zombie.label killed zombies |
| 59 |
irongolem.type GAUGE |
| 60 |
irongolem.label killed iron golems |
| 61 |
enderdragon.type GAUGE |
| 62 |
enderdragon.label killed ender dragons |
| 63 |
wither.type GAUGE |
| 64 |
wither.label killed withers |
| 65 |
"); |
| 66 |
exit(); |
| 67 |
} |
| 68 |
|
| 69 |
## Construct 'minimum' timstamp |
| 70 |
$current = mktime(); |
| 71 |
$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current));
|
| 72 |
|
| 73 |
## Initiate connection |
| 74 |
$connection = mysqli_connect($hostname, $username, $password, $database, $port); |
| 75 |
|
| 76 |
## Check connection |
| 77 |
if (mysqli_connect_errno()) {
|
| 78 |
printf("Connect failed: %s\n", mysqli_connect_error());
|
| 79 |
exit(); |
| 80 |
} |
| 81 |
|
| 82 |
## Select queries for blaze kills and return the amount of rows |
| 83 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Blaze'")) {
|
| 84 |
## Print values |
| 85 |
print('blaze.value ' . mysqli_num_rows($result) . "\n");
|
| 86 |
} |
| 87 |
|
| 88 |
## Select queries for spider kills and return the amount of rows |
| 89 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%Spider'")) {
|
| 90 |
## Print values |
| 91 |
print('spider.value ' . mysqli_num_rows($result) . "\n");
|
| 92 |
} |
| 93 |
|
| 94 |
## Select queries for creeper kills and return the amount of rows |
| 95 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%reeper%'")) {
|
| 96 |
## Print values |
| 97 |
print('creeper.value ' . mysqli_num_rows($result) . "\n");
|
| 98 |
} |
| 99 |
|
| 100 |
## Select queries for ghast kills and return the amount of rows |
| 101 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Ghast'")) {
|
| 102 |
## Print values |
| 103 |
print('ghast.value ' . mysqli_num_rows($result) . "\n");
|
| 104 |
} |
| 105 |
|
| 106 |
## Select queries for magma cube kills and return the amount of rows |
| 107 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'MagmaCube'")) {
|
| 108 |
## Print values |
| 109 |
print('magmacube.value ' . mysqli_num_rows($result) . "\n");
|
| 110 |
} |
| 111 |
|
| 112 |
## Select queries for silverfish and return the amount of rows |
| 113 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Silverfish'")) {
|
| 114 |
## Print values |
| 115 |
print('silverfish.value ' . mysqli_num_rows($result) . "\n");
|
| 116 |
} |
| 117 |
|
| 118 |
## Select queries for skeleton kills and return the amount of rows |
| 119 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Skeleton'")) {
|
| 120 |
## Print values |
| 121 |
print('skeleton.value ' . mysqli_num_rows($result) . "\n");
|
| 122 |
} |
| 123 |
|
| 124 |
## Select queries for slime kills and return the amount of rows |
| 125 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Slime'")) {
|
| 126 |
## Print values |
| 127 |
print('slime.value ' . mysqli_num_rows($result) . "\n");
|
| 128 |
} |
| 129 |
|
| 130 |
## Select queries for witch kills and return the amount of rows |
| 131 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Witch'")) {
|
| 132 |
## Print values |
| 133 |
print('witch.value ' . mysqli_num_rows($result) . "\n");
|
| 134 |
} |
| 135 |
|
| 136 |
## Select queries for zombie kills and return the amount of rows |
| 137 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Zombie'")) {
|
| 138 |
## Print values |
| 139 |
print('zombie.value ' . mysqli_num_rows($result) . "\n");
|
| 140 |
} |
| 141 |
|
| 142 |
## Select queries for iron golem kills and return the amount of rows |
| 143 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%ron%'")) {
|
| 144 |
## Print values |
| 145 |
print('irongolem.value ' . mysqli_num_rows($result) . "\n");
|
| 146 |
} |
| 147 |
|
| 148 |
## Select queries for ender dragon kills and return the amount of rows |
| 149 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'EnderDragon'")) {
|
| 150 |
## Print values |
| 151 |
print('enderdragon.value ' . mysqli_num_rows($result) . "\n");
|
| 152 |
} |
| 153 |
|
| 154 |
## Select queries for wither kills and return the amount of rows |
| 155 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Wither'")) {
|
| 156 |
## Print values |
| 157 |
print('wither.value ' . mysqli_num_rows($result) . "\n");
|
| 158 |
} |
| 159 |
|
| 160 |
## Close connection |
| 161 |
mysqli_close($connection); |
| 162 |
?> |
