diff options
Diffstat (limited to 'source4/scripting')
-rwxr-xr-x | source4/scripting/bin/smbstatus | 11 | ||||
-rw-r--r-- | source4/scripting/libjs/management.js | 41 |
2 files changed, 51 insertions, 1 deletions
diff --git a/source4/scripting/bin/smbstatus b/source4/scripting/bin/smbstatus index fd3009012b..9f7566a642 100755 --- a/source4/scripting/bin/smbstatus +++ b/source4/scripting/bin/smbstatus @@ -21,6 +21,17 @@ if (ok == false) { var sessions = smbsrv_sessions(); +if (sessions == undefined) { + println("No sessions"); + exit(0); +} printVars(sessions); +var trees = smbsrv_trees(); +if (trees == undefined) { + println("No trees"); + exit(0); +} +printVars(trees); + return 0; diff --git a/source4/scripting/libjs/management.js b/source4/scripting/libjs/management.js index 371ddc026b..d989541661 100644 --- a/source4/scripting/libjs/management.js +++ b/source4/scripting/libjs/management.js @@ -4,6 +4,7 @@ Released under the GNU GPL v2 or later */ + /* return a list of current sessions */ @@ -12,11 +13,16 @@ function smbsrv_sessions() var conn = new Object(); var irpc = irpc_init(); status = irpc_connect(conn, "smb_server"); - assert(status.is_ok == true); + if (status.is_ok != true) { + return undefined; + } var io = irpcObj(); io.input.level = irpc.SMBSRV_INFO_SESSIONS; status = irpc.smbsrv_information(conn, io); + if (status.is_ok != true) { + return undefined; + } /* gather the results into a single array */ var i, count=0, ret = new Object(); @@ -31,3 +37,36 @@ function smbsrv_sessions() ret.length = count; return ret; } + +/* + return a list of current tree connects +*/ +function smbsrv_trees() +{ + var conn = new Object(); + var irpc = irpc_init(); + status = irpc_connect(conn, "smb_server"); + if (status.is_ok != true) { + return undefined; + } + + var io = irpcObj(); + io.input.level = irpc.SMBSRV_INFO_TREES; + status = irpc.smbsrv_information(conn, io); + if (status.is_ok != true) { + return undefined; + } + + /* gather the results into a single array */ + var i, count=0, ret = new Object(); + for (i=0;i<io.results.length;i++) { + var trees = io.results[i].info.trees.trees; + var j; + for (j=0;j<trees.length;j++) { + ret[count] = trees[j]; + count++; + } + } + ret.length = count; + return ret; +} |