2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/minecraft/bukkit-statistician-players

67 lines
1.5 KiB
Plaintext
Raw Normal View History

#!/usr/bin/php
<?php
2013-03-28 16:06:49 +01:00
/**
* Bukkit/MySQL Munin plugin
* ---------------------------------
* New players per day
*
* Shows the new players / visitors per day
* via Statistician (http://s.frd.mn/14qKXTM)
*
* Read more about my plugins on my blog:
* http://s.frd.mn/XJsryR
*
* Author: Jonas Friedmann (http://frd.mn)
* GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins
2013-03-28 16:06:49 +01:00
*
*/
/**
* MySQL configuration
*/
$hostname = 'localhost';
$username = 'sql';
$password = 'pass';
$database = 'sql';
$port = 3306;
2013-03-28 16:06:49 +01:00
/**
* !!! DO NOT EDIT THIS PART BELOW !!!
*/
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / Statistician - new players per day
graph_category games
graph_vlabel new players per day
graph_args --base 1000 -l 0
players.type GAUGE
players.label new players
");
exit();
}
// Construct 'minimum' timstamp
$current = mktime();
$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current));
2013-03-28 16:06:49 +01:00
// Initiate connection
$connection = mysqli_connect($hostname, $username, $password, $database, $port);
2013-03-28 16:06:49 +01:00
// Check connection
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
2013-03-28 16:06:49 +01:00
// Select queries return the amount of rows
if ($result = mysqli_query($connection, "SELECT player_name FROM players WHERE firstever_login > $today")) {
2013-03-28 16:06:49 +01:00
// Print values
print('players.value ' . mysqli_num_rows($result) . "\n");
}
2013-03-28 16:06:49 +01:00
// Close connection
mysqli_close($connection);
?>