added stats command
authorpk910 <philipp@zoelle1.de>
Mon, 23 Jan 2012 20:38:10 +0000 (21:38 +0100)
committerpk910 <philipp@zoelle1.de>
Mon, 23 Jan 2012 20:38:10 +0000 (21:38 +0100)
INSTALL
zncadmin.php

diff --git a/INSTALL b/INSTALL
index 6377b47f2bd3965bf8719e5c2962e3dd49c82ee5..88e301c659fbe24aa33345f7c9bd10cc4023166a 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -30,6 +30,7 @@ ZNCAdmin is made to be used as external scripts from NeonServV5.
        +bind znc_whois NeonServ.extscript php scripts/zncadmin.php search $1 $2- %1+
        +bind znc_seen NeonServ.extscript php scripts/zncadmin.php seen $1 $2 %1+
        +bind znc_simul NeonServ.extscript php scripts/zncadmin.php simul $1 $2 $3- %1+
+       +bind znc_stats NeonServ.extscript php scripts/zncadmin.php stats $1 %1+
 
      You may also bind the "admin commands" (override the protected option)
        +bind znc_admin_add NeonServ.extscript php scripts/zncadmin.php force add $1 $2 %1+
index 669fca5a00e73976a87bca76aa276309e819a232..4fffe0e22ca993503b5e095432da45b9e7819ea4 100644 (file)
@@ -56,6 +56,9 @@ switch(strtolower($argv[1])) {
     case "simul":
         zncadmin_simul();
         break;
+    case "stats":
+        zncadmin_stats();
+        break;
     default:
         error("invalid subcommand '".$argv[1]."'");
         break;
@@ -456,4 +459,33 @@ function zncadmin_simul() {
     }
 }
 
+//SUBCOMMAND: stats
+function zncadmin_stats() {
+    global $argv, $zncservers;
+    $table = new Table(5);
+    $table->add("Server", "Port / SSL Port", "Total ZNC's", "Connected (IRC)", "Online (User)");
+    $count = 0;
+    foreach($zncservers as $zncserver) {
+        $total = 0;
+        $connected = 0;
+        $online = 0;
+        $zncserver['conn'] = new ZNCServer($zncserver['host'], $zncserver['port']);
+        $zncserver['conn']->login($zncserver['auser'], $zncserver['apass']);
+        foreach($zncserver['conn']->getUserList() as $user) {
+            if($user['server'] != "-N/A-") $connected++;
+            if($user['clients'] > 0) $online++;
+            $total++;
+        }
+        $table->add($zncserver['name'], $zncserver['port'].($zncserver['sslport'] ? "/".$zncserver['sslport'] : ""), $total.($zncserver['maxznc'] ? "/".$zncserver['maxznc'] : ""), $connected, $online);
+        $count++;
+    }
+    if($count) {
+        foreach($table->end() as $line) {
+            echo$line."\n";
+        }
+    } else {
+        echo "No Servers configured...\n";
+    }
+}
+
 ?>
\ No newline at end of file