Changeset 988 for vendor/current/source4/scripting/bin/smbstatus
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
-
vendor/current/source4/scripting/bin/smbstatus (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/scripting/bin/smbstatus
r740 r988 3 3 # 4 4 # provide information on connected users and open files 5 # Copyright ÇJelmer Vernooij 20085 # Copyright Jelmer Vernooij 2008 6 6 # 7 7 # Based on the original in EJS: … … 12 12 import os, sys 13 13 14 15 16 17 18 19 14 20 sys.path.insert(0, "bin/python") 15 21 … … 19 25 20 26 def show_sessions(conn): 21 """show open sessions"""27 """show open sessions""" 22 28 23 sessions = conn.smbsrv_information(irpc.SMBSRV_INFO_SESSIONS).next()24 print "User Client Connected at"25 print "-" * 7926 for session in sessions:27 fulluser = "%s/%s" % (session.account_name, session.domain_name)28 print "%-30s %16s %s" % (fulluser, session.client_ip, sys.httptime(session.connect_time))29 print ""29 sessions = conn.smbsrv_information(irpc.SMBSRV_INFO_SESSIONS).next() 30 print "User Client Connected at" 31 print "-" * 79 32 for session in sessions: 33 fulluser = "%s/%s" % (session.account_name, session.domain_name) 34 print "%-30s %16s %s" % (fulluser, session.client_ip, sys.httptime(session.connect_time)) 35 print "" 30 36 31 37 def show_tcons(open_connection): 32 """show open tree connects"""33 conn = open_connection("smb_server")34 tcons = conn.smbsrv_information(irpc.SMBSRV_INFO_TCONS).next()35 print "Share Client Connected at"36 print "-" * 7937 for tcon in tcons:38 print "%-30s %16s %s" % (tcon.share_name, tcon.client_ip, sys.httptime(tcon.connect_time))38 """show open tree connects""" 39 conn = open_connection("smb_server") 40 tcons = conn.smbsrv_information(irpc.SMBSRV_INFO_TCONS).next() 41 print "Share Client Connected at" 42 print "-" * 79 43 for tcon in tcons: 44 print "%-30s %16s %s" % (tcon.share_name, tcon.client_ip, sys.httptime(tcon.connect_time)) 39 45 40 46 41 47 def show_nbt(open_connection): 42 """show nbtd information"""43 conn = open_connection("nbt_server")44 stats = conn.nbtd_information(irpc.NBTD_INFO_STATISTICS).next()45 print "NBT server statistics:"46 fields = [("total_received", "Total received"),47 ("total_sent", "Total sent"),48 ("query_count", "Query count"),49 ("register_count", "Register count"),50 ("release_count", "Release count")]51 for (field, description) in fields:52 print "\t%s:\t%s" % (description, getattr(stats, field))53 48 """show nbtd information""" 49 conn = open_connection("nbt_server") 50 stats = conn.nbtd_information(irpc.NBTD_INFO_STATISTICS).next() 51 print "NBT server statistics:" 52 fields = [("total_received", "Total received"), 53 ("total_sent", "Total sent"), 54 ("query_count", "Query count"), 55 ("register_count", "Register count"), 56 ("release_count", "Release count")] 57 for (field, description) in fields: 58 print "\t%s:\t%s" % (description, getattr(stats, field)) 59 print 54 60 55 61 parser = optparse.OptionParser("%s [options]" % sys.argv[0]) … … 57 63 parser.add_option_group(sambaopts) 58 64 parser.add_option("--messaging-path", type="string", metavar="PATH", 59 help="messaging path")65 help="messaging path") 60 66 parser.add_option("--nbt", help="show NetBIOS status", action="store_true") 61 67 … … 69 75 70 76 def open_connection(name): 71 return messaging.ClientConnection(name, messaging_path=messaging_path)77 return messaging.ClientConnection(name, messaging_path=messaging_path) 72 78 73 79 if opts.nbt: 74 show_nbt(open_connection)80 show_nbt(open_connection) 75 81 else: 76 try:77 conn = open_connection("smb_server")78 except RuntimeError, (num, msg):79 if msg == 'NT_STATUS_OBJECT_NAME_NOT_FOUND':80 print "No active connections"81 else:82 show_sessions(conn)83 show_tcons(conn)82 try: 83 conn = open_connection("smb_server") 84 except RuntimeError, (num, msg): 85 if msg == 'NT_STATUS_OBJECT_NAME_NOT_FOUND': 86 print "No active connections" 87 else: 88 show_sessions(conn) 89 show_tcons(conn)
Note:
See TracChangeset
for help on using the changeset viewer.
