summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-05-26 04:14:28 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-05-26 04:14:28 +0200
commitd5434f0b4bcf744e5a5f0e933bdcf629d42a6478 (patch)
treeace24381ce274aa5d1d29af03ffd7917732334da /source4/scripting
parentd60d8e57d83acfc94fa36c59fcfb9c6e03ee02b6 (diff)
downloadsamba-d5434f0b4bcf744e5a5f0e933bdcf629d42a6478.tar.gz
samba-d5434f0b4bcf744e5a5f0e933bdcf629d42a6478.tar.bz2
samba-d5434f0b4bcf744e5a5f0e933bdcf629d42a6478.zip
Allow using IRPC functions on the messaging bus from Python.
(This used to be commit 6ecf81ae13dffa05356c1177c617206c120fb7d7)
Diffstat (limited to 'source4/scripting')
-rwxr-xr-xsource4/scripting/bin/smbstatus39
1 files changed, 23 insertions, 16 deletions
diff --git a/source4/scripting/bin/smbstatus b/source4/scripting/bin/smbstatus
index 782e83e4cf..6d852c279c 100755
--- a/source4/scripting/bin/smbstatus
+++ b/source4/scripting/bin/smbstatus
@@ -15,11 +15,12 @@ sys.path.insert(0, "bin/python")
import optparse
import samba.getopt as options
-import samba.irpc
+from samba import messaging, irpc
-def show_sessions():
+def show_sessions(conn):
"""show open sessions"""
- sessions = smbsrv_sessions()
+ conn = open_connection("smb_server")
+ sessions = conn.smbsrv_information(irpc.SMBSRV_INFO_SESSIONS).next()
print "User Client Connected at"
print "-------------------------------------------------------------------------------"
for session in sessions:
@@ -27,37 +28,43 @@ def show_sessions():
print "%-30s %16s %s" % (fulluser, session.client_ip, sys.httptime(session.connect_time))
print ""
-def show_tcons():
+def show_tcons(open_connection):
"""show open tree connects"""
- tcons = smbsrv_tcons()
+ conn = open_connection("smb_server")
+ tcons = conn.smbsrv_information(irpc.SMBSRV_INFO_TCONS).next()
print "Share Client Connected at"
print "-------------------------------------------------------------------------------"
for tcon in tcons:
print "%-30s %16s %s\n" % (tcon.share_name, tcon.client_ip, sys.httptime(tcon.connect_time))
-def show_nbt():
+def show_nbt(open_connection):
"""show nbtd information"""
- stats = nbtd_statistics()
- print "NBT server statistics:",
+ conn = open_connection("nbt_server")
+ stats = conn.nbtd_information(irpc.NBTD_INFO_STATISTICS).next()
+ print "NBT server statistics:"
for r in stats:
- print "\t" + r + ":\t" + stats[r] + "\n"
+ print "\t" + r + ":\t" + getattr(stats, r) + "\n"
print ""
parser = optparse.OptionParser("%s [options]" % sys.argv[0])
sambaopts = options.SambaOptions(parser)
parser.add_option_group(sambaopts)
-parser.add_option("--nbt", type="string", metavar="NBT",
- help="show NetBIOS status")
+parser.add_option("--messaging-path", type="string", metavar="PATH",
+ help="messaging path")
+parser.add_option("--nbt", help="show NetBIOS status", action="store_true")
+
+opts, args = parser.parse_args()
lp = sambaopts.get_loadparm()
print "%s\n\n" % lp.get("server string")
+def open_connection(name):
+ return messaging.ClientConnection(name, messaging_path=opts.messaging_path)
+
if opts.nbt:
- show_nbt()
+ show_nbt(open_connection)
else:
- show_sessions()
- show_tcons()
-
-return 0
+ show_sessions(open_connection)
+ show_tcons(open_connection)