s3:smbstatus add --fast option
authorChristian Ambach <ambi@samba.org>
Fri, 13 Jul 2012 15:24:02 +0000 (17:24 +0200)
committerChristian Ambach <ambi@samba.org>
Wed, 18 Jul 2012 13:49:52 +0000 (15:49 +0200)
this option skips all checks if the process for the record is still there
using it gives a huge performance benefit on busy systems and clusters while
it might display stale data if a smbd crashed

source3/utils/status.c

index b87f64c15933395d57e711715ca76f46797fd5aa..0cb46a5f536540022e3167d9442631ee0f10d88e 100644 (file)
@@ -56,6 +56,7 @@ static bool locks_only;            /* Added by RJS */
 static bool processes_only;
 static bool show_brl;
 static bool numeric_only;
+static bool do_checks = true;
 
 const char *username = NULL;
 
@@ -120,7 +121,7 @@ static void print_share_mode(const struct share_mode_entry *e,
 {
        static int count;
 
-       if (!is_valid_share_mode_entry(e)) {
+       if (do_checks && !is_valid_share_mode_entry(e)) {
                return;
        }
 
@@ -250,7 +251,8 @@ static int traverse_connections(const struct connections_key *key,
        if (crec->cnum == TID_FIELD_INVALID)
                return 0;
 
-       if (!process_exists(crec->pid) || !Ucrit_checkUid(crec->uid)) {
+       if (do_checks &&
+           (!process_exists(crec->pid) || !Ucrit_checkUid(crec->uid))) {
                return 0;
        }
 
@@ -267,8 +269,9 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
 {
        fstring uid_str, gid_str;
 
-       if (!process_exists(session->pid)
-           || !Ucrit_checkUid(session->uid)) {
+       if (do_checks &&
+           (!process_exists(session->pid) ||
+            !Ucrit_checkUid(session->uid))) {
                return 0;
        }
 
@@ -331,6 +334,7 @@ static void print_notify_recs(const char *path,
                {"profile-rates", 'R', POPT_ARG_NONE, NULL, 'R', "Show call rates" },
                {"byterange",   'B', POPT_ARG_NONE,     NULL, 'B', "Include byte range locks"},
                {"numeric",     'n', POPT_ARG_NONE,     NULL, 'n', "Numeric uid/gid"},
+               {"fast",        'f', POPT_ARG_NONE,     NULL, 'f', "Skip checks if processes still exist"},
                POPT_COMMON_SAMBA
                POPT_TABLEEND
        };
@@ -385,6 +389,9 @@ static void print_notify_recs(const char *path,
                case 'n':
                        numeric_only = true;
                        break;
+               case 'f':
+                       do_checks = false;
+                       break;
                }
        }