mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
119 lines
4.3 KiB
Plaintext
119 lines
4.3 KiB
Plaintext
|
#!/usr/bin/php
|
||
|
<?php
|
||
|
###########################################################
|
||
|
## - Bukkit passive mob kills per day Munin plugin - ##
|
||
|
###########################################################
|
||
|
## Script by: ##
|
||
|
## Jonas Friedmann (@frdmn) ##
|
||
|
## http://frd.mn ##
|
||
|
###########################################################
|
||
|
## MySQL ##
|
||
|
###########################################################
|
||
|
|
||
|
$hostname = 'localhost';
|
||
|
$username = 'sql';
|
||
|
$password = 'pass';
|
||
|
$database = 'sql';
|
||
|
$port = 3306;
|
||
|
|
||
|
###########################################################
|
||
|
## DON'T EDIT THIS ##
|
||
|
###########################################################
|
||
|
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);
|
||
|
?>
|