root / plugins / minecraft / jsonapi / mcsqls2killspassive @ 2b174682
Historique | Voir | Annoter | Télécharger (4,27 ko)
| 1 |
#!/usr/bin/php |
|---|---|
| 2 |
<?php |
| 3 |
########################################################### |
| 4 |
## - Bukkit passive 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 - passive mob kills per day
|
| 25 |
graph_category bukkit_sql_kills |
| 26 |
graph_vlabel passive mob kills per day |
| 27 |
graph_args --base 1000 -l 0 |
| 28 |
bat.type GAUGE |
| 29 |
bat.label killed bats |
| 30 |
chicken.type GAUGE |
| 31 |
chicken.label killed chickens |
| 32 |
cow.type GAUGE |
| 33 |
cow.label killed cows |
| 34 |
mooshroom.type GAUGE |
| 35 |
mooshroom.label killed mooshrooms |
| 36 |
ocelot.type GAUGE |
| 37 |
ocelot.label killed magma ocelots |
| 38 |
pig.type GAUGE |
| 39 |
pig.label killed pigs |
| 40 |
sheep.type GAUGE |
| 41 |
sheep.label killed sheeps |
| 42 |
squid.type GAUGE |
| 43 |
squid.label killed squids |
| 44 |
villager.type GAUGE |
| 45 |
villager.label killed villager |
| 46 |
"); |
| 47 |
exit(); |
| 48 |
} |
| 49 |
|
| 50 |
## Construct 'minumum' timstamp |
| 51 |
$current = mktime(); |
| 52 |
$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current));
|
| 53 |
|
| 54 |
## Initiate connection |
| 55 |
$connection = mysqli_connect($hostname, $username, $password, $database, $port); |
| 56 |
|
| 57 |
## Check connection |
| 58 |
if (mysqli_connect_errno()) {
|
| 59 |
printf("Connect failed: %s\n", mysqli_connect_error());
|
| 60 |
exit(); |
| 61 |
} |
| 62 |
|
| 63 |
## Select queries for bat kills and return the amount of rows |
| 64 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Bat'")) {
|
| 65 |
## Print values |
| 66 |
print('bat.value ' . mysqli_num_rows($result) . "\n");
|
| 67 |
} |
| 68 |
|
| 69 |
## Select queries for chicken kills and return the amount of rows |
| 70 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Chicken'")) {
|
| 71 |
## Print values |
| 72 |
print('chicken.value ' . mysqli_num_rows($result) . "\n");
|
| 73 |
} |
| 74 |
|
| 75 |
## Select queries for mooshroom kills and return the amount of rows |
| 76 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'MushroomCow'")) {
|
| 77 |
## Print values |
| 78 |
print('mooshroom.value ' . mysqli_num_rows($result) . "\n");
|
| 79 |
} |
| 80 |
|
| 81 |
## Select queries for cow kills and return the amount of rows |
| 82 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Cow'")) {
|
| 83 |
## Print values |
| 84 |
print('cow.value ' . mysqli_num_rows($result) . "\n");
|
| 85 |
} |
| 86 |
|
| 87 |
## Select queries for ocelot kills and return the amount of rows |
| 88 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Ocelot'")) {
|
| 89 |
## Print values |
| 90 |
print('ocelot.value ' . mysqli_num_rows($result) . "\n");
|
| 91 |
} |
| 92 |
|
| 93 |
## Select queries for pig kills and return the amount of rows |
| 94 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Pig'")) {
|
| 95 |
## Print values |
| 96 |
print('pig.value ' . mysqli_num_rows($result) . "\n");
|
| 97 |
} |
| 98 |
|
| 99 |
## Select queries for sheep and return the amount of rows |
| 100 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Sheep'")) {
|
| 101 |
## Print values |
| 102 |
print('sheep.value ' . mysqli_num_rows($result) . "\n");
|
| 103 |
} |
| 104 |
|
| 105 |
## Select queries for squid kills and return the amount of rows |
| 106 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Squid'")) {
|
| 107 |
## Print values |
| 108 |
print('squid.value ' . mysqli_num_rows($result) . "\n");
|
| 109 |
} |
| 110 |
|
| 111 |
## Select queries for villager and return the amount of rows |
| 112 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Villager'")) {
|
| 113 |
## Print values |
| 114 |
print('villager.value ' . mysqli_num_rows($result) . "\n");
|
| 115 |
} |
| 116 |
|
| 117 |
## Close connection |
| 118 |
mysqli_close($connection); |
| 119 |
?> |
