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

Merge pull request #521 from frdmn/master

Fix frdmn's minecraft plugins
This commit is contained in:
dipohl 2014-09-06 16:14:36 +02:00
commit b92aabbdbf
17 changed files with 30 additions and 841 deletions

View File

@ -11,7 +11,8 @@
* http://s.frd.mn/XJsryR
*
* Author: Jonas Friedmann (http://frd.mn)
*
* GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins
*
*/
/**
@ -31,7 +32,7 @@ $port = 20059;
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / JSONAPI - players online
graph_category bukkit_jsonapi
graph_category bukkit
graph_vlabel players
graph_args --base 1000 -l 0
players.type GAUGE
@ -52,4 +53,4 @@ if ($result['result'] == 'success'){
// Print values
print('players.value ' . $result['success'] . "\n");
}
?>
?>

View File

@ -11,7 +11,8 @@
* http://s.frd.mn/XJsryR
*
* Author: Jonas Friedmann (http://frd.mn)
*
* GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins
*
*/
/**
@ -31,7 +32,7 @@ $port = 20059;
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / JSONAPI - RAM usage
graph_category bukkit_jsonapi
graph_category bukkit
graph_vlabel RAM usage in GB
graph_args --base 1024 -l 0
total.label total
@ -61,4 +62,4 @@ if ($result['result'] == 'success'){
print('used.value ' . round($result['success'][0]['success']/1000,2) . "\n");
print('total.value ' . round($result['success'][1]['success']/1000,2) . "\n");
}
?>
?>

View File

@ -11,7 +11,8 @@
* http://s.frd.mn/XJsryR
*
* Author: Jonas Friedmann (http://frd.mn)
*
* GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins
*
*/
/**
@ -31,7 +32,7 @@ $port = 20059;
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / JSONAPI - ticks per second (TPS)
graph_category bukkit_jsonapi
graph_category bukkit
graph_vlabel ticks per second
graph_args --base 1000 -l 0
tps.type GAUGE
@ -52,4 +53,4 @@ if ($result['result'] == 'success'){
// Print values
print('tps.value ' . round($result['success']['clockRate'], 2) . "\n");
}
?>
?>

View File

@ -12,7 +12,8 @@
* http://s.frd.mn/XJsryR
*
* Author: Jonas Friedmann (http://frd.mn)
*
* GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins
*
*/
/**
@ -32,7 +33,7 @@ $port = 3306;
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / Statistician - hostile mob kills per day
graph_category bukkit_sql_kills
graph_category bukkit
graph_vlabel hostile mob kills per day
graph_args --base 1000 -l 0
blaze.type GAUGE
@ -158,4 +159,4 @@ if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $
## Close connection
mysqli_close($connection);
?>
?>

View File

@ -12,7 +12,8 @@
* http://s.frd.mn/XJsryR
*
* Author: Jonas Friedmann (http://frd.mn)
*
* GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins
*
*/
/**
@ -32,7 +33,7 @@ $port = 3306;
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / Statistician - neutral mob kills per day
graph_category bukkit_sql_kills
graph_category bukkit
graph_vlabel neutral mob kills per day
graph_args --base 1000 -l 0
enderman.type GAUGE
@ -86,4 +87,4 @@ if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $
// Close connection
mysqli_close($connection);
?>
?>

View File

@ -12,7 +12,8 @@
* http://s.frd.mn/XJsryR
*
* Author: Jonas Friedmann (http://frd.mn)
*
* GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins
*
*/
/**
@ -32,7 +33,7 @@ $port = 3306;
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / Statistician - passive mob kills per day
graph_category bukkit_sql_kills
graph_category bukkit
graph_vlabel passive mob kills per day
graph_args --base 1000 -l 0
bat.type GAUGE
@ -126,4 +127,4 @@ if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $
// Close connection
mysqli_close($connection);
?>
?>

View File

@ -12,6 +12,7 @@
* http://s.frd.mn/XJsryR
*
* Author: Jonas Friedmann (http://frd.mn)
* GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins
*
*/
@ -32,7 +33,7 @@ $port = 3306;
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / Statistician - new players per day
graph_category bukkit_sql
graph_category bukkit
graph_vlabel new players per day
graph_args --base 1000 -l 0
players.type GAUGE
@ -62,4 +63,4 @@ if ($result = mysqli_query($connection, "SELECT player_name FROM players WHERE f
// Close connection
mysqli_close($connection);
?>
?>

View File

@ -13,6 +13,7 @@
* http://s.frd.mn/XJsryR
*
* Author: Jonas Friedmann (http://frd.mn)
* GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins
*
*/
@ -33,7 +34,7 @@ $port = 3306;
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / Ultrabans - shame per day
graph_category bukkit_sql
graph_category bukkit
graph_vlabel amount of shame per day
graph_args --base 1000 -l 0
unban.type GAUGE
@ -137,4 +138,4 @@ print('mute.value ' . $mutes . "\n");
// Close connection
mysqli_close($connection);
?>
?>

View File

@ -1,55 +0,0 @@
# munin-bukkit-plugins
This repository contains some useful [Munin](http://munin-monitoring.org/) plugins to monitor and observe a [Bukkit](http://bukkit.org) server:
* **mcjsonplayers** - players currently online
* **mcjsonramusage** - RAM usage
* **mcjsontps** - TPS (ticks per second)
* **mcsqls2killshostile** - hostile mob kills
* **mcsqls2killsneutral** - neutral mob kills
* **mcsqls2killspassive** - passive mob kills
* **mcsqls2players** - new players per day
* **mcsqlubshame** - kicks/bans/mutes/etc. per day
mcjson* requires [JSONAPI](https://github.com/alecgorge/jsonapi/)
mcsqls2* requires [Statistician](http://dev.bukkit.org/server-mods/statisticianv2/)
mcsqlub* requires [Ultrabans](http://dev.bukkit.org/server-mods/ultrabans/)
Read more in my [blog post](http://blog.frd.mn/munin-bukkit-plugins/).
## Requirements
* Web server with `PHP` support and Munin (2)
* Bukkit server with JSONAPI for the JSONAPI plugins (`mcjson*`)
* Bukkit server with Ultrabans for the Ultrabans plugins (`mcsqlub*`)
* Bukkit server with Statistician for the MySQL plugins (`mcsqls2*`)
* MySQL server for the SQL plugins
## Configuration
1. Clone this repository: `git clone git@github.com:frdmn/munin-bukkit-plugins.git`
1. Adjust the JSONAPI variables in the mcjson* files
1. Adjust the MySQL variables in the mcsql* files
1. Make sure the `PHP` binary in the Shebang line is executable
## Installation
1. Perform your configuration (see above)
1. Move the plugins into the Munin plugin directory: `mv mc* /usr/share/munin/plugins/`
1. Change the ownership: `chown munin:munin /usr/share/munin/plugins/mc*`
1. Make sure they are exectuable: `chmod 755 /usr/share/munin/plugins/mc*`
1. Enable the plugins: `ln -s /usr/share/munin/plugins/mc* /etc/munin/plugins/`
1. Restart your munin-node: `service munin-node restart`
1. Run your cron: `su - munin --shell=/bin/sh -c /usr/bin/munin-cron`
## Alerts and limits?
To setup alerts and limits add the following lines in your specific node in the `munin.conf` file:
[kotor.yeahwh.at]
address 5.9.115.5
[...]
mctps_main.warning 19.9: # Warning alert on < 19.9
mctps_main.critical 19: # Critical alert on < 19.0
mcplayer_main.warning 20 # Warning alert when there are 20 players online
mcplayer_main.critical 30 # Critical alert when there are more than 30 players online

View File

@ -1,57 +0,0 @@
#!/usr/bin/php
<?php
/**
* Bukkit player online Munin plugin
* ---------------------------------
*
* Shows the current online players
* (parsed via JSONAPI)
*
* Read more about my plugins on my blog:
* http://s.frd.mn/XJsryR
*
* Author: Jonas Friedmann (http://frd.mn)
*
*/
/**
* JSONAPI configuration
* (get the SDK php file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php)
*/
$apisdk = '/var/cache/munin/JSONAPI.php';
$hostname = 'your-hostname';
$username = 'your-username';
$password = 'your-password';
$salt = 'your-salt';
$port = 20059;
/**
* !!! DO NOT EDIT THIS PART BELOW !!!
*/
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / JSONAPI - players online
graph_category bukkit_jsonapi
graph_vlabel players
graph_args --base 1000 -l 0
players.type GAUGE
players.label players
");
exit();
}
// Include JSONAPI.php
require($apisdk);
// Prepare API call
$api = new JSONAPI($hostname, $port, $username, $password, $salt);
$result = $api->call("getPlayerCount");
// Check for success
if ($result['result'] == 'success'){
// Print values
print('players.value ' . $result['success'] . "\n");
}
?>

View File

@ -1,66 +0,0 @@
#!/usr/bin/php
<?php
/**
* Bukkit RAM usage Munin plugin
* ---------------------------------
*
* Shows the current RAM usage of your Minecraft process
* an the total RAM (parsed via JSONAPI)
*
* Read more about my plugins on my blog:
* http://s.frd.mn/XJsryR
*
* Author: Jonas Friedmann (http://frd.mn)
*
*/
/**
* JSONAPI configuration
* (get the SDK php file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php)
*/
$apisdk = '/var/cache/munin/JSONAPI.php';
$hostname = 'your-hostname';
$username = 'your-username';
$password = 'your-password';
$salt = 'your-salt';
$port = 20059;
/**
* !!! DO NOT EDIT THIS PART BELOW !!!
*/
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / JSONAPI - RAM usage
graph_category bukkit_jsonapi
graph_vlabel RAM usage in GB
graph_args --base 1024 -l 0
total.label total
total.type GAUGE
used.label used
used.type GAUGE
");
exit();
}
// Include JSONAPI.php
require($apisdk);
// Prepare API call
$api = new JSONAPI($hostname, $port, $username, $password, $salt);
$result = $api->callMultiple(array(
"system.getJavaMemoryUsage",
"system.getJavaMemoryTotal"
), array(
array(),
array(),
));
// Check for success
if ($result['result'] == 'success'){
// Print values
print('used.value ' . round($result['success'][0]['success']/1000,2) . "\n");
print('total.value ' . round($result['success'][1]['success']/1000,2) . "\n");
}
?>

View File

@ -1,57 +0,0 @@
#!/usr/bin/php
<?php
/**
* Bukkit TPS Munin plugin
* ---------------------------------
*
* Shows the current TPS (ticks per second) of your
* Minecraft server (parsed via JSONAPI)
*
* Read more about my plugins on my blog:
* http://s.frd.mn/XJsryR
*
* Author: Jonas Friedmann (http://frd.mn)
*
*/
/**
* JSONAPI configuration
* (get the SDK php file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php)
*/
$apisdk = '/var/cache/munin/JSONAPI.php';
$hostname = 'your-hostname';
$username = 'your-username';
$password = 'your-password';
$salt = 'your-salt';
$port = 20059;
/**
* !!! DO NOT EDIT THIS PART BELOW !!!
*/
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / JSONAPI - ticks per second (TPS)
graph_category bukkit_jsonapi
graph_vlabel ticks per second
graph_args --base 1000 -l 0
tps.type GAUGE
tps.label TPS
");
exit();
}
// Include JSONAPI.php
require($apisdk);
// Prepare API call
$api = new JSONAPI($hostname, $port, $username, $password, $salt);
$result = $api->call("system.getServerClockDebug");
// Check for success
if ($result['result'] == 'success'){
// Print values
print('tps.value ' . round($result['success']['clockRate'], 2) . "\n");
}
?>

View File

@ -1,161 +0,0 @@
#!/usr/bin/php
<?php
/**
* 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)
*
*/
/**
* MySQL configuration
*/
$hostname = 'localhost';
$username = 'sql';
$password = 'pass';
$database = 'sql';
$port = 3306;
/**
* !!! 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 bukkit_sql_kills
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 '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 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);
?>

View File

@ -1,89 +0,0 @@
#!/usr/bin/php
<?php
/**
* 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)
*
*/
/**
* MySQL configuration
*/
$hostname = 'localhost';
$username = 'sql';
$password = 'pass';
$database = 'sql';
$port = 3306;
/**
* !!! DO NOT EDIT THIS PART BELOW !!!
*/
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / Statistician - neutral mob kills per day
graph_category bukkit_sql_kills
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();
}
// 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 for enderman and return the amount of rows
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Enderman'")) {
// Print values
print('enderman.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for wolf kills and return the amount of rows
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Wolf'")) {
// Print values
print('wolf.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for zombie pigman kills and return the amount of rows
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Zombie Pigman'")) {
// Print values
print('zombiepigman.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for zombie snowman kills and return the amount of rows
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Snowman'")) {
// Print values
print('snowman.value ' . mysqli_num_rows($result) . "\n");
}
// Close connection
mysqli_close($connection);
?>

View File

@ -1,65 +0,0 @@
#!/usr/bin/php
<?php
/**
* 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)
*
*/
/**
* MySQL configuration
*/
$hostname = 'localhost';
$username = 'sql';
$password = 'pass';
$database = 'sql';
$port = 3306;
/**
* !!! DO NOT EDIT THIS PART BELOW !!!
*/
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);
?>

View File

@ -1,129 +0,0 @@
#!/usr/bin/php
<?php
/**
* Bukkit/MySQL Munin plugin
* ---------------------------------
* Passive mob kills per day
*
* Shows the passive 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)
*
*/
/**
* MySQL configuration
*/
$hostname = 'localhost';
$username = 'sql';
$password = 'pass';
$database = 'sql';
$port = 3306;
/**
* !!! DO NOT EDIT THIS PART BELOW !!!
*/
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / Statistician - passive mob kills per day
graph_category bukkit_sql_kills
graph_vlabel passive mob kills per day
graph_args --base 1000 -l 0
bat.type GAUGE
bat.label killed bats
chicken.type GAUGE
chicken.label killed chickens
cow.type GAUGE
cow.label killed cows
mooshroom.type GAUGE
mooshroom.label killed mooshrooms
ocelot.type GAUGE
ocelot.label killed magma ocelots
pig.type GAUGE
pig.label killed pigs
sheep.type GAUGE
sheep.label killed sheeps
squid.type GAUGE
squid.label killed squids
villager.type GAUGE
villager.label killed villager
");
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 for bat kills and return the amount of rows
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Bat'")) {
// Print values
print('bat.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for chicken kills and return the amount of rows
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Chicken'")) {
// Print values
print('chicken.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for mooshroom kills and return the amount of rows
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'MushroomCow'")) {
// Print values
print('mooshroom.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for cow kills and return the amount of rows
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Cow'")) {
// Print values
print('cow.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for ocelot kills and return the amount of rows
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Ocelot'")) {
// Print values
print('ocelot.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for pig kills and return the amount of rows
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Pig'")) {
// Print values
print('pig.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for sheep and return the amount of rows
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Sheep'")) {
// Print values
print('sheep.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for squid kills and return the amount of rows
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Squid'")) {
// Print values
print('squid.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for villager and return the amount of rows
if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Villager'")) {
// Print values
print('villager.value ' . mysqli_num_rows($result) . "\n");
}
// Close connection
mysqli_close($connection);
?>

View File

@ -1,140 +0,0 @@
#!/usr/bin/php
<?php
/**
* Bukkit/MySQL Munin plugin
* ---------------------------------
* Kicks/bans/jails/etc. per day
*
* Shows the amount and kind of shame that
* happens on your server via Ultrabans
* (http://s.frd.mn/14qLR2B)
*
* Read more about my plugins on my blog:
* http://s.frd.mn/XJsryR
*
* Author: Jonas Friedmann (http://frd.mn)
*
*/
/**
* MySQL configuration
*/
$hostname = 'localhost';
$username = 'sql';
$password = 'pass';
$database = 'sql';
$port = 3306;
/**
* !!! DO NOT EDIT THIS PART BELOW !!!
*/
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / Ultrabans - shame per day
graph_category bukkit_sql
graph_vlabel amount of shame per day
graph_args --base 1000 -l 0
unban.type GAUGE
unban.label unbans
kick.type GAUGE
kick.label kicks
warning.type GAUGE
warning.label warnings
ban.type GAUGE
ban.label bans
ipban.type GAUGE
ipban.label ipbans
fine.type GAUGE
fine.label fines
jail.type GAUGE
jail.label jails
permban.type GAUGE
permban.label permbans
mute.type GAUGE
mute.label mutes
");
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 for unbans return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 5 AND time > $today")) {
// Print values
print('unban.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for kicks return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 3 AND time > $today")) {
// Print values
print('kick.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for warnings return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 2 AND time > $today")) {
// Print values
print('warning.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for bans return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 0 AND time > $today")) {
// Print values
print('ban.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for ipbans return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 1 AND time > $today")) {
// Print values
print('ipban.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for fines return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 4 AND time > $today")) {
// Print values
print('fine.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for jails return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 6 AND time > $today")) {
// Print values
print('jail.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for permbans return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 9 AND time > $today")) {
// Print values
print('permban.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for mutes - part 1 return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 7 AND time > $today")) {
// Store result
$tmp1 = mysqli_num_rows($result);
}
// Select queries for mutes - part 2 return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 8 AND time > $today")) {
// Store result
$tmp2 = mysqli_num_rows($result);
}
$mutes = $tmp1 + $tmp2;
print('mute.value ' . $mutes . "\n");
// Close connection
mysqli_close($connection);
?>