-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbukkit-statistician-killspassive
129 lines (112 loc) · 3.94 KB
/
bukkit-statistician-killspassive
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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
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);
?>