-
Notifications
You must be signed in to change notification settings - Fork 1
/
bukkit-statistician-killshostile
161 lines (140 loc) · 5.32 KB
/
bukkit-statistician-killshostile
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
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
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);
?>