2013-03-27 07:11:27 +01:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
2013-03-28 16:06:49 +01:00
|
|
|
/**
|
|
|
|
* Bukkit/MySQL Munin plugin
|
|
|
|
* ---------------------------------
|
|
|
|
* Neutral mob kills per day
|
|
|
|
*
|
|
|
|
* Shows the daily kills of neutral mobs
|
|
|
|
* 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)
|
2014-09-06 15:11:07 +02:00
|
|
|
* GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins
|
|
|
|
*
|
2013-03-28 16:06:49 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MySQL configuration
|
|
|
|
*/
|
2013-03-27 07:11:27 +01:00
|
|
|
|
|
|
|
$hostname = 'localhost';
|
|
|
|
$username = 'sql';
|
|
|
|
$password = 'pass';
|
|
|
|
$database = 'sql';
|
|
|
|
$port = 3306;
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
/**
|
|
|
|
* !!! DO NOT EDIT THIS PART BELOW !!!
|
|
|
|
*/
|
|
|
|
|
2013-03-27 07:11:27 +01:00
|
|
|
if ((count($argv) > 1) && ($argv[1] == 'config'))
|
|
|
|
{
|
|
|
|
print("graph_title Bukkit / Statistician - neutral mob kills per day
|
2017-02-20 23:53:04 +01:00
|
|
|
graph_category games
|
2013-03-27 07:11:27 +01:00
|
|
|
graph_vlabel neutral mob kills per day
|
|
|
|
graph_args --base 1000 -l 0
|
|
|
|
enderman.type GAUGE
|
|
|
|
enderman.label killed endermen
|
|
|
|
wolf.type GAUGE
|
|
|
|
wolf.label killed wolf
|
|
|
|
zombiepigman.type GAUGE
|
|
|
|
zombiepigman.label killed zombie pigmen
|
|
|
|
snowman.type GAUGE
|
|
|
|
snowman.label killed snowmen
|
|
|
|
");
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2014-12-05 00:37:42 +01:00
|
|
|
// Construct 'minimum' timstamp
|
2013-03-27 07:11:27 +01:00
|
|
|
$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
|
2013-03-27 07:11:27 +01:00
|
|
|
$connection = mysqli_connect($hostname, $username, $password, $database, $port);
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
// Check connection
|
2013-03-27 07:11:27 +01:00
|
|
|
if (mysqli_connect_errno()) {
|
|
|
|
printf("Connect failed: %s\n", mysqli_connect_error());
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
// Select queries for enderman and return the amount of rows
|
2013-03-27 07:11:27 +01:00
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Enderman'")) {
|
2013-03-28 16:06:49 +01:00
|
|
|
// Print values
|
2013-03-27 07:11:27 +01:00
|
|
|
print('enderman.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
// Select queries for wolf kills and return the amount of rows
|
2013-03-27 07:11:27 +01:00
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Wolf'")) {
|
2013-03-28 16:06:49 +01:00
|
|
|
// Print values
|
2013-03-27 07:11:27 +01:00
|
|
|
print('wolf.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
// Select queries for zombie pigman kills and return the amount of rows
|
2013-03-27 07:11:27 +01:00
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Zombie Pigman'")) {
|
2013-03-28 16:06:49 +01:00
|
|
|
// Print values
|
2013-03-27 07:11:27 +01:00
|
|
|
print('zombiepigman.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
// Select queries for zombie snowman kills and return the amount of rows
|
2013-03-27 07:11:27 +01:00
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Snowman'")) {
|
2013-03-28 16:06:49 +01:00
|
|
|
// Print values
|
2013-03-27 07:11:27 +01:00
|
|
|
print('snowman.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
// Close connection
|
2013-03-27 07:11:27 +01:00
|
|
|
mysqli_close($connection);
|
2014-09-06 15:11:07 +02:00
|
|
|
?>
|