All of lore.kernel.org
 help / color / mirror / Atom feed
* NFS debugging helpers
@ 2007-06-21 20:31 Chuck Lever
  2007-06-21 20:37 ` J. Bruce Fields
  0 siblings, 1 reply; 4+ messages in thread
From: Chuck Lever @ 2007-06-21 20:31 UTC (permalink / raw)
  To: Linux NFS Mailing List

[-- Attachment #1: Type: text/plain, Size: 295 bytes --]

I thought I remembered that nfs-utils has simple programs to set NFS/RPC 
debugging flags, but I couldn't find them.

So I constructed a couple of Python scripts to remember the flag names 
and values (see attached).  They are still a little raw.

Is there anything like this already out there?

[-- Attachment #2: nfsdebug --]
[-- Type: text/plain, Size: 2965 bytes --]

#!/usr/bin/env python
# -*- python-mode -*-
"""Script to set NFS debug levels symbolically
"""

__copyright__ = """
Copyright (C) 2007, Chuck Lever <chuck.lever@oracle.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.

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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""

""" History:
Thu Jun 21 10:41:40 EDT 2007 cel - created
"""

import sys, os, time, popen2

""" From include/linux/nfs_fs.h
"""
NfsDebugFlags = {
    'vfs'         : 0x0001,
    'dircache'    : 0x0002,
    'lookupcache' : 0x0004,
    'pagecache'   : 0x0008,
    'proc'        : 0x0010,
    'xdr'         : 0x0020,
    'file'        : 0x0040,
    'root'        : 0x0080,
    'callback'    : 0x0100,
    'client'      : 0x0200,
    'mount'       : 0x0400,
}

NoNfsFlags = 0
AllNfsFlags = 0x07ff

def DoCmd(cmd):
    p = popen2.Popen3(cmd, True)
    output = p.fromchild.read()
    if p.wait():
        print '%s failed (%s)' % (str(cmd), p.childerr.read().strip())
    return output

def CurrentSetting():
    string = DoCmd("/sbin/sysctl sunrpc.nfs_debug")
    words = string.split()
    return int(words[2])

def SetNfsFlags(flags):
    cmd = '/usr/bin/sudo /sbin/sysctl -w sunrpc.nfs_debug=%d' % flags
    DoCmd(cmd)
    return

def ProcessFlag(flag):
    if flag not in NfsDebugFlags:
        print 'Unrecognized NFS debugging flag.'
        return

    current = CurrentSetting()
    SetNfsFlags(current | NfsDebugFlags[flag])

    return


#
# Main
#

if len(sys.argv) == 1:
    current = CurrentSetting()
    if current == NoNfsFlags:
        print 'NFS debugging is currently disabled.'
    elif current == AllNfsFlags:
        print 'NFS debugging is currently fully enabled.'
    else:
        print 'Current NFS debugging flags:'
        for i in NfsDebugFlags.items():
            if (current & i[1]) == i[1]:
                 print '   %s' % i[0]
    sys.exit(0)

if sys.argv[1] in [ '-h', '--help' ]:
    print 'Usage:  nfsdebug [flag name] [flag name] ...'
    print '  where flag name is one of: all, none, %s' % \
        ', '.join(NfsDebugFlags.keys())
    sys.exit(1)

for arg in sys.argv:
    if arg == sys.argv[0]:
        continue

    elif arg in [ 'all', 'on', 'true', 'yes' ]:
        SetNfsFlags(AllNfsFlags)
        print 'NFS debugging is now enabled.'

    elif arg in [ 'none', 'off', 'false', 'no', 'clear', 'zero' ]:
        SetNfsFlags(NoNfsFlags)
        print 'NFS debugging is now disabled.'

    else:
        ProcessFlag(arg)

sys.exit(0)

[-- Attachment #3: rpcdebug --]
[-- Type: text/plain, Size: 2951 bytes --]

#!/usr/bin/env python
# -*- python-mode -*-
"""Script to set RPC debug levels symbolically
"""

__copyright__ = """
Copyright (C) 2007, Chuck Lever <chuck.lever@oracle.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.

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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""

""" History:
Thu Jun 21 10:41:40 EDT 2007 cel - created
"""

import sys, os, time, popen2

""" From include/linux/sunrpc/debug.h
"""
RpcDebugFlags = {
    'xprt'    : 0x0001,
    'call'    : 0x0002,
    'debug'   : 0x0004,
    'nfs'     : 0x0008,
    'auth'    : 0x0010,
    'bind'    : 0x0020,
    'sched'   : 0x0040,
    'trans'   : 0x0080,
    'svcsock' : 0x0100,
    'svcdsp'  : 0x0200,
    'misc'    : 0x0400,
    'cache'   : 0x0800,
}

NoRpcFlags = 0
AllRpcFlags = 0x0fff

def DoCmd(cmd):
    p = popen2.Popen3(cmd, True)
    output = p.fromchild.read()
    if p.wait():
        print '%s failed (%s)' % (str(cmd), p.childerr.read().strip())
    return output

def CurrentSetting():
    string = DoCmd("/sbin/sysctl sunrpc.rpc_debug")
    words = string.split()
    return int(words[2])

def SetRpcFlags(flags):
    cmd = '/usr/bin/sudo /sbin/sysctl -w sunrpc.rpc_debug=%d' % flags
    DoCmd(cmd)
    return

def ProcessFlag(flag):
    if flag not in RpcDebugFlags:
        print 'Unrecognized RPC debugging flag.'
        return

    current = CurrentSetting()
    SetRpcFlags(current | RpcDebugFlags[flag])

    return


#
# Main
#

if len(sys.argv) == 1:
    current = CurrentSetting()
    if current == NoRpcFlags:
        print 'RPC debugging is currently disabled.'
    elif current == AllRpcFlags:
        print 'RPC debugging is currently fully enabled.'
    else:
        print 'Current RPC debugging flags:'
        for i in RpcDebugFlags.items():
            if (current & i[1]) == i[1]:
                 print '   %s' % i[0]
    sys.exit(0)

if sys.argv[1] in [ '-h', '--help' ]:
    print 'Usage:  rpcdebug [flag name] [flag name] ...'
    print '  where flag name is one of: all, none, %s' % \
        ', '.join(RpcDebugFlags.keys())
    sys.exit(1)

for arg in sys.argv:
    if arg == sys.argv[0]:
        continue

    elif arg in [ 'all', 'on', 'true', 'yes' ]:
        SetRpcFlags(AllRpcFlags)
        print 'RPC debugging is now enabled.'

    elif arg in [ 'none', 'off', 'false', 'no', 'clear', 'zero' ]:
        SetRpcFlags(NoRpcFlags)
        print 'RPC debugging is now disabled.'

    else:
        ProcessFlag(arg)

sys.exit(0)

[-- Attachment #4: chuck.lever.vcf --]
[-- Type: text/x-vcard, Size: 291 bytes --]

begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel/
version:2.1
end:vcard


[-- Attachment #5: Type: text/plain, Size: 286 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

[-- Attachment #6: Type: text/plain, Size: 140 bytes --]

_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: NFS debugging helpers
  2007-06-21 20:31 NFS debugging helpers Chuck Lever
@ 2007-06-21 20:37 ` J. Bruce Fields
  2007-06-22 16:39   ` Chuck Lever
  0 siblings, 1 reply; 4+ messages in thread
From: J. Bruce Fields @ 2007-06-21 20:37 UTC (permalink / raw)
  To: Chuck Lever; +Cc: Linux NFS Mailing List

On Thu, Jun 21, 2007 at 04:31:29PM -0400, Chuck Lever wrote:
> I thought I remembered that nfs-utils has simple programs to set NFS/RPC 
> debugging flags, but I couldn't find them.
> 
> So I constructed a couple of Python scripts to remember the flag names 
> and values (see attached).  They are still a little raw.
> 
> Is there anything like this already out there?

Try

	man rpcdebug

It comes from nfs-utils/tools/rpcdebug/.

--b.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: NFS debugging helpers
  2007-06-21 20:37 ` J. Bruce Fields
@ 2007-06-22 16:39   ` Chuck Lever
  2007-06-22 18:12     ` J. Bruce Fields
  0 siblings, 1 reply; 4+ messages in thread
From: Chuck Lever @ 2007-06-22 16:39 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: Linux NFS Mailing List

[-- Attachment #1: Type: text/plain, Size: 629 bytes --]

J. Bruce Fields wrote:
> On Thu, Jun 21, 2007 at 04:31:29PM -0400, Chuck Lever wrote:
>> I thought I remembered that nfs-utils has simple programs to set NFS/RPC 
>> debugging flags, but I couldn't find them.
>>
>> So I constructed a couple of Python scripts to remember the flag names 
>> and values (see attached).  They are still a little raw.
>>
>> Is there anything like this already out there?
> 
> Try
> 
> 	man rpcdebug
> 
> It comes from nfs-utils/tools/rpcdebug/.

Ja, that's what I remembered.

Not necessarily to Bruce:  Is it actively maintained?  If a new 
debugging flag is added, is this tool updated by someone?

[-- Attachment #2: chuck.lever.vcf --]
[-- Type: text/x-vcard, Size: 291 bytes --]

begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel/
version:2.1
end:vcard


[-- Attachment #3: Type: text/plain, Size: 286 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

[-- Attachment #4: Type: text/plain, Size: 140 bytes --]

_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: NFS debugging helpers
  2007-06-22 16:39   ` Chuck Lever
@ 2007-06-22 18:12     ` J. Bruce Fields
  0 siblings, 0 replies; 4+ messages in thread
From: J. Bruce Fields @ 2007-06-22 18:12 UTC (permalink / raw)
  To: Chuck Lever; +Cc: Linux NFS Mailing List

On Fri, Jun 22, 2007 at 12:39:57PM -0400, Chuck Lever wrote:
> J. Bruce Fields wrote:
> >On Thu, Jun 21, 2007 at 04:31:29PM -0400, Chuck Lever wrote:
> >>I thought I remembered that nfs-utils has simple programs to set NFS/RPC 
> >>debugging flags, but I couldn't find them.
> >>
> >>So I constructed a couple of Python scripts to remember the flag names 
> >>and values (see attached).  They are still a little raw.
> >>
> >>Is there anything like this already out there?
> >
> >Try
> >
> >	man rpcdebug
> >
> >It comes from nfs-utils/tools/rpcdebug/.
> 
> Ja, that's what I remembered.
> 
> Not necessarily to Bruce:  Is it actively maintained?  If a new 
> debugging flag is added, is this tool updated by someone?

Sounds like a volunteer!

git hsows the last update (to update some flags, add the manpage, and
install everything) as being by Greg Banks last in July 2006.

I have to admit, just now I needed to turn on some dprintk's, and did it
by looking up the #define by hand.  I forgot about rpcdebug even after
having talked about it just yesterday....

--b.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-06-22 18:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-21 20:31 NFS debugging helpers Chuck Lever
2007-06-21 20:37 ` J. Bruce Fields
2007-06-22 16:39   ` Chuck Lever
2007-06-22 18:12     ` J. Bruce Fields

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.