r8575: the beginnings of a smbstatus command
authorAndrew Tridgell <tridge@samba.org>
Tue, 19 Jul 2005 03:59:25 +0000 (03:59 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:29:40 +0000 (13:29 -0500)
(This used to be commit 4ecaf72a31cde2722315a61cbe823d44f0c14586)

source4/scripting/bin/smbstatus [new file with mode: 0755]
source4/scripting/libjs/management.js [new file with mode: 0644]

diff --git a/source4/scripting/bin/smbstatus b/source4/scripting/bin/smbstatus
new file mode 100755 (executable)
index 0000000..fd30090
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+exec smbscript "$0" ${1+"$@"}
+/*
+  provide information on connected users and open files
+  Copyright Andrew Tridgell 2005
+  Released under the GNU GPL v2 or later
+*/     
+
+libinclude("base.js");
+libinclude("management.js");
+
+var options = new Object();
+
+ok = GetOptions(ARGV, options,
+               "POPT_AUTOHELP",
+               "POPT_COMMON_SAMBA");
+if (ok == false) {
+   println("Failed to parse options: " + options.ERROR);
+   return -1;
+}
+
+
+var sessions = smbsrv_sessions();
+printVars(sessions);
+
+return 0;
diff --git a/source4/scripting/libjs/management.js b/source4/scripting/libjs/management.js
new file mode 100644 (file)
index 0000000..371ddc0
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+       backend code for Samba4 management
+       Copyright Andrew Tridgell 2005
+       Released under the GNU GPL v2 or later
+*/
+
+/*
+  return a list of current sessions 
+*/
+function smbsrv_sessions()
+{
+       var conn = new Object();
+       var irpc = irpc_init();
+       status = irpc_connect(conn, "smb_server");
+       assert(status.is_ok == true);
+
+       var io = irpcObj();
+       io.input.level = irpc.SMBSRV_INFO_SESSIONS;
+       status = irpc.smbsrv_information(conn, io);
+
+       /* gather the results into a single array */
+       var i, count=0, ret = new Object();
+       for (i=0;i<io.results.length;i++) {
+               var sessions = io.results[i].info.sessions.sessions;
+               var j;
+               for (j=0;j<sessions.length;j++) {
+                       ret[count] = sessions[j];
+                       count++;
+               }
+       }
+       ret.length = count;
+       return ret;
+}