summaryrefslogtreecommitdiff
path: root/source4/scripting/bin
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-05-26 05:00:45 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-05-26 05:00:45 +0200
commit4b3641695ba42d0348e8eceadb02430342c1513c (patch)
treee30c163f10aa6158ac20308417f0a8d212246c2e /source4/scripting/bin
parentd5434f0b4bcf744e5a5f0e933bdcf629d42a6478 (diff)
downloadsamba-4b3641695ba42d0348e8eceadb02430342c1513c.tar.gz
samba-4b3641695ba42d0348e8eceadb02430342c1513c.tar.bz2
samba-4b3641695ba42d0348e8eceadb02430342c1513c.zip
Finish smbstatus in Python.
(This used to be commit 988508c2d3269cc88ed38df2fc207a1c0aaccc6b)
Diffstat (limited to 'source4/scripting/bin')
-rwxr-xr-xsource4/scripting/bin/smbstatus23
1 files changed, 15 insertions, 8 deletions
diff --git a/source4/scripting/bin/smbstatus b/source4/scripting/bin/smbstatus
index 6d852c279c..7e58ee1269 100755
--- a/source4/scripting/bin/smbstatus
+++ b/source4/scripting/bin/smbstatus
@@ -9,13 +9,13 @@
# Released under the GNU GPL version 3 or later
#
-import sys
+import os, sys
sys.path.insert(0, "bin/python")
import optparse
import samba.getopt as options
-from samba import messaging, irpc
+from samba import irpc, messaging
def show_sessions(conn):
"""show open sessions"""
@@ -35,7 +35,7 @@ def show_tcons(open_connection):
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))
+ print "%-30s %16s %s" % (tcon.share_name, tcon.client_ip, sys.httptime(tcon.connect_time))
def show_nbt(open_connection):
@@ -43,9 +43,14 @@ def show_nbt(open_connection):
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" + getattr(stats, r) + "\n"
- print ""
+ fields = [("total_received", "Total received"),
+ ("total_sent", "Total sent"),
+ ("query_count", "Query count"),
+ ("register_count", "Register count"),
+ ("release_count", "Release count")]
+ for (field, description) in fields:
+ print "\t%s:\t%s" % (description, getattr(stats, field))
+ print
parser = optparse.OptionParser("%s [options]" % sys.argv[0])
sambaopts = options.SambaOptions(parser)
@@ -58,10 +63,12 @@ opts, args = parser.parse_args()
lp = sambaopts.get_loadparm()
-print "%s\n\n" % lp.get("server string")
+print "%s" % lp.get("server string")
+
+messaging_path = (opts.messaging_path or os.path.join(lp.get("private dir"), "smbd.tmp", "messaging"))
def open_connection(name):
- return messaging.ClientConnection(name, messaging_path=opts.messaging_path)
+ return messaging.ClientConnection(name, messaging_path=messaging_path)
if opts.nbt:
show_nbt(open_connection)