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