]> git.sesse.net Git - nms/commitdiff
Actually add the MBD status too.
authorroot <root@space>
Wed, 4 Apr 2007 21:22:33 +0000 (23:22 +0200)
committerroot <root@space>
Wed, 4 Apr 2007 21:22:33 +0000 (23:22 +0200)
web/mbd-status.pl [new file with mode: 0755]

diff --git a/web/mbd-status.pl b/web/mbd-status.pl
new file mode 100755 (executable)
index 0000000..33dee1d
--- /dev/null
@@ -0,0 +1,44 @@
+#! /usr/bin/perl
+use CGI;
+use DBI;
+use lib '../include';
+use nms;
+my $cgi = CGI->new;
+
+my $dbh = nms::db_connect();
+print $cgi->header(-type=>'text/html', -refresh=>'10; http://nms.tg07.gathering.org/mbd-status.pl');
+
+print <<"EOF";
+<html>
+  <head>
+    <title>MBD status</title>
+  </head>
+  <body>
+    <h1>MBD status</h1>
+
+    <p>Spill søkt etter siste 15 minutter:</p>
+
+    <table>
+      <tr>
+        <th>Beskrivelse</th>
+       <th>Aktive servere</th>
+      </tr>
+EOF
+
+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;');
+$q->execute();
+while (my $ref = $q->fetchrow_hashref()) {
+       print <<"EOF";
+      <tr>
+        <td>$ref->{'description'}</td>
+       <td>$ref->{'active_servers'}</td>
+      </tr>
+EOF
+}
+$dbh->disconnect;
+
+print <<"EOF";
+    </table>
+  </body>
+</html>
+EOF