]> git.sesse.net Git - nms/blob - web/mbd-status.pl
Actually add the MBD status too.
[nms] / web / mbd-status.pl
1 #! /usr/bin/perl
2 use CGI;
3 use DBI;
4 use lib '../include';
5 use nms;
6 my $cgi = CGI->new;
7
8 my $dbh = nms::db_connect();
9 print $cgi->header(-type=>'text/html', -refresh=>'10; http://nms.tg07.gathering.org/mbd-status.pl');
10
11 print <<"EOF";
12 <html>
13   <head>
14     <title>MBD status</title>
15   </head>
16   <body>
17     <h1>MBD status</h1>
18
19     <p>Spill søkt etter siste 15 minutter:</p>
20
21     <table>
22       <tr>
23         <th>Beskrivelse</th>
24         <th>Aktive servere</th>
25       </tr>
26 EOF
27
28 my $q = $dbh->prepare('select description,sum(active_servers) as active_servers from (select distinct on (game,port) * from mbd_log where ts >= now() - interval \'30 minutes\' order by game,port,ts desc ) t1 group by game,description order by sum(active_servers) desc, description;');
29 $q->execute();
30 while (my $ref = $q->fetchrow_hashref()) {
31         print <<"EOF";
32       <tr>
33         <td>$ref->{'description'}</td>
34         <td>$ref->{'active_servers'}</td>
35       </tr>
36 EOF
37 }
38 $dbh->disconnect;
39
40 print <<"EOF";
41     </table>
42   </body>
43 </html>
44 EOF