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-killshostile

163 lines
5.4 KiB
Plaintext
Raw Normal View History

#!/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)
* 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 - hostile mob kills per day
graph_category games
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();
}
## Construct 'minimum' 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 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);
?>