root / plugins / minecraft / minecraft-sql-statistician-newplayers @ 007c2825
Historique | Voir | Annoter | Télécharger (1,42 ko)
| 1 |
#!/usr/bin/php |
|---|---|
| 2 |
<?php |
| 3 |
/** |
| 4 |
* Bukkit/MySQL Munin plugin |
| 5 |
* --------------------------------- |
| 6 |
* New players per day |
| 7 |
* |
| 8 |
* Shows the new players / visitors per day |
| 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 - new players per day
|
| 35 |
graph_category bukkit_sql |
| 36 |
graph_vlabel new players per day |
| 37 |
graph_args --base 1000 -l 0 |
| 38 |
players.type GAUGE |
| 39 |
players.label new players |
| 40 |
"); |
| 41 |
exit(); |
| 42 |
} |
| 43 |
|
| 44 |
// Construct 'minumum' timstamp |
| 45 |
$current = mktime(); |
| 46 |
$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current));
|
| 47 |
|
| 48 |
// Initiate connection |
| 49 |
$connection = mysqli_connect($hostname, $username, $password, $database, $port); |
| 50 |
|
| 51 |
// Check connection |
| 52 |
if (mysqli_connect_errno()) {
|
| 53 |
printf("Connect failed: %s\n", mysqli_connect_error());
|
| 54 |
exit(); |
| 55 |
} |
| 56 |
|
| 57 |
// Select queries return the amount of rows |
| 58 |
if ($result = mysqli_query($connection, "SELECT player_name FROM players WHERE firstever_login > $today")) {
|
| 59 |
// Print values |
| 60 |
print('players.value ' . mysqli_num_rows($result) . "\n");
|
| 61 |
} |
| 62 |
|
| 63 |
// Close connection |
| 64 |
mysqli_close($connection); |
| 65 |
?> |
