2013-03-27 07:11:27 +01:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
2013-03-28 16:06:49 +01:00
|
|
|
/**
|
|
|
|
* Bukkit/MySQL Munin plugin
|
|
|
|
* ---------------------------------
|
|
|
|
* Hostile mob kills per day
|
|
|
|
*
|
|
|
|
* Shows the daily kills of hostile 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
|
2018-08-02 02:03:42 +02:00
|
|
|
*
|
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 - hostile 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 hostile mob kills per day
|
|
|
|
graph_args --base 1000 -l 0
|
|
|
|
blaze.type GAUGE
|
|
|
|
blaze.label killed blazes
|
|
|
|
spider.type GAUGE
|
|
|
|
spider.label killed spiders
|
|
|
|
creeper.type GAUGE
|
|
|
|
creeper.label killed creepers
|
|
|
|
ghast.type GAUGE
|
|
|
|
ghast.label killed ghasts
|
|
|
|
magmacube.type GAUGE
|
|
|
|
magmacube.label killed magma cubes
|
|
|
|
silverfish.type GAUGE
|
|
|
|
silverfish.label killed silverfish
|
|
|
|
skeleton.type GAUGE
|
|
|
|
skeleton.label killed skeletons
|
|
|
|
slime.type GAUGE
|
|
|
|
slime.label killed slimes
|
|
|
|
witch.type GAUGE
|
|
|
|
witch.label killed witches
|
|
|
|
zombie.type GAUGE
|
|
|
|
zombie.label killed zombies
|
|
|
|
irongolem.type GAUGE
|
|
|
|
irongolem.label killed iron golems
|
|
|
|
enderdragon.type GAUGE
|
|
|
|
enderdragon.label killed ender dragons
|
|
|
|
wither.type GAUGE
|
|
|
|
wither.label killed withers
|
|
|
|
");
|
|
|
|
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));
|
|
|
|
|
|
|
|
## 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 for blaze kills and return the amount of rows
|
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Blaze'")) {
|
|
|
|
## Print values
|
|
|
|
print('blaze.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
## Select queries for spider kills and return the amount of rows
|
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%Spider'")) {
|
|
|
|
## Print values
|
|
|
|
print('spider.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
## Select queries for creeper kills and return the amount of rows
|
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%reeper%'")) {
|
|
|
|
## Print values
|
|
|
|
print('creeper.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
## Select queries for ghast kills and return the amount of rows
|
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Ghast'")) {
|
|
|
|
## Print values
|
|
|
|
print('ghast.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
## Select queries for magma cube kills and return the amount of rows
|
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'MagmaCube'")) {
|
|
|
|
## Print values
|
|
|
|
print('magmacube.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
## Select queries for silverfish and return the amount of rows
|
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Silverfish'")) {
|
|
|
|
## Print values
|
|
|
|
print('silverfish.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
## Select queries for skeleton kills and return the amount of rows
|
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Skeleton'")) {
|
|
|
|
## Print values
|
|
|
|
print('skeleton.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
## Select queries for slime kills and return the amount of rows
|
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Slime'")) {
|
|
|
|
## Print values
|
|
|
|
print('slime.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
## Select queries for witch kills and return the amount of rows
|
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Witch'")) {
|
|
|
|
## Print values
|
|
|
|
print('witch.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
## Select queries for zombie kills and return the amount of rows
|
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Zombie'")) {
|
|
|
|
## Print values
|
|
|
|
print('zombie.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
## Select queries for iron golem kills and return the amount of rows
|
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%ron%'")) {
|
|
|
|
## Print values
|
|
|
|
print('irongolem.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
## Select queries for ender dragon kills and return the amount of rows
|
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'EnderDragon'")) {
|
|
|
|
## Print values
|
|
|
|
print('enderdragon.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
## Select queries for wither kills and return the amount of rows
|
|
|
|
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Wither'")) {
|
|
|
|
## Print values
|
|
|
|
print('wither.value ' . mysqli_num_rows($result) . "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
## Close connection
|
|
|
|
mysqli_close($connection);
|
2014-09-06 15:11:07 +02:00
|
|
|
?>
|