Add a tool for using the new sysfs files
Subsystems (2)
v4 cover Add a tool for using the new sysfs files
From: Anna Schumaker <[email protected]>
These patches implement a tool that can be used to read and write the sysfs files, with subcommands!
The following subcommands are implemented:
rpcsys rpc-client
rpcsys xprt
rpcsys xprt set
rpcsys xprt-switch
rpcsys xprt-switch set
So you can print out information about every xprt-switch with:
anna@client ~ % rpcsys xprt-switch
switch 0: num_xprts 1, num_active 1, queue_len 0
xprt 0: local, /var/run/gssproxy.sock [main]
switch 1: num_xprts 1, num_active 1, queue_len 0
xprt 1: local, /var/run/rpcbind.sock [main]
switch 2: num_xprts 1, num_active 1, queue_len 0
xprt 2: tcp, 192.168.111.1 [main]
switch 3: num_xprts 4, num_active 4, queue_len 0
xprt 3: tcp, 192.168.111.188 [main] xprt 4: tcp, 192.168.111.188
xprt 5: tcp, 192.168.111.188
xprt 6: tcp, 192.168.111.188
And information about each xprt:
anna@client ~ % rpcsys xprt xprt 0: local, /var/run/gssproxy.sock, port 0, state <MAIN,CONNECTED,BOUND> Source: (einval), port 0, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 1: local, /var/run/rpcbind.sock, port 0, state <MAIN,CONNECTED,BOUND> Source: (einval), port 0, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 2: tcp, 192.168.111.1, port 2049, state <MAIN,CONNECTED,BOUND> Source: 192.168.111.222, port 959, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 3: tcp, 192.168.111.188, port 2049, state <MAIN,CONNECTED,BOUND> Source: 192.168.111.222, port 921, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 4: tcp, 192.168.111.188, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 726, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 5: tcp, 192.168.111.188, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 671, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 6: tcp, 192.168.111.188, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 934, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0
You can use the set subcommand to change the dstaddr of individual xprts:
anna@client ~ % sudo rpcsys xprt --id 4 xprt 4: tcp, 192.168.111.188, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 726, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 anna@client ~ % sudo rpcsys xprt set --id 4 --dstaddr server2.nowheycreamery.com xprt 4: tcp, 192.168.111.186, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 726, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0
Or for changing the dstaddr of all xprts attached to a switch:
anna@client % rpcsys xprt-switch --id 3 switch 3: num_xprts 4, num_active 4, queue_len 0 xprt 3: tcp, 192.168.111.188 [main] xprt 4: tcp, 192.168.111.188 xprt 5: tcp, 192.168.111.188 xprt 6: tcp, 192.168.111.188 anna@client % sudo rpcsys xprt-switch set --id 4 --dstaddr server2.nowheycreamery.vm switch 3: num_xprts 4, num_active 4, queue_len 0 xprt 2: tcp, 192.168.111.186 [main] xprt 3: tcp, 192.168.111.186 xprt 5: tcp, 192.168.111.186 xprt 6: tcp, 192.168.111.186
I renamed the tool to "rpcsys" after the discussion at the bakeathon. I think this is at least a better name, but if anybody has other ideas please let me know!
Thoughts?
Anna
Anna Schumaker (9):
rpcsys: Add a rpcsys.py tool
rpcsys: Add a command for printing xprt switch information
rpcsys: Add a command for printing individual xprts
rpcsys: Add a command for printing rpc-client information
rpcsys: Add a command for changing xprt dstaddr
rpcsys: Add a command for changing xprt-switch dstaddrs
rpcsys: Add a command for changing xprt state
rpcsys: Add a man page
rpcsys: Add installation to the Makefile
.gitignore | 2 + configure.ac | 1 + tools/Makefile.am | 2 +- tools/rpcsys/Makefile.am | 20 ++++++++ tools/rpcsys/client.py | 27 +++++++++++ tools/rpcsys/rpcsys | 5 ++ tools/rpcsys/rpcsys.man | 88 ++++++++++++++++++++++++++++++++++ tools/rpcsys/rpcsys.py | 23 +++++++++ tools/rpcsys/switch.py | 51 ++++++++++++++++++++ tools/rpcsys/sysfs.py | 29 +++++++++++ tools/rpcsys/xprt.py | 101 +++++++++++++++++++++++++++++++++++++++ 11 files changed, 348 insertions(+), 1 deletion(-) create mode 100644 tools/rpcsys/Makefile.am create mode 100644 tools/rpcsys/client.py create mode 100644 tools/rpcsys/rpcsys create mode 100644 tools/rpcsys/rpcsys.man create mode 100755 tools/rpcsys/rpcsys.py create mode 100644 tools/rpcsys/switch.py create mode 100644 tools/rpcsys/sysfs.py create mode 100644 tools/rpcsys/xprt.py
Signature · 1 line
2.33.1
PATCH v4 1/9 rpcsys: Add a rpcsys.py tool
From: Anna Schumaker <[email protected]>
This will be used to print and manipulate the sunrpc sysfs directory files. Running without arguments prints both usage information and the location of the sunrpc sysfs directory.
--- .gitignore | 2 ++ tools/rpcsys/rpcsys.py | 13 +++++++++++++ tools/rpcsys/sysfs.py | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100755 tools/rpcsys/rpcsys.py create mode 100644 tools/rpcsys/sysfs.py
.gitignore +2 -0
@@ -84,3 +84,5 @@ systemd/rpc-gssd.service cscope.* # generic editor backup et al *~ +# python bytecode +__pycache__
tools/rpcsys/rpcsys.py new file +13 -0
@@ -0,0 +1,13 @@ +#!/usr/bin/python +import argparse +import sysfs + +parser = argparse.ArgumentParser() + +def show_small_help(args): + parser.print_usage() + print("sunrpc dir:", sysfs.SUNRPC) +parser.set_defaults(func=show_small_help) + +args = parser.parse_args() +args.func(args)
tools/rpcsys/sysfs.py new file +19 -0
@@ -0,0 +1,19 @@ +import pathlib +import re +import sys + +MOUNT = None +with open("/proc/mounts", 'r') as f: + for line in f: + if re.search("^sys ", line): + MOUNT = line.split()[1] + break + +if MOUNT == None: + print("ERROR: sysfs is not mounted") + sys.exit(1) + +SUNRPC = pathlib.Path(MOUNT) / "kernel" / "sunrpc" +if not SUNRPC.is_dir(): + print("ERROR: sysfs does not have sunrpc directory") + sys.exit(1)
Signature · 1 line
2.33.1
PATCH v4 2/9 rpcsys: Add a command for printing xprt switch information
In reply to [email protected]From: Anna Schumaker <[email protected]>
This combines the information found in xprt_switch_info with a subset of the information found in each xprt subdirectory
--- tools/rpcsys/rpcsys.py | 6 ++++++ tools/rpcsys/switch.py | 35 +++++++++++++++++++++++++++++++++++ tools/rpcsys/sysfs.py | 10 ++++++++++ tools/rpcsys/xprt.py | 12 ++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 tools/rpcsys/switch.py create mode 100644 tools/rpcsys/xprt.py
tools/rpcsys/rpcsys.py +6 -0
@@ -9,5 +9,11 @@ def show_small_help(args): print("sunrpc dir:", sysfs.SUNRPC) parser.set_defaults(func=show_small_help) + +import switch +subparser = parser.add_subparsers(title="commands") +switch.add_command(subparser) + + args = parser.parse_args() args.func(args)
tools/rpcsys/switch.py new file +35 -0
@@ -0,0 +1,35 @@ +import sysfs +import xprt + +class XprtSwitch: + def __init__(self, path): + self.path = path + self.id = int(str(path).rsplit("-", 1)[1]) + + self.xprts = [ xprt.Xprt(p) for p in self.path.iterdir() if p.is_dir() ] + self.xprts.sort() + + self.__dict__.update(sysfs.read_info_file(path / "xprt_switch_info")) + + def __lt__(self, rhs): + return self.path < rhs.path + + def __str__(self): + line = "switch %s: num_xprts %s, num_active %s, queue_len %s" % \ + (self.id, self.num_xprts, self.num_active, self.queue_len) + for x in self.xprts: + line += "\n %s" % x.small_str() + return line + + +def list_xprt_switches(args): + switches = [ XprtSwitch(f) for f in (sysfs.SUNRPC / "xprt-switches").iterdir() ] + switches.sort() + for xs in switches: + if args.id == None or xs.id == args.id[0]: + print(xs) + +def add_command(subparser): + parser = subparser.add_parser("xprt-switch", help="Commands for xprt switches") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt-switch to show") + parser.set_defaults(func=list_xprt_switches)
tools/rpcsys/sysfs.py +10 -0
@@ -17,3 +17,13 @@ SUNRPC = pathlib.Path(MOUNT) / "kernel" / "sunrpc" if not SUNRPC.is_dir(): print("ERROR: sysfs does not have sunrpc directory") sys.exit(1) + + +def read_info_file(path): + res = dict() + with open(path) as info: + for line in info: + if "=" in line: + (key, val) = line.strip().split("=") + res[key] = int(val) + return res
tools/rpcsys/xprt.py new file +12 -0
@@ -0,0 +1,12 @@ +class Xprt: + def __init__(self, path): + self.path = path + self.id = int(str(path).rsplit("-", 2)[1]) + self.type = str(path).rsplit("-", 2)[2] + self.dstaddr = open(path / "dstaddr", 'r').readline().strip() + + def __lt__(self, rhs): + return self.id < rhs.id + + def small_str(self): + return "xprt %s: %s, %s" % (self.id, self.type, self.dstaddr)
Signature · 1 line
2.33.1
PATCH v4 3/9 rpcsys: Add a command for printing individual xprts
In reply to [email protected]From: Anna Schumaker <[email protected]>
This shows more detailed information than what is presented with xprt switches. I take the chance to add a main-export indicator to the small_str() used when printing out xprt-switches.
--- tools/rpcsys/rpcsys.py | 2 ++ tools/rpcsys/xprt.py | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-)
tools/rpcsys/rpcsys.py +2 -0
@@ -11,8 +11,10 @@ parser.set_defaults(func=show_small_help) import switch +import xprt subparser = parser.add_subparsers(title="commands") switch.add_command(subparser) +xprt.add_command(subparser) args = parser.parse_args()
tools/rpcsys/xprt.py +37 -1
@@ -1,12 +1,48 @@ +import sysfs + class Xprt: def __init__(self, path): self.path = path self.id = int(str(path).rsplit("-", 2)[1]) self.type = str(path).rsplit("-", 2)[2] self.dstaddr = open(path / "dstaddr", 'r').readline().strip() + self.srcaddr = open(path / "srcaddr", 'r').readline().strip() + + with open(path / "xprt_state") as f: + self.state = ','.join(f.readline().split()[1:]) + self.__dict__.update(sysfs.read_info_file(path / "xprt_info")) def __lt__(self, rhs): return self.id < rhs.id + def __str__(self): + state = self.state + if self.main_xprt: + state = "MAIN," + self.state + + line = "xprt %s: %s, %s, port %s, state <%s>" % \ + (self.id, self.type, self.dstaddr, self.dst_port, state) + line += "\n Source: %s, port %s, Requests: %s" % \ + (self.srcaddr, self.src_port, self.num_reqs) + line += "\n Congestion: cur %s, win %s, Slots: min %s, max %s" % \ + (self.cur_cong, self.cong_win, self.min_num_slots, self.max_num_slots) + line += "\n Queues: binding %s, sending %s, pending %s, backlog %s, tasks %s" % \ + (self.binding_q_len, self.sending_q_len, self.pending_q_len, self.backlog_q_len, self.tasks_queuelen) + return line + def small_str(self): - return "xprt %s: %s, %s" % (self.id, self.type, self.dstaddr) + return "xprt %s: %s, %s%s" % (self.id, self.type, self.dstaddr, + f" [main]" if self.main_xprt else "" ) + + +def list_xprts(args): + xprts = [ Xprt(f) for f in (sysfs.SUNRPC / "xprt-switches").glob("**/xprt-*") ] + xprts.sort() + for xprt in xprts: + if args.id == None or xprt.id == args.id[0]: + print(xprt) + +def add_command(subparser): + parser = subparser.add_parser("xprt", help="Commands for individual xprts") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt to show") + parser.set_defaults(func=list_xprts)
Signature · 1 line
2.33.1
PATCH v4 4/9 rpcsys: Add a command for printing rpc-client information
In reply to [email protected]From: Anna Schumaker <[email protected]>
It's mostly the same information as with xprt-switches, except with rpc-client id prepended to the first line.
--- tools/rpcsys/client.py | 27 +++++++++++++++++++++++++++ tools/rpcsys/rpcsys.py | 2 ++ tools/rpcsys/switch.py | 7 ++++--- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 tools/rpcsys/client.py
tools/rpcsys/client.py new file +27 -0
@@ -0,0 +1,27 @@ +import sysfs +import switch + +class RpcClient: + def __init__(self, path): + self.path = path + self.id = int(str(path).rsplit("-", 1)[1]) + self.switch = switch.XprtSwitch(path / (path / "switch").readlink(), sep=",") + + def __lt__(self, rhs): + return self.id < rhs.id + + def __str__(self): + return "client %s: %s" % (self.id, self.switch) + + +def list_rpc_clients(args): + clients = [ RpcClient(f) for f in (sysfs.SUNRPC / "rpc-clients").iterdir() ] + clients.sort() + for client in clients: + if args.id == None or client.id == args.id[0]: + print(client) + +def add_command(subparser): + parser = subparser.add_parser("rpc-client", help="Commands for rpc clients") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific client to show") + parser.set_defaults(func=list_rpc_clients)
tools/rpcsys/rpcsys.py +2 -0
@@ -10,9 +10,11 @@ def show_small_help(args): parser.set_defaults(func=show_small_help) +import client import switch import xprt subparser = parser.add_subparsers(title="commands") +client.add_command(subparser) switch.add_command(subparser) xprt.add_command(subparser)
tools/rpcsys/switch.py +4 -3
@@ -2,9 +2,10 @@ import sysfs import xprt class XprtSwitch: - def __init__(self, path): + def __init__(self, path, sep=":"): self.path = path self.id = int(str(path).rsplit("-", 1)[1]) + self.sep = sep self.xprts = [ xprt.Xprt(p) for p in self.path.iterdir() if p.is_dir() ] self.xprts.sort()
@@ -15,8 +16,8 @@ class XprtSwitch: return self.path < rhs.path def __str__(self): - line = "switch %s: num_xprts %s, num_active %s, queue_len %s" % \ - (self.id, self.num_xprts, self.num_active, self.queue_len) + line = "switch %s%s num_xprts %s, num_active %s, queue_len %s" % \ + (self.id, self.sep, self.num_xprts, self.num_active, self.queue_len) for x in self.xprts: line += "\n %s" % x.small_str() return line
Signature · 1 line
2.33.1
PATCH v4 5/9 rpcsys: Add a command for changing xprt dstaddr
In reply to [email protected]From: Anna Schumaker <[email protected]>
Using the socket module for dns resolution
--- tools/rpcsys/xprt.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
tools/rpcsys/xprt.py +28 -0
@@ -1,3 +1,4 @@ +import socket import sysfs class Xprt:
@@ -34,6 +35,12 @@ class Xprt: return "xprt %s: %s, %s%s" % (self.id, self.type, self.dstaddr, f" [main]" if self.main_xprt else "" ) + def set_dstaddr(self, newaddr): + resolved = socket.gethostbyname(newaddr) + with open(self.path / "dstaddr", 'w') as f: + f.write(resolved) + self.dstaddr = open(self.path / "dstaddr", 'r').readline().strip() + def list_xprts(args): xprts = [ Xprt(f) for f in (sysfs.SUNRPC / "xprt-switches").glob("**/xprt-*") ]
@@ -42,7 +49,28 @@ def list_xprts(args): if args.id == None or xprt.id == args.id[0]: print(xprt) +def get_xprt(id): + xprts = [ Xprt(f) for f in (sysfs.SUNRPC / "xprt-switches").glob("**/xprt-*") ] + for xprt in xprts: + if xprt.id == id: + return xprt + +def set_xprt_property(args): + xprt = get_xprt(args.id[0]) + try: + if args.dstaddr != None: + xprt.set_dstaddr(args.dstaddr[0]) + print(xprt) + except Exception as e: + print(e) + def add_command(subparser): parser = subparser.add_parser("xprt", help="Commands for individual xprts") parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt to show") parser.set_defaults(func=list_xprts) + + subparser = parser.add_subparsers() + parser = subparser.add_parser("set", help="Set an xprt property") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, required=True, help="Id of a specific xprt to modify") + parser.add_argument("--dstaddr", metavar="dstaddr", nargs=1, type=str, help="New dstaddr to set") + parser.set_defaults(func=set_xprt_property)
Signature · 1 line
2.33.1
PATCH v4 6/9 rpcsys: Add a command for changing xprt-switch dstaddrs
In reply to [email protected]From: Anna Schumaker <[email protected]>
This is basically the same as for xprts, but it iterates through all xprts attached to the switch to apply the new address.
--- tools/rpcsys/switch.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
tools/rpcsys/switch.py +15 -0
@@ -30,7 +30,22 @@ def list_xprt_switches(args): if args.id == None or xs.id == args.id[0]: print(xs) +def set_xprt_switch_property(args): + switch = XprtSwitch(sysfs.SUNRPC / "xprt-switches" / f"switch-{args.id[0]}") + try: + for xprt in switch.xprts: + xprt.set_dstaddr(args.dstaddr[0]) + print(switch) + except Exception as e: + print(e) + def add_command(subparser): parser = subparser.add_parser("xprt-switch", help="Commands for xprt switches") parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt-switch to show") parser.set_defaults(func=list_xprt_switches) + + subparser = parser.add_subparsers() + parser = subparser.add_parser("set", help="Set an xprt switch property") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, required=True, help="Id of an xprt-switch to modify") + parser.add_argument("--dstaddr", metavar="dstaddr", nargs=1, type=str, help="New dstaddr to set") + parser.set_defaults(func=set_xprt_switch_property)
Signature · 1 line
2.33.1
PATCH v4 7/9 rpcsys: Add a command for changing xprt state
In reply to [email protected]From: Anna Schumaker <[email protected]>
We can set it offline or online, or we can remove an xprt. The kernel only supports removing offlined transports, so we make sure to set the state to "offline" before sending the remove command.
--- tools/rpcsys/xprt.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)
tools/rpcsys/xprt.py +27 -2
@@ -8,15 +8,18 @@ class Xprt: self.type = str(path).rsplit("-", 2)[2] self.dstaddr = open(path / "dstaddr", 'r').readline().strip() self.srcaddr = open(path / "srcaddr", 'r').readline().strip() + self.exists = True - with open(path / "xprt_state") as f: - self.state = ','.join(f.readline().split()[1:]) + self.read_state() self.__dict__.update(sysfs.read_info_file(path / "xprt_info")) def __lt__(self, rhs): return self.id < rhs.id def __str__(self): + if not self.exists: + return "xprt %s: has been removed" % self.id + state = self.state if self.main_xprt: state = "MAIN," + self.state
@@ -31,6 +34,13 @@ class Xprt: (self.binding_q_len, self.sending_q_len, self.pending_q_len, self.backlog_q_len, self.tasks_queuelen) return line + def read_state(self): + if not self.path.exists(): + self.exists = False + return + with open(self.path / "xprt_state") as f: + self.state = ','.join(f.readline().split()[1:]) + def small_str(self): return "xprt %s: %s, %s%s" % (self.id, self.type, self.dstaddr, f" [main]" if self.main_xprt else "" )
@@ -41,6 +51,11 @@ class Xprt: f.write(resolved) self.dstaddr = open(self.path / "dstaddr", 'r').readline().strip() + def set_state(self, state): + with open(self.path / "xprt_state", 'w') as f: + f.write(state) + self.read_state() + def list_xprts(args): xprts = [ Xprt(f) for f in (sysfs.SUNRPC / "xprt-switches").glob("**/xprt-*") ]
@@ -60,6 +75,13 @@ def set_xprt_property(args): try: if args.dstaddr != None: xprt.set_dstaddr(args.dstaddr[0]) + if args.offline: + xprt.set_state("offline") + elif args.online: + xprt.set_state("online") + elif args.remove: + xprt.set_state("offline") + xprt.set_state("remove") print(xprt) except Exception as e: print(e)
@@ -73,4 +95,7 @@ def add_command(subparser): parser = subparser.add_parser("set", help="Set an xprt property") parser.add_argument("--id", metavar="ID", nargs=1, type=int, required=True, help="Id of a specific xprt to modify") parser.add_argument("--dstaddr", metavar="dstaddr", nargs=1, type=str, help="New dstaddr to set") + parser.add_argument("--offline", action="store_true", help="Set an xprt offline") + parser.add_argument("--online", action="store_true", help="Set an offline xprt back online") + parser.add_argument("--remove", action="store_true", help="Remove an xprt") parser.set_defaults(func=set_xprt_property)
Signature · 1 line
2.33.1
PATCH v4 8/9 rpcsys: Add a man page
In reply to [email protected]From: Anna Schumaker <[email protected]>
--- tools/rpcsys/rpcsys.man | 88 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 tools/rpcsys/rpcsys.man
tools/rpcsys/rpcsys.man new file +88 -0
@@ -0,0 +1,88 @@ +.\" +.\" rpcsys(8) +.\" +.TH rpcsys 8 "22 Oct 2021" +.SH NAME +rpcsys \- Displays SunRPC connection information +.SH SYNOPSIS +.B rpcsys +.RB [ \-h | \-\-help ] +.P +.B rpcsys rpc-client +.RB [ \-h | \-\-help ] +.RB [ \--id +.IR ID ] +.P +.B rpcsys xprt-switch +.RB [ \-h | \-\-help ] +.RB [ \--id +.IR ID ] +.P +.B rpcsys xprt-switch set +.RB [ \-h | \-\-help ] +.RB [ \--id +.IR ID ] +.RB [ \--dstaddr +.IR dstaddr] +.P +.B rpcsys xprt +.RB [ \-h | \-\-help ] +.RB [ \--id +.IR ID ] +.P +.B rpcsys xprt set +.RB [ \-h | \-\-help ] +.RB [ \--id +.IR ID ] +.RB [ \--dstaddr +.IR dstaddr] +.RB [ --offline ] +.RB [ --online ] +.RB [ --remove ] +.P +.SH DESCRIPTION +.RB "The " rpcsys " command displays information collected in the SunRPC sysfs files about the system's SunRPC objects. +.P +.SS Objects +Valid +.BR rpcsys (8) +objects are: +.IP "\fBrpc-client\fP" +Display information about this system's RPC clients. +.IP "\fBxprt-switch\fP" +Display information about groups of transports. +.IP "\fBxprt\fP" +Display detailed information about each transport that exists on the system. +.SH OPTIONS +.SS Options valid for all objects +.TP +.B \-h, \-\-help +Show the help message and exit +.TP +.B \-\-id \fIID +Set or display properties for the object with the given +.IR ID. +This option is mandatory for setting properties. +.SS Options specific to the `xprt-switch set` sub-command +.TP +.B \-\-dstaddr \fIdstaddr +Change the destination address of all transports in the xprt-switch to +.IR dstaddr +.SS Options specific to the `xprt set` sub-command +.TP +.B \-\-dstaddr \fIdstaddr +Change the destination address of this specific transport to +.TP +.B \-\-offline +Change the transport state from online to offline +.TP +.B \-\-online +Change the transport state from offline to online +.TP +.B \-\-remove +Removes the transport from the xprt-switch. Note that "main" transports cannot be removed. +.SH DIRECTORY +.TP +.B /sys/kernel/sunrpc/ +.SH AUTHOR +Anna Schumaker <[email protected]>
Signature · 1 line
2.33.1
PATCH v4 9/9 rpcsys: Add installation to the Makefile
In reply to [email protected]From: Anna Schumaker <[email protected]>
And create a shell script that launches the python program from the $(libdir)
--- configure.ac | 1 + tools/Makefile.am | 2 +- tools/rpcsys/Makefile.am | 20 ++++++++++++++++++++ tools/rpcsys/rpcsys | 5 +++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tools/rpcsys/Makefile.am create mode 100644 tools/rpcsys/rpcsys
configure.ac +1 -0
@@ -731,6 +731,7 @@ AC_CONFIG_FILES([ tools/rpcgen/Makefile tools/mountstats/Makefile tools/nfs-iostat/Makefile + tools/rpcsys/Makefile tools/nfsdclnts/Makefile tools/nfsconf/Makefile tools/nfsdclddb/Makefile
tools/Makefile.am +1 -1
@@ -12,6 +12,6 @@ if CONFIG_NFSDCLD OPTDIRS += nfsdclddb endif -SUBDIRS = locktest rpcdebug nlmtest mountstats nfs-iostat nfsdclnts $(OPTDIRS) +SUBDIRS = locktest rpcdebug nlmtest mountstats nfs-iostat rpcsys nfsdclnts $(OPTDIRS) MAINTAINERCLEANFILES = Makefile.in
tools/rpcsys/Makefile.am new file +20 -0
@@ -0,0 +1,20 @@ +## Process this file with automake to produce Makefile.in +PYTHON_FILES = rpcsys.py client.py switch.py sysfs.py xprt.py +tooldir = $(DESTDIR)$(libdir)/rpcsys + +man8_MANS = rpcsys.man + +all-local: $(PYTHON_FILES) + +install-data-hook: + mkdir -p $(tooldir) + for f in $(PYTHON_FILES) ; do \ + $(INSTALL) -m 644 $$f $(tooldir)/$$f ; \ + done + chmod +x $(tooldir)/rpcsys.py + $(INSTALL) -m 755 rpcsys $(DESTDIR)$(sbindir)/rpcsys + sed -i "s|LIBDIR=.|LIBDIR=$(tooldir)|" $(DESTDIR)$(sbindir)/rpcsys + + + +MAINTAINERCLEANFILES=Makefile.in
tools/rpcsys/rpcsys new file +5 -0
@@ -0,0 +1,5 @@ +#!/bin/bash +LIBDIR=. +PYTHON3=/usr/bin/python + +exec $PYTHON3 $LIBDIR/rpcsys.py $*
Signature · 1 line
2.33.1
Quoted 88 lines · On Oct 22, 2021, at 4:55 PM, [email protected] wrote:
From: Anna Schumaker <[email protected]>
These patches implement a tool that can be used to read and write the sysfs files, with subcommands!
The following subcommands are implemented:
rpcsys rpc-client
rpcsys xprt
rpcsys xprt set
rpcsys xprt-switch
rpcsys xprt-switch setSo you can print out information about every xprt-switch with:
anna@client ~ % rpcsys xprt-switch
switch 0:num_xprts1,num_active1,queue_len0
xprt 0: local,/var/run/gssproxy.sock[main]
switch 1:num_xprts1,num_active1,queue_len0
xprt 1: local,/var/run/rpcbind.sock[main]
switch 2:num_xprts1,num_active1,queue_len0
xprt 2: tcp, 192.168.111.1 [main]
switch 3:num_xprts4,num_active4,queue_len0
xprt 3: tcp, 192.168.111.188 [main] xprt 4: tcp, 192.168.111.188
xprt 5: tcp, 192.168.111.188
xprt 6: tcp, 192.168.111.188And information about each xprt:
anna@client ~ % rpcsys xprt xprt 0: local, /var/run/gssproxy.sock, port 0, state <MAIN,CONNECTED,BOUND> Source: (einval), port 0, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 1: local, /var/run/rpcbind.sock, port 0, state <MAIN,CONNECTED,BOUND> Source: (einval), port 0, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 2: tcp, 192.168.111.1, port 2049, state <MAIN,CONNECTED,BOUND> Source: 192.168.111.222, port 959, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 3: tcp, 192.168.111.188, port 2049, state <MAIN,CONNECTED,BOUND> Source: 192.168.111.222, port 921, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 4: tcp, 192.168.111.188, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 726, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 5: tcp, 192.168.111.188, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 671, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 6: tcp, 192.168.111.188, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 934, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0You can use the
setsubcommand to change the dstaddr of individual xprts:anna@client ~ % sudo rpcsys xprt --id 4 xprt 4: tcp, 192.168.111.188, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 726, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 anna@client ~ % sudo rpcsys xprt set --id 4 --dstaddr server2.nowheycreamery.com xprt 4: tcp, 192.168.111.186, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 726, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0Or for changing the dstaddr of all xprts attached to a switch:
anna@client % rpcsys xprt-switch --id 3 switch 3: num_xprts 4, num_active 4, queue_len 0 xprt 3: tcp, 192.168.111.188 [main] xprt 4: tcp, 192.168.111.188 xprt 5: tcp, 192.168.111.188 xprt 6: tcp, 192.168.111.188 anna@client % sudo rpcsys xprt-switch set --id 4 --dstaddr server2.nowheycreamery.vm switch 3: num_xprts 4, num_active 4, queue_len 0 xprt 2: tcp, 192.168.111.186 [main] xprt 3: tcp, 192.168.111.186 xprt 5: tcp, 192.168.111.186 xprt 6: tcp, 192.168.111.186
Quoted 5 lines
I renamed the tool to "rpcsys" after the discussion at the bakeathon. I think this is at least a better name, but if anybody has other ideas please let me know!
Thoughts?
Anna, very nice!
How about naming it "rpcctl" to follow the pattern of:
systemctl
resolvectl
hostnamectl
Quoted 25 lines
Anna
Anna Schumaker (9):
rpcsys: Add arpcsys.pytool
rpcsys: Add a command for printing xprt switch information
rpcsys: Add a command for printing individual xprts
rpcsys: Add a command for printing rpc-client information
rpcsys: Add a command for changing xprt dstaddr
rpcsys: Add a command for changing xprt-switch dstaddrs
rpcsys: Add a command for changing xprt state
rpcsys: Add a man page
rpcsys: Add installation to theMakefile.gitignore | 2 + configure.ac | 1 + tools/Makefile.am | 2 +- tools/rpcsys/Makefile.am | 20 ++++++++ tools/rpcsys/client.py | 27 +++++++++++ tools/rpcsys/rpcsys | 5 ++ tools/rpcsys/rpcsys.man | 88 ++++++++++++++++++++++++++++++++++ tools/rpcsys/rpcsys.py | 23 +++++++++ tools/rpcsys/switch.py | 51 ++++++++++++++++++++ tools/rpcsys/sysfs.py | 29 +++++++++++ tools/rpcsys/xprt.py | 101 +++++++++++++++++++++++++++++++++++++++ 11 files changed, 348 insertions(+), 1 deletion(-)
Quoted 12 lines
create mode 100644
tools/rpcsys/Makefile.am
create mode 100644tools/rpcsys/client.py
create mode 100644tools/rpcsys/rpcsys
create mode 100644tools/rpcsys/rpcsys.man
create mode 100755tools/rpcsys/rpcsys.py
create mode 100644tools/rpcsys/switch.py
create mode 100644tools/rpcsys/sysfs.py
create mode 100644tools/rpcsys/xprt.pySignature · 1 line
2.33.1
--
Chuck Lever
Quoted 93 lines · Chuck Lever III
Quoted 93 lines · On Oct 22, 2021, at 4:55 PM, [email protected] wrote:
From: Anna Schumaker <[email protected]>
These patches implement a tool that can be used to read and write the sysfs files, with subcommands!
The following subcommands are implemented:
rpcsys rpc-client
rpcsys xprt
rpcsys xprt set
rpcsys xprt-switch
rpcsys xprt-switch setSo you can print out information about every xprt-switch with:
anna@client ~ % rpcsys xprt-switch
switch 0:num_xprts1,num_active1,queue_len0
xprt 0: local,/var/run/gssproxy.sock[main]
switch 1:num_xprts1,num_active1,queue_len0
xprt 1: local,/var/run/rpcbind.sock[main]
switch 2:num_xprts1,num_active1,queue_len0
xprt 2: tcp, 192.168.111.1 [main]
switch 3:num_xprts4,num_active4,queue_len0
xprt 3: tcp, 192.168.111.188 [main] xprt 4: tcp, 192.168.111.188
xprt 5: tcp, 192.168.111.188
xprt 6: tcp, 192.168.111.188And information about each xprt:
anna@client ~ % rpcsys xprt xprt 0: local, /var/run/gssproxy.sock, port 0, state <MAIN,CONNECTED,BOUND> Source: (einval), port 0, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 1: local, /var/run/rpcbind.sock, port 0, state <MAIN,CONNECTED,BOUND> Source: (einval), port 0, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 2: tcp, 192.168.111.1, port 2049, state <MAIN,CONNECTED,BOUND> Source: 192.168.111.222, port 959, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 3: tcp, 192.168.111.188, port 2049, state <MAIN,CONNECTED,BOUND> Source: 192.168.111.222, port 921, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 4: tcp, 192.168.111.188, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 726, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 5: tcp, 192.168.111.188, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 671, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 xprt 6: tcp, 192.168.111.188, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 934, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0You can use the
setsubcommand to change the dstaddr of individual xprts:anna@client ~ % sudo rpcsys xprt --id 4 xprt 4: tcp, 192.168.111.188, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 726, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0 anna@client ~ % sudo rpcsys xprt set --id 4 --dstaddr server2.nowheycreamery.com xprt 4: tcp, 192.168.111.186, port 2049, state <CONNECTED,BOUND> Source: 192.168.111.222, port 726, Requests: 2 Congestion: cur 0, win 256, Slots: min 2, max 65536 Queues: binding 0, sending 0, pending 0, backlog 0, tasks 0Or for changing the dstaddr of all xprts attached to a switch:
anna@client % rpcsys xprt-switch --id 3 switch 3: num_xprts 4, num_active 4, queue_len 0 xprt 3: tcp, 192.168.111.188 [main] xprt 4: tcp, 192.168.111.188 xprt 5: tcp, 192.168.111.188 xprt 6: tcp, 192.168.111.188 anna@client % sudo rpcsys xprt-switch set --id 4 --dstaddr server2.nowheycreamery.vm switch 3: num_xprts 4, num_active 4, queue_len 0 xprt 2: tcp, 192.168.111.186 [main] xprt 3: tcp, 192.168.111.186 xprt 5: tcp, 192.168.111.186 xprt 6: tcp, 192.168.111.186I renamed the tool to "rpcsys" after the discussion at the bakeathon. I think this is at least a better name, but if anybody has other ideas please let me know!
Quoted 5 lines
Quoted 1 line
Thoughts?
Anna, very nice!
How about naming it "rpcctl" to follow the pattern of:
Good suggestion! I can go with that.
Quoted 49 lines
systemctl
resolvectl
hostnamectlQuoted 34 lines
Anna
Anna Schumaker (9):
rpcsys: Add arpcsys.pytool
rpcsys: Add a command for printing xprt switch information
rpcsys: Add a command for printing individual xprts
rpcsys: Add a command for printing rpc-client information
rpcsys: Add a command for changing xprt dstaddr
rpcsys: Add a command for changing xprt-switch dstaddrs
rpcsys: Add a command for changing xprt state
rpcsys: Add a man page
rpcsys: Add installation to theMakefile.gitignore | 2 + configure.ac | 1 + tools/Makefile.am | 2 +- tools/rpcsys/Makefile.am | 20 ++++++++ tools/rpcsys/client.py | 27 +++++++++++ tools/rpcsys/rpcsys | 5 ++ tools/rpcsys/rpcsys.man | 88 ++++++++++++++++++++++++++++++++++ tools/rpcsys/rpcsys.py | 23 +++++++++ tools/rpcsys/switch.py | 51 ++++++++++++++++++++ tools/rpcsys/sysfs.py | 29 +++++++++++ tools/rpcsys/xprt.py | 101 +++++++++++++++++++++++++++++++++++++++ 11 files changed, 348 insertions(+), 1 deletion(-)create mode 100644
tools/rpcsys/Makefile.am
create mode 100644tools/rpcsys/client.py
create mode 100644tools/rpcsys/rpcsys
create mode 100644tools/rpcsys/rpcsys.man
create mode 100755tools/rpcsys/rpcsys.py
create mode 100644tools/rpcsys/switch.py
create mode 100644tools/rpcsys/sysfs.py
create mode 100644tools/rpcsys/xprt.pyQuoted 3 lines
--
2.33.1--
Chuck Lever