mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Added several Minecraft/Bukkit plugins (depending on JSONAPI, Statistician and Ultrabans) to show the current online players, the RAM usage, the current TPS (ticks per second), hostile/neutral/passive mob kills per day, new players/visitors per day and kicks/ban/mutes/jail/unban/etc. per day - http://s.frd.mn/XJsryR for more informations
This commit is contained in:
parent
46d1dcc987
commit
bed5815230
8 changed files with 758 additions and 0 deletions
55
plugins/minecraft/minecraft-jsonapi-players
Normal file
55
plugins/minecraft/minecraft-jsonapi-players
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/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
|
||||||
|
*/
|
||||||
|
|
||||||
|
$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 SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php)
|
||||||
|
require('/var/cache/munin/JSONAPI.php');
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
}
|
||||||
|
?>
|
64
plugins/minecraft/minecraft-jsonapi-ramusage
Normal file
64
plugins/minecraft/minecraft-jsonapi-ramusage
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
#!/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
|
||||||
|
*/
|
||||||
|
|
||||||
|
$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 SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php)
|
||||||
|
require('/var/cache/munin/JSONAPI.php');
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
}
|
||||||
|
?>
|
55
plugins/minecraft/minecraft-jsonapi-tps
Normal file
55
plugins/minecraft/minecraft-jsonapi-tps
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/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
|
||||||
|
*/
|
||||||
|
|
||||||
|
$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 SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php)
|
||||||
|
require('/var/cache/munin/JSONAPI.php');
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
}
|
||||||
|
?>
|
161
plugins/minecraft/minecraft-sql-statistician-hostile-kills
Normal file
161
plugins/minecraft/minecraft-sql-statistician-hostile-kills
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
#!/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);
|
||||||
|
?>
|
89
plugins/minecraft/minecraft-sql-statistician-neutral-kills
Normal file
89
plugins/minecraft/minecraft-sql-statistician-neutral-kills
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
#!/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);
|
||||||
|
?>
|
65
plugins/minecraft/minecraft-sql-statistician-newplayers
Normal file
65
plugins/minecraft/minecraft-sql-statistician-newplayers
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
#!/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);
|
||||||
|
?>
|
129
plugins/minecraft/minecraft-sql-statistician-passive-kills
Normal file
129
plugins/minecraft/minecraft-sql-statistician-passive-kills
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
#!/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);
|
||||||
|
?>
|
140
plugins/minecraft/minecraft-sql-ultrabans-shame
Normal file
140
plugins/minecraft/minecraft-sql-ultrabans-shame
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
#!/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);
|
||||||
|
?>
|
Loading…
Reference in a new issue