r8584: added --nbt option to smbstatus for nbt server statistics
authorAndrew Tridgell <tridge@samba.org>
Tue, 19 Jul 2005 06:18:48 +0000 (06:18 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:29:41 +0000 (13:29 -0500)
(This used to be commit 26a676a4e3596d34aee391bf132f2525972c81df)

source4/scripting/bin/smbstatus
source4/scripting/libjs/management.js

index eaf3aa1616c9f6205f19433db86942e93d87b932..df8864f7e8e29b6538eea248c29eae13eb0363f5 100755 (executable)
@@ -13,7 +13,8 @@ var options = new Object();
 
 ok = GetOptions(ARGV, options,
                "POPT_AUTOHELP",
-               "POPT_COMMON_SAMBA");
+               "POPT_COMMON_SAMBA",
+               "nbt");
 if (ok == false) {
        println("Failed to parse options: " + options.ERROR);
        return -1;
@@ -62,8 +63,30 @@ function show_trees()
        }
 }
 
+/*
+  show nbtd information
+*/
+function show_nbt()
+{
+       var stats = nbtd_statistics();
+       if (stats == undefined) {
+               println("nbt server not running");
+               return;
+       }
+       var r;
+       println("NBT server statistics:");
+       for (r in stats) {
+               print("\t" + r + ":\t" + stats[r] + "\n");
+       }
+       println("");
+}
 
-show_sessions();
-show_trees();
+
+if (options['nbt'] != undefined) {
+       show_nbt();
+} else {
+       show_sessions();
+       show_trees();
+}
 
 return 0;
index d989541661c1b7e688a5f379618ed73153640937..8b042472484afe86e77291e67affec6090935471 100644 (file)
@@ -70,3 +70,24 @@ function smbsrv_trees()
        ret.length = count;
        return ret;
 }
+
+/*
+  return nbtd statistics
+*/
+function nbtd_statistics()
+{
+       var conn = new Object();
+       var irpc = irpc_init();
+       status = irpc_connect(conn, "nbt_server");
+       if (status.is_ok != true) {
+               return undefined;
+       }
+
+       var io = irpcObj();
+       io.input.level = irpc.NBTD_INFO_STATISTICS;
+       status = irpc.nbtd_information(conn, io);
+       if (status.is_ok != true) {
+               return undefined;
+       }
+       return io.results[0].info.stats;
+}