summaryrefslogtreecommitdiff
path: root/source3/include
diff options
context:
space:
mode:
authortodd stecher <todd.stecher@gmail.com>2009-02-08 23:10:34 -0800
committerTim Prouty <tprouty@samba.org>2009-02-09 13:23:44 -0800
commit54c51a66e3e31c70a641d7efac2d4b08c3007278 (patch)
tree01ea8154819950eec666579dfeaad7724cf3fdb1 /source3/include
parent98a4327b19e83ffad4e0be7e8895fdbd9e48d49f (diff)
downloadsamba-54c51a66e3e31c70a641d7efac2d4b08c3007278.tar.gz
samba-54c51a66e3e31c70a641d7efac2d4b08c3007278.tar.bz2
samba-54c51a66e3e31c70a641d7efac2d4b08c3007278.zip
S3: New module interface for SMB message statistics gathering
This changelist allows for the addition of custom performance monitoring modules through smb.conf. Entrypoints in the main message processing code have been added to capture the command, subop, ioctl, identity and message size statistics.
Diffstat (limited to 'source3/include')
-rw-r--r--source3/include/includes.h1
-rw-r--r--source3/include/proto.h5
-rw-r--r--source3/include/smb.h3
-rw-r--r--source3/include/smb_perfcount.h106
4 files changed, 114 insertions, 1 deletions
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 930df6e36c..095fcaa3da 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -597,6 +597,7 @@ struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx);
#include "privileges.h"
#include "messages.h"
#include "locking.h"
+#include "smb_perfcount.h"
#include "smb.h"
#include "nameserv.h"
#include "secrets.h"
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 537eb98ffc..7deaff3e19 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4358,6 +4358,8 @@ void lp_set_posix_pathnames(void);
enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp);
void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val);
int lp_min_receive_file_size(void);
+char* lp_smb_perfcount_module(void);
+
/* The following definitions come from param/params.c */
@@ -6978,7 +6980,8 @@ SEC_DESC *get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fname);
void smbd_setup_sig_term_handler(void);
void smbd_setup_sig_hup_handler(void);
-bool srv_send_smb(int fd, char *buffer, bool do_encrypt);
+bool srv_send_smb(int fd, char *buffer, bool do_encrypt,
+ struct smb_perfcount_data *pcd);
int srv_set_message(char *buf,
int num_words,
int num_bytes,
diff --git a/source3/include/smb.h b/source3/include/smb.h
index eaf09dd09c..3da63cfc2b 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -613,6 +613,7 @@ struct current_user {
NT_USER_TOKEN *nt_user_token;
};
+
struct smb_request {
uint8_t cmd;
uint16 flags2;
@@ -640,6 +641,7 @@ struct smb_request {
size_t unread_bytes;
bool encrypted;
connection_struct *conn;
+ struct smb_perfcount_data pcd;
/*
* Chained request handling
@@ -717,6 +719,7 @@ struct pending_message_list {
struct pending_message_list *next, *prev;
struct timeval request_time; /* When was this first issued? */
struct timed_event *te;
+ struct smb_perfcount_data pcd;
bool encrypted;
DATA_BLOB buf;
DATA_BLOB private_data;
diff --git a/source3/include/smb_perfcount.h b/source3/include/smb_perfcount.h
new file mode 100644
index 0000000000..218045be88
--- /dev/null
+++ b/source3/include/smb_perfcount.h
@@ -0,0 +1,106 @@
+/*
+ Unix SMB/CIFS implementation.
+ Portable SMB Messaging statistics interfaces
+ Copyright (C) Todd Stecher (2008)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _SMB_PERFCOUNT_H_
+#define _SMB_PERFCOUNT_H_
+
+#define SMB_PERFCOUNTER_INTERFACE_VERSION 1
+
+struct smb_perfcount_data{
+ struct smb_perfcount_handlers *handlers;
+ void *context;
+};
+
+struct smb_perfcount_handlers {
+ void (*perfcount_start) (struct smb_perfcount_data *pcd);
+ void (*perfcount_add) (struct smb_perfcount_data *pcd);
+ void (*perfcount_set_op) (struct smb_perfcount_data *pcd, int op);
+ void (*perfcount_set_subop) (struct smb_perfcount_data *pcd, int subop);
+ void (*perfcount_set_ioctl) (struct smb_perfcount_data *pcd, int io_ctl);
+ void (*perfcount_set_msglen_in) (struct smb_perfcount_data *pcd,
+ uint64_t in_bytes);
+ void (*perfcount_set_msglen_out) (struct smb_perfcount_data *pcd,
+ uint64_t out_bytes);
+ void (*perfcount_set_client) (struct smb_perfcount_data *pcd, uid_t uid,
+ const char *user, const char *domain);
+ void (*perfcount_defer_op) (struct smb_perfcount_data *pcd,
+ struct smb_perfcount_data *def_pcd);
+ void (*perfcount_end) (struct smb_perfcount_data *pcd);
+};
+
+bool smb_perfcount_init(void);
+
+NTSTATUS smb_register_perfcounter(int interface_version, const char *name,
+ const struct smb_perfcount_handlers *handlers);
+
+void smb_init_perfcount_data(struct smb_perfcount_data *pcd);
+
+#define SMB_PERFCOUNT_START(_pcd_) \
+ do {if((_pcd_) && (_pcd_)->handlers) \
+ (_pcd_)->handlers->perfcount_start((_pcd_)); \
+ } while (0)
+
+#define SMB_PERFCOUNT_ADD(_pcd_) \
+ do {if((_pcd_) && (_pcd_)->handlers) \
+ (_pcd_)->handlers->perfcount_add((_pcd_)); \
+ } while (0)
+
+#define SMB_PERFCOUNT_SET_OP(_pcd_,_op_) \
+ do {if((_pcd_) && (_pcd_)->handlers) \
+ (_pcd_)->handlers->perfcount_set_op((_pcd_), (_op_)); \
+ } while (0)
+
+#define SMB_PERFCOUNT_SET_SUBOP(_pcd_,_subop_) \
+ do {if((_pcd_) && (_pcd_)->handlers) \
+ (_pcd_)->handlers->perfcount_set_subop((_pcd_), (_subop_)); \
+ } while (0)
+
+#define SMB_PERFCOUNT_SET_IOCTL(_pcd_,_subop_) \
+ do {if((_pcd_) && (_pcd_)->handlers) \
+ (_pcd_)->handlers->perfcount_set_ioctl((_pcd_), (_subop_)); \
+ } while (0)
+
+#define SMB_PERFCOUNT_SET_MSGLEN_IN(_pcd_,_in_) \
+ do {if((_pcd_) && (_pcd_)->handlers) \
+ (_pcd_)->handlers->perfcount_set_msglen_in((_pcd_), (_in_));\
+ } while (0)
+
+#define SMB_PERFCOUNT_SET_MSGLEN_OUT(_pcd_,_out_) \
+ do {if((_pcd_) && (_pcd_)->handlers) \
+ (_pcd_)->handlers->perfcount_set_msglen_out((_pcd_), (_out_));\
+ } while (0)
+
+
+#define SMB_PERFCOUNT_SET_CLIENT(_pcd_,_uid_, _user_, _domain_) \
+ do {if((_pcd_) && (_pcd_)->handlers) \
+ (_pcd_)->handlers->perfcount_set_client((_pcd_), (_uid_), \
+ (_user_), (_domain_)); \
+ } while (0)
+
+#define SMB_PERFCOUNT_DEFER_OP(_pcd_, _def_pcd_) \
+ do {if((_pcd_) && (_pcd_)->handlers) \
+ (_pcd_)->handlers->perfcount_defer_op((_pcd_), (_def_pcd_)); \
+ } while (0)
+
+#define SMB_PERFCOUNT_END(_pcd_) \
+ do {if((_pcd_) && (_pcd_)->handlers) \
+ (_pcd_)->handlers->perfcount_end((_pcd_));\
+ } while (0)
+
+#endif /* _SMB_PERFCOUNT_H_ */