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-ultrabans-shame

142 lines
3.9 KiB
Plaintext
Raw Normal View History

#!/usr/bin/php
<?php
2013-03-28 16:06:49 +01:00
/**
* 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)
* 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 / Ultrabans - shame per day
graph_category games
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 'minimum' timstamp
$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
$connection = mysqli_connect($hostname, $username, $password, $database, $port);
2013-03-28 16:06:49 +01:00
// Check connection
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
2013-03-28 16:06:49 +01:00
// Select queries for unbans return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 5 AND time > $today")) {
2013-03-28 16:06:49 +01:00
// Print values
print('unban.value ' . mysqli_num_rows($result) . "\n");
}
2013-03-28 16:06:49 +01:00
// Select queries for kicks return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 3 AND time > $today")) {
2013-03-28 16:06:49 +01:00
// Print values
print('kick.value ' . mysqli_num_rows($result) . "\n");
}
2013-03-28 16:06:49 +01:00
// Select queries for warnings return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 2 AND time > $today")) {
2013-03-28 16:06:49 +01:00
// Print values
print('warning.value ' . mysqli_num_rows($result) . "\n");
}
2013-03-28 16:06:49 +01:00
// Select queries for bans return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 0 AND time > $today")) {
2013-03-28 16:06:49 +01:00
// Print values
print('ban.value ' . mysqli_num_rows($result) . "\n");
}
2013-03-28 16:06:49 +01:00
// Select queries for ipbans return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 1 AND time > $today")) {
2013-03-28 16:06:49 +01:00
// Print values
print('ipban.value ' . mysqli_num_rows($result) . "\n");
}
2013-03-28 16:06:49 +01:00
// Select queries for fines return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 4 AND time > $today")) {
2013-03-28 16:06:49 +01:00
// Print values
print('fine.value ' . mysqli_num_rows($result) . "\n");
}
2013-03-28 16:06:49 +01:00
// Select queries for jails return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 6 AND time > $today")) {
2013-03-28 16:06:49 +01:00
// Print values
print('jail.value ' . mysqli_num_rows($result) . "\n");
}
2013-03-28 16:06:49 +01:00
// Select queries for permbans return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 9 AND time > $today")) {
2013-03-28 16:06:49 +01:00
// Print values
print('permban.value ' . mysqli_num_rows($result) . "\n");
}
2013-03-28 16:06:49 +01:00
// 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")) {
2013-03-28 16:06:49 +01:00
// Store result
$tmp1 = mysqli_num_rows($result);
}
2013-03-28 16:06:49 +01:00
// 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")) {
2013-03-28 16:06:49 +01:00
// Store result
$tmp2 = mysqli_num_rows($result);
}
$mutes = $tmp1 + $tmp2;
print('mute.value ' . $mutes . "\n");
2013-03-28 16:06:49 +01:00
// Close connection
mysqli_close($connection);
?>