Projet

Général

Profil

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

root / plugins / aris / aris_players @ 8589c6df

Historique | Voir | Annoter | Télécharger (1,62 ko)

1
#!/usr/bin/php
2
# Copyright (C) 2012 David Gagnon <djgagnon@wisc.edu>
3
# Plugin to monitor ARIS users
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU Library General Public License as published by
7
# the Free Software Foundation; version 2 only
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU Library General Public License for more details.
13
#
14
# You should have received a copy of the GNU Library General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
#
18
# Parameters:
19
#
20
# 	config   (required)
21
# 	
22
#
23
#%# family=manual
24

    
25
<?php
26
$aris_db_host='localhost';
27
$aris_db_name='db';
28
$aris_db_user='user';
29
$aris_db_pass='password';
30

    
31
if ($argv[1]=='config'){
32
    print "graph_title ARIS active players\n";
33
    print "graph_vlabel Players Count\n";
34
    print "graph_category games\n";
35
    print "players.label player count\n";
36

    
37
    exit;
38
}
39

    
40
$sqlLink = mysql_connect($aris_db_host,$aris_db_user,$aris_db_pass) or die('MySQL authentication error');
41
mysql_select_db($aris_db_name) or die('MySQL Wrong Scheme Error');
42

    
43
    $query = 'SELECT COUNT(DISTINCT player_id) AS count FROM player_log WHERE timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 5 MINUTE) AND NOW()';
44
    $result = mysql_query($query);
45
    $numCurrentPlayersObject = mysql_fetch_object($result);
46
    $numCurrentPlayers = $numCurrentPlayersObject->count;
47

    
48
echo 'players.value '. $numCurrentPlayers;
49

    
50
?>