]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
profile: Add number of sessions, tcons and files to smbstatus -P
authorVolker Lendecke <vl@samba.org>
Wed, 22 Nov 2023 15:12:01 +0000 (16:12 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 11 Apr 2025 18:46:40 +0000 (18:46 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source3/include/smbprofile.h
source3/profile/profile.c
source3/smbd/smb2_process.c

index 689a84d9c8d7188ed478e6d4e4f48d56ac376200..3354770efe72f1d94bf6a55f4ce4f841edcb2c3e 100644 (file)
@@ -476,6 +476,7 @@ struct smbprofile_global_state {
                struct tdb_wrap *db;
                struct tevent_context *ev;
                struct tevent_timer *te;
+               struct smbd_server_connection *sconn;
        } internal;
 
        struct {
@@ -491,7 +492,8 @@ struct smbprofile_global_state {
 extern struct smbprofile_global_state smbprofile_state;
 
 void smbprofile_dump_schedule_timer(void);
-void smbprofile_dump_setup(struct tevent_context *ev);
+void smbprofile_dump_setup(struct tevent_context *ev,
+                          struct smbd_server_connection *sconn);
 
 static inline void smbprofile_dump_schedule(void)
 {
@@ -644,7 +646,8 @@ static inline bool smbprofile_dump_pending(void)
        return false;
 }
 
-static inline void smbprofile_dump_setup(struct tevent_context *ev)
+static inline void smbprofile_dump_setup(struct tevent_context *ev,
+                                        struct smbd_server_connection *sconn)
 {
        return;
 }
index 8bc261361ff8c9b17fb409d5d60e8b2a8f2179f5..d24a6382c920b972022ad6b1b3a74eb12095b874 100644 (file)
@@ -163,10 +163,12 @@ out:
        return ok;
 }
 
-void smbprofile_dump_setup(struct tevent_context *ev)
+void smbprofile_dump_setup(struct tevent_context *ev,
+                          struct smbd_server_connection *sconn)
 {
        TALLOC_FREE(smbprofile_state.internal.te);
        smbprofile_state.internal.ev = ev;
+       smbprofile_state.internal.sconn = sconn;
 }
 
 static void smbprofile_dump_timer(struct tevent_context *ev,
@@ -174,7 +176,7 @@ static void smbprofile_dump_timer(struct tevent_context *ev,
                                  struct timeval current_time,
                                  void *private_data)
 {
-       smbprofile_dump(NULL);
+       smbprofile_dump(smbprofile_state.internal.sconn);
 }
 
 void smbprofile_dump_schedule_timer(void)
index 67cc0978771c2f62da31e433ec3e2b3e34e6cd86..745985e5c0e8451d297e4597794dd69b889bbbad 100644 (file)
@@ -1738,6 +1738,7 @@ static void smbd_id_cache_kill(struct messaging_context *msg_ctx,
 struct smbd_tevent_trace_state {
        struct tevent_context *ev;
        TALLOC_CTX *frame;
+       struct smbd_server_connection *sconn;
        SMBPROFILE_BASIC_ASYNC_STATE(profile_idle);
        struct timeval before_wait_tv;
        struct timeval after_wait_tv;
@@ -1844,7 +1845,7 @@ static void smbd_tevent_trace_callback_profile(enum tevent_trace_point point,
                         *
                         * Instead we want to sleep as long as nothing happens.
                         */
-                       smbprofile_dump_setup(NULL);
+                       smbprofile_dump_setup(NULL, NULL);
                }
                SMBPROFILE_BASIC_ASYNC_START(idle, profile_p, state->profile_idle);
                break;
@@ -1856,12 +1857,12 @@ static void smbd_tevent_trace_callback_profile(enum tevent_trace_point point,
                         * We need to flush our state after sleeping
                         * (hopefully a long time).
                         */
-                       smbprofile_dump(NULL);
+                       smbprofile_dump(state->sconn);
                        /*
                         * future profiling events should trigger timers
                         * on our main event context.
                         */
-                       smbprofile_dump_setup(state->ev);
+                       smbprofile_dump_setup(state->ev, state->sconn);
                }
                break;
        case TEVENT_TRACE_BEFORE_LOOP_ONCE:
@@ -1923,6 +1924,7 @@ void smbd_process(struct tevent_context *ev_ctx,
        if (sconn == NULL) {
                exit_server("failed to create smbd_server_connection");
        }
+       trace_state.sconn = sconn;
 
        client->sconn = sconn;
        sconn->client = client;
@@ -2138,7 +2140,7 @@ void smbd_process(struct tevent_context *ev_ctx,
                exit(1);
        }
 
-       smbprofile_dump_setup(ev_ctx);
+       smbprofile_dump_setup(ev_ctx, sconn);
 
        if (!init_dptrs(sconn)) {
                exit_server("init_dptrs() failed");