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