Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / minecraft / jsonapi / mcsqlubshame @ 2b174682

Historique | Voir | Annoter | Télécharger (4,16 ko)

1
#!/usr/bin/php
2
<?php
3
###########################################################
4
##          - Bukkit shame per day Munin plugin -        ##
5
###########################################################
6
## Script by:                                            ##
7
##           Jonas Friedmann (@frdmn)                    ##
8
##           http://frd.mn                               ##
9
###########################################################
10
##                        MySQL                          ##
11
###########################################################
12

    
13
$hostname = 'localhost';
14
$username = 'sql';
15
$password = 'pass';
16
$database = 'sql';
17
$port     = 3306;
18

    
19
###########################################################
20
##                     DON'T EDIT THIS                   ##
21
###########################################################
22
if ((count($argv) > 1) && ($argv[1] == 'config'))
23
{
24
print("graph_title Bukkit / Ultrabans - shame per day
25
graph_category bukkit_sql
26
graph_vlabel amount of shame per day
27
graph_args --base 1000 -l 0
28
unban.type GAUGE
29
unban.label unbans
30
kick.type GAUGE
31
kick.label kicks
32
warning.type GAUGE
33
warning.label warnings
34
ban.type GAUGE
35
ban.label bans
36
ipban.type GAUGE
37
ipban.label ipbans
38
fine.type GAUGE
39
fine.label fines
40
jail.type GAUGE
41
jail.label jails
42
permban.type GAUGE
43
permban.label permbans
44
mute.type GAUGE
45
mute.label mutes
46
");
47
exit();
48
}
49

    
50
## Construct 'minumum' timstamp
51
$current = mktime();
52
$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current));
53

    
54
## Initiate connection
55
$connection = mysqli_connect($hostname, $username, $password, $database, $port);
56

    
57
## Check connection
58
if (mysqli_connect_errno()) {
59
    printf("Connect failed: %s\n", mysqli_connect_error());
60
    exit();
61
}
62

    
63
## Select queries for unbans return the amount of rows
64
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 5 AND time > $today")) {
65
    ## Print values
66
    print('unban.value ' . mysqli_num_rows($result) . "\n");
67
}
68

    
69
## Select queries for kicks return the amount of rows
70
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 3 AND time > $today")) {
71
    ## Print values
72
    print('kick.value ' . mysqli_num_rows($result) . "\n");
73
}
74

    
75
## Select queries for warnings return the amount of rows
76
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 2 AND time > $today")) {
77
    ## Print values
78
    print('warning.value ' . mysqli_num_rows($result) . "\n");
79
}
80

    
81
## Select queries for bans return the amount of rows
82
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 0 AND time > $today")) {
83
    ## Print values
84
    print('ban.value ' . mysqli_num_rows($result) . "\n");
85
}
86

    
87
## Select queries for ipbans return the amount of rows
88
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 1 AND time > $today")) {
89
    ## Print values
90
    print('ipban.value ' . mysqli_num_rows($result) . "\n");
91
}
92

    
93
## Select queries for fines return the amount of rows
94
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 4 AND time > $today")) {
95
    ## Print values
96
    print('fine.value ' . mysqli_num_rows($result) . "\n");
97
}
98

    
99
## Select queries for jails return the amount of rows
100
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 6 AND time > $today")) {
101
    ## Print values
102
    print('jail.value ' . mysqli_num_rows($result) . "\n");
103
}
104

    
105
## Select queries for permbans return the amount of rows
106
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 9 AND time > $today")) {
107
    ## Print values
108
    print('permban.value ' . mysqli_num_rows($result) . "\n");
109
}
110

    
111
## Select queries for mutes - part 1 return the amount of rows
112
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 7 AND time > $today")) {
113
    ## Store result
114
    $tmp1 = mysqli_num_rows($result);
115
}
116

    
117
## Select queries for mutes - part 2 return the amount of rows
118
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 8 AND time > $today")) {
119
    ## Store result
120
    $tmp2 = mysqli_num_rows($result);
121
}
122

    
123
$mutes = $tmp1 + $tmp2;
124

    
125
print('mute.value ' . $mutes . "\n");
126

    
127
## Close connection
128
mysqli_close($connection);
129
?>