mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
55 lines
No EOL
1.7 KiB
PHP
55 lines
No EOL
1.7 KiB
PHP
#!/usr/bin/php
|
|
<?php
|
|
###########################################################
|
|
## - Bukkit new players per day Munin plugin - ##
|
|
###########################################################
|
|
## Script by: ##
|
|
## Jonas Friedmann (@frdmn) ##
|
|
## http://frd.mn ##
|
|
###########################################################
|
|
## MySQL ##
|
|
###########################################################
|
|
|
|
$hostname = 'localhost';
|
|
$username = 'sql';
|
|
$password = 'pass';
|
|
$database = 'sql';
|
|
$port = 3306;
|
|
|
|
###########################################################
|
|
## DON'T EDIT THIS ##
|
|
###########################################################
|
|
if ((count($argv) > 1) && ($argv[1] == 'config'))
|
|
{
|
|
print("graph_title Bukkit / Statistician - new players per day
|
|
graph_category bukkit_sql
|
|
graph_vlabel new players per day
|
|
graph_args --base 1000 -l 0
|
|
players.type GAUGE
|
|
players.label new players
|
|
");
|
|
exit();
|
|
}
|
|
|
|
## Construct 'minumum' timstamp
|
|
$current = mktime();
|
|
$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current));
|
|
|
|
## Initiate connection
|
|
$connection = mysqli_connect($hostname, $username, $password, $database, $port);
|
|
|
|
## Check connection
|
|
if (mysqli_connect_errno()) {
|
|
printf("Connect failed: %s\n", mysqli_connect_error());
|
|
exit();
|
|
}
|
|
|
|
## Select queries return the amount of rows
|
|
if ($result = mysqli_query($connection, "SELECT player_name FROM players WHERE firstever_login > $today")) {
|
|
## Print values
|
|
print('players.value ' . mysqli_num_rows($result) . "\n");
|
|
}
|
|
|
|
## Close connection
|
|
mysqli_close($connection);
|
|
?>
|