2013-03-27 07:11:27 +01:00
|
|
|
#!/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)
|
2014-09-06 15:11:07 +02:00
|
|
|
* GitHub: https://github.com/yeahwhat-mc/munin-bukkit-plugins
|
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 / Ultrabans - shame per day
|
2017-02-20 23:53:04 +01:00
|
|
|
graph_category games
|
2013-03-27 07:11:27 +01:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
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));
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
// Initiate connection
|
2013-03-27 07:11:27 +01:00
|
|
|
$connection = mysqli_connect($hostname, $username, $password, $database, $port);
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
// Check connection
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
$tmp1 = mysqli_num_rows($result);
|
|
|
|
}
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
// Select queries for mutes - part 2 return the amount of rows
|
2013-03-27 07:11:27 +01:00
|
|
|
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
|
2013-03-27 07:11:27 +01:00
|
|
|
$tmp2 = mysqli_num_rows($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
$mutes = $tmp1 + $tmp2;
|
|
|
|
|
|
|
|
print('mute.value ' . $mutes . "\n");
|
|
|
|
|
2013-03-28 16:06:49 +01:00
|
|
|
// Close connection
|
2013-03-27 07:11:27 +01:00
|
|
|
mysqli_close($connection);
|
2014-09-06 15:11:07 +02:00
|
|
|
?>
|