r8583: nicer smbstatus output
authorAndrew Tridgell <tridge@samba.org>
Tue, 19 Jul 2005 06:08:06 +0000 (06:08 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:29:41 +0000 (13:29 -0500)
(This used to be commit 0578bcdf7f8919509a78a5c64f94aa5de7e90416)

source4/scripting/bin/smbstatus

index 9f7566a6420e488ebfb5364e05ef6fc42d6fab8d..eaf3aa1616c9f6205f19433db86942e93d87b932 100755 (executable)
@@ -15,23 +15,55 @@ ok = GetOptions(ARGV, options,
                "POPT_AUTOHELP",
                "POPT_COMMON_SAMBA");
 if (ok == false) {
-   println("Failed to parse options: " + options.ERROR);
-   return -1;
+       println("Failed to parse options: " + options.ERROR);
+       return -1;
 }
 
-
-var sessions = smbsrv_sessions();
-if (sessions == undefined) {
-       println("No sessions");
-       exit(0);
+/*
+  show open sessions
+*/
+function show_sessions()
+{
+       var sessions = smbsrv_sessions();
+       var i;
+       var sys = sys_init();
+       if (sessions == undefined) {
+               println("No sessions open");
+               return;
+       }
+       printf("User                                  Client      Connected at\n");
+       printf("-------------------------------------------------------------------------------\n");
+       for (i=0;i<sessions.length;i++) {
+               var info = sessions[i];
+               var fulluser = sprintf("%s/%s", info.account_name, info.domain_name);
+               printf("%-30s %16s   %s\n", 
+                      fulluser, info.client_ip, sys.httptime(info.connect_time));
+       }
+       printf("\n");
 }
-printVars(sessions);
 
-var trees = smbsrv_trees();
-if (trees == undefined) {
-       println("No trees");
-       exit(0);
+/*
+  show open tree connects
+*/
+function show_trees()
+{
+       var trees = smbsrv_trees();
+       var sys = sys_init();
+       if (trees == undefined) {
+               println("No tree connects");
+               return;
+       }
+       printf("Share                                 Client      Connected at\n");
+       printf("-------------------------------------------------------------------------------\n");
+       for (i=0;i<trees.length;i++) {
+               var info = trees[i];
+               printf("%-30s %16s   %s\n", 
+                      info.share_name, info.client_ip, sys.httptime(info.connect_time));
+       }
 }
-printVars(trees);
+
+
+show_sessions();
+show_trees();
 
 return 0;