root / plugins / minecraft / minecraft-sql-statistician-hostile-kills @ 007c2825
Historique | Voir | Annoter | Télécharger (5,34 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 |
* |
| 16 |
*/ |
| 17 |
|
| 18 |
/** |
| 19 |
* MySQL configuration |
| 20 |
*/ |
| 21 |
|
| 22 |
$hostname = 'localhost'; |
| 23 |
$username = 'sql'; |
| 24 |
$password = 'pass'; |
| 25 |
$database = 'sql'; |
| 26 |
$port = 3306; |
| 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 / Statistician - hostile mob kills per day
|
| 35 |
graph_category bukkit_sql_kills |
| 36 |
graph_vlabel hostile mob kills per day |
| 37 |
graph_args --base 1000 -l 0 |
| 38 |
blaze.type GAUGE |
| 39 |
blaze.label killed blazes |
| 40 |
spider.type GAUGE |
| 41 |
spider.label killed spiders |
| 42 |
creeper.type GAUGE |
| 43 |
creeper.label killed creepers |
| 44 |
ghast.type GAUGE |
| 45 |
ghast.label killed ghasts |
| 46 |
magmacube.type GAUGE |
| 47 |
magmacube.label killed magma cubes |
| 48 |
silverfish.type GAUGE |
| 49 |
silverfish.label killed silverfish |
| 50 |
skeleton.type GAUGE |
| 51 |
skeleton.label killed skeletons |
| 52 |
slime.type GAUGE |
| 53 |
slime.label killed slimes |
| 54 |
witch.type GAUGE |
| 55 |
witch.label killed witches |
| 56 |
zombie.type GAUGE |
| 57 |
zombie.label killed zombies |
| 58 |
irongolem.type GAUGE |
| 59 |
irongolem.label killed iron golems |
| 60 |
enderdragon.type GAUGE |
| 61 |
enderdragon.label killed ender dragons |
| 62 |
wither.type GAUGE |
| 63 |
wither.label killed withers |
| 64 |
"); |
| 65 |
exit(); |
| 66 |
} |
| 67 |
|
| 68 |
## Construct 'minumum' timstamp |
| 69 |
$current = mktime(); |
| 70 |
$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current));
|
| 71 |
|
| 72 |
## Initiate connection |
| 73 |
$connection = mysqli_connect($hostname, $username, $password, $database, $port); |
| 74 |
|
| 75 |
## Check connection |
| 76 |
if (mysqli_connect_errno()) {
|
| 77 |
printf("Connect failed: %s\n", mysqli_connect_error());
|
| 78 |
exit(); |
| 79 |
} |
| 80 |
|
| 81 |
## Select queries for blaze kills and return the amount of rows |
| 82 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Blaze'")) {
|
| 83 |
## Print values |
| 84 |
print('blaze.value ' . mysqli_num_rows($result) . "\n");
|
| 85 |
} |
| 86 |
|
| 87 |
## Select queries for spider kills and return the amount of rows |
| 88 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%Spider'")) {
|
| 89 |
## Print values |
| 90 |
print('spider.value ' . mysqli_num_rows($result) . "\n");
|
| 91 |
} |
| 92 |
|
| 93 |
## Select queries for creeper kills and return the amount of rows |
| 94 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%reeper%'")) {
|
| 95 |
## Print values |
| 96 |
print('creeper.value ' . mysqli_num_rows($result) . "\n");
|
| 97 |
} |
| 98 |
|
| 99 |
## Select queries for ghast kills and return the amount of rows |
| 100 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Ghast'")) {
|
| 101 |
## Print values |
| 102 |
print('ghast.value ' . mysqli_num_rows($result) . "\n");
|
| 103 |
} |
| 104 |
|
| 105 |
## Select queries for magma cube kills and return the amount of rows |
| 106 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'MagmaCube'")) {
|
| 107 |
## Print values |
| 108 |
print('magmacube.value ' . mysqli_num_rows($result) . "\n");
|
| 109 |
} |
| 110 |
|
| 111 |
## Select queries for silverfish and return the amount of rows |
| 112 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Silverfish'")) {
|
| 113 |
## Print values |
| 114 |
print('silverfish.value ' . mysqli_num_rows($result) . "\n");
|
| 115 |
} |
| 116 |
|
| 117 |
## Select queries for skeleton kills and return the amount of rows |
| 118 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Skeleton'")) {
|
| 119 |
## Print values |
| 120 |
print('skeleton.value ' . mysqli_num_rows($result) . "\n");
|
| 121 |
} |
| 122 |
|
| 123 |
## Select queries for slime kills and return the amount of rows |
| 124 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Slime'")) {
|
| 125 |
## Print values |
| 126 |
print('slime.value ' . mysqli_num_rows($result) . "\n");
|
| 127 |
} |
| 128 |
|
| 129 |
## Select queries for witch kills and return the amount of rows |
| 130 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Witch'")) {
|
| 131 |
## Print values |
| 132 |
print('witch.value ' . mysqli_num_rows($result) . "\n");
|
| 133 |
} |
| 134 |
|
| 135 |
## Select queries for zombie kills and return the amount of rows |
| 136 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Zombie'")) {
|
| 137 |
## Print values |
| 138 |
print('zombie.value ' . mysqli_num_rows($result) . "\n");
|
| 139 |
} |
| 140 |
|
| 141 |
## Select queries for iron golem kills and return the amount of rows |
| 142 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%ron%'")) {
|
| 143 |
## Print values |
| 144 |
print('irongolem.value ' . mysqli_num_rows($result) . "\n");
|
| 145 |
} |
| 146 |
|
| 147 |
## Select queries for ender dragon kills and return the amount of rows |
| 148 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'EnderDragon'")) {
|
| 149 |
## Print values |
| 150 |
print('enderdragon.value ' . mysqli_num_rows($result) . "\n");
|
| 151 |
} |
| 152 |
|
| 153 |
## Select queries for wither kills and return the amount of rows |
| 154 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Wither'")) {
|
| 155 |
## Print values |
| 156 |
print('wither.value ' . mysqli_num_rows($result) . "\n");
|
| 157 |
} |
| 158 |
|
| 159 |
## Close connection |
| 160 |
mysqli_close($connection); |
| 161 |
?> |
