function svcprog:string(_prog:long) %{ static struct { int prog; char *string; } svc_progtbl[] = { {100000, "rpcbind"}, {100024, "statd"}, {100011, "rquotad"}, {100003, "nfsd"}, {100021, "nlockmgr"}, {100005, "mountd"}, {100227, "nfs_acl"}, }; int i; int tabsz = (sizeof(svc_progtbl)/sizeof(svc_progtbl[0])); for (i = 0; i < tabsz; i++) { if (svc_progtbl[i].prog == THIS->_prog) { break; } } if (i == tabsz) snprintf(THIS->__retvalue, MAXSTRINGLEN, "%lld", THIS->_prog); else snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", svc_progtbl[i].string); %} function svcerror:string(err:long) %{ static struct { int svcerr; char *string; } svc_errtbl[] = { {1, "SVC_GARBAGE" }, {2, "SVC_SYSERR" }, {3, "SVC_VALID" }, {4, "SVC_NEGATIVE" }, {5, "SVC_OK" }, {6, "SVC_DROP" }, {7, "SVC_DENIED" }, {8, "SVC_PENDING" }, {9, "SVC_COMPLETE" }, }; int i; int tabsz = (sizeof(svc_errtbl)/sizeof(svc_errtbl[0])); for (i = 0; i < tabsz; i++) { if (svc_errtbl[i].svcerr == THIS->err) { break; } } if (i == tabsz) snprintf(THIS->__retvalue, MAXSTRINGLEN, "svcerr %lld", THIS->err); else snprintf(THIS->__retvalue, MAXSTRINGLEN, "svcderr %d(%s)", svc_errtbl[i].svcerr, svc_errtbl[i].string); %} global rq_prog, rq_vers, rq_proc, rq_prot global show_all probe module("sunrpc").function("svc_process") { rq_prot = $rqstp->rq_prot rq_proc = $rqstp->rq_proc rq_vers = $rqstp->rq_vers rq_prog = $rqstp->rq_prog } probe module("sunrpc").function("svc_process").return { if ($return == 0) { printf("%s(%d): %s[%d]:%d: return %d (%s)\n", execname(), pid(), svcprog(rq_prog), rq_vers, rq_proc, $return, errno_str($return)); } else if (show_all && $return != 0) { if (rq_vers == 4) { printf("%s(%d): %s[%d]:%d: bytes %d\n", execname(), pid(), svcprog(rq_prog), rq_vers, rq_proc, $return); } else { printf("%s(%d): %s[%d]:%d: bytes %d\n", execname(), pid(), svcprog(rq_prog), rq_vers, rq_proc, $return); } } } probe module("sunrpc").function("svc_authenticate") { if (show_all) { printf("svc_authenticate: rqstp %p authp %p\n", $rqstp, $authp); } } probe module("sunrpc").function("svc_authenticate").return { if (show_all) { printf("svc_authenticate: return %s\n", svcerror($return)); } else if ($return != 5) { printf("svc_authenticate: return %s\n", svcerror($return)); } } probe module("sunrpc").function("svc_recv") { if (show_all) { printf("svc_recv: rqstp %p timeout %d\n", $rqstp, $timeout); } } probe module("sunrpc").function("svc_recv").return { if (show_all) { if ($return >= 0) { printf("svc_recv: bytes %d\n", $return); } else { printf("svc_recv: return %d (%s)\n", $return, errno_str($return)); } } else if ($return < 0 && $return != -11) { printf("svc_recv: return %d (%s)\n", $return, errno_str($return)); } } probe begin { show_all = 0; if (argc > 0) { if (isinstr(argv[1], "--show_all")) { show_all = 1 } else { error("Usage: sunrpc -- --show_all"); } } log("starting sunrpc-svc probe") } probe end { log("ending sunrpc-svc probe") }