root / plugins / minecraft / jsonapi / mcsqls2killsneutral @ 2b174682
Historique | Voir | Annoter | Télécharger (2,77 ko)
| 1 |
#!/usr/bin/php |
|---|---|
| 2 |
<?php |
| 3 |
########################################################### |
| 4 |
## - Bukkit neutral 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 - neutral mob kills per day
|
| 25 |
graph_category bukkit_sql_kills |
| 26 |
graph_vlabel neutral mob kills per day |
| 27 |
graph_args --base 1000 -l 0 |
| 28 |
enderman.type GAUGE |
| 29 |
enderman.label killed endermen |
| 30 |
wolf.type GAUGE |
| 31 |
wolf.label killed wolf |
| 32 |
zombiepigman.type GAUGE |
| 33 |
zombiepigman.label killed zombie pigmen |
| 34 |
snowman.type GAUGE |
| 35 |
snowman.label killed snowmen |
| 36 |
"); |
| 37 |
exit(); |
| 38 |
} |
| 39 |
|
| 40 |
## Construct 'minumum' timstamp |
| 41 |
$current = mktime(); |
| 42 |
$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current));
|
| 43 |
|
| 44 |
## Initiate connection |
| 45 |
$connection = mysqli_connect($hostname, $username, $password, $database, $port); |
| 46 |
|
| 47 |
## Check connection |
| 48 |
if (mysqli_connect_errno()) {
|
| 49 |
printf("Connect failed: %s\n", mysqli_connect_error());
|
| 50 |
exit(); |
| 51 |
} |
| 52 |
|
| 53 |
## Select queries for enderman and return the amount of rows |
| 54 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Enderman'")) {
|
| 55 |
## Print values |
| 56 |
print('enderman.value ' . mysqli_num_rows($result) . "\n");
|
| 57 |
} |
| 58 |
|
| 59 |
## Select queries for wolf kills and return the amount of rows |
| 60 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Wolf'")) {
|
| 61 |
## Print values |
| 62 |
print('wolf.value ' . mysqli_num_rows($result) . "\n");
|
| 63 |
} |
| 64 |
|
| 65 |
## Select queries for zombie pigman kills and return the amount of rows |
| 66 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Zombie Pigman'")) {
|
| 67 |
## Print values |
| 68 |
print('zombiepigman.value ' . mysqli_num_rows($result) . "\n");
|
| 69 |
} |
| 70 |
|
| 71 |
## Select queries for zombie snowman kills and return the amount of rows |
| 72 |
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Snowman'")) {
|
| 73 |
## Print values |
| 74 |
print('snowman.value ' . mysqli_num_rows($result) . "\n");
|
| 75 |
} |
| 76 |
|
| 77 |
## Close connection |
| 78 |
mysqli_close($connection); |
| 79 |
?> |
