summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Dickson <steved@redhat.com>2013-04-09 08:16:23 -0400
committerSteve Dickson <steved@redhat.com>2013-04-09 08:16:23 -0400
commit330857f790fe94b38001367a4cf6e376f72d656e (patch)
tree58c7a87cb6c1c225c09735ede2192877ae85326d
parentc70763075b9d1086ec40771bc800db09152a6994 (diff)
downloadsystemtap-330857f790fe94b38001367a4cf6e376f72d656e.tar.gz
systemtap-330857f790fe94b38001367a4cf6e376f72d656e.tar.xz
systemtap-330857f790fe94b38001367a4cf6e376f72d656e.zip
Add nfsd/nfsdacc-fullpath.stp
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r--nfsd/nfsdacc-fullpath.stp67
1 files changed, 67 insertions, 0 deletions
diff --git a/nfsd/nfsdacc-fullpath.stp b/nfsd/nfsdacc-fullpath.stp
new file mode 100644
index 0000000..c8b9382
--- /dev/null
+++ b/nfsd/nfsdacc-fullpath.stp
@@ -0,0 +1,67 @@
+#! /usr/bin/env stap
+
+# nfsd client tables
+
+
+global file_to_path_hash
+
+global nfsd_stat_read
+global nfsd_stat_write
+
+
+function nullstr:long (str:string) %{
+ THIS->__retvalue = (STAP_ARG_str[0] == '\0');
+ return;
+%}
+
+function daddr_to_string:string(daddr:long)
+%{ /* pure */
+ union { __u32 d; unsigned char addr[4]; } u;
+ u.d = STAP_ARG_daddr;
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%d.%d.%d.%d",
+ u.addr[0], u.addr[1], u.addr[2], u.addr[3]);
+%}
+
+
+probe module("nfsd").function("nfsd_vfs_read").return
+{
+ uid = $rqstp->rq_cred->cr_uid
+ if($file) {
+ if($file->f_path->dentry) {
+ path = file_to_path_hash[$file->f_path->dentry->d_inode, $file->f_path->mnt->mnt_mountpoint->d_inode]
+ if(nullstr(path)) {
+ path = sprintf("%s/%s", d_name($file->f_path->mnt->mnt_mountpoint), reverse_path_walk($file->f_path->dentry))
+ file_to_path_hash[$file->f_path->dentry->d_inode, $file->f_path->mnt->mnt_mountpoint->d_inode] = path
+ }
+ }
+ nfsd_stat_read[uid,path,addr_from_rqst($rqstp)] += $count[0]
+ }
+}
+
+probe module("nfsd").function("nfsd_vfs_write").return
+{
+ uid = $rqstp->rq_cred->cr_uid
+ if($file) {
+ if($file->f_path->dentry) {
+ path = file_to_path_hash[$file->f_path->dentry->d_inode, $file->f_path->mnt->mnt_mountpoint->d_inode]
+ if(nullstr(path)) {
+ path = sprintf("%s/%s", d_name($file->f_path->mnt->mnt_mountpoint), reverse_path_walk($file->f_path->dentry))
+ file_to_path_hash[$file->f_path->dentry->d_inode, $file->f_path->mnt->mnt_mountpoint->d_inode] = path
+ }
+ }
+ nfsd_stat_write[uid,path,addr_from_rqst($rqstp)] += $cnt[0]
+ }
+}
+
+probe timer.ms(60000)
+{
+ foreach ([uid,path,addr] in nfsd_stat_read)
+ printf("%d,read,%d,%d,%s,%s\n", gettimeofday_s(), nfsd_stat_read[uid,path,addr], uid,path,daddr_to_string(addr))
+ foreach ([uid,path,addr] in nfsd_stat_write)
+ printf("%d,write,%d,%d,%s,%s\n", gettimeofday_s(), nfsd_stat_write[uid,path,addr], uid,path,daddr_to_string(addr))
+
+ delete file_to_path_hash
+
+ delete nfsd_stat_read
+ delete nfsd_stat_write
+}