proxysearch.py #1

  • //
  • guest/
  • russell_jackson/
  • sdp/
  • Maintenance/
  • proxysearch.py
  • View
  • Commits
  • Open Download .zip Download (1 KB)
#!/usr/bin/env python
# ==============================================================================
# Copyright and license info is available in the LICENSE file included with
# the Server Deployment Package (SDP), and also available online:
# https://swarm.workshop.perforce.com/projects/perforce-software-sdp/view/main/LICENSE
# ------------------------------------------------------------------------------

"""
This script will search your server log file and find any proxy servers that are
connecting to the server. The server log file needs to be set to a debug level 1 or
higher in order to record all the commands coming into the server.

Just pass the log file in as  parameter to this script and it will print out a list
of the proxy servers.
"""

import re, sys

def main():
    input = open(sys.argv[1], "r")

    proxylist = []

    for line in input.readlines():
        if re.search(r'\d+\.\d+\.\d+\.\d+\/\d+\.\d+\.\d+\.\d+', line):
            def rep(mo):
                return '%s' % (mo.group(1))


            line = re.sub(r'.* (\d+\.\d+\.\d+\.\d+)\/\d+\.\d+\.\d+\.\d+ .*', rep, line)
            if line not in proxylist:
                proxylist.append(line)

    input.close()

    for proxy in proxylist:
        print(proxy)



if __name__ == "__main__":
    main()
# Change User Description Committed
#2 24675 Russell C. Jackson (Rusty) Fixed bugs in sdputils.py and scripts using it.
Converted to standard 2 space spacing, removed copyright stuff.
#1 22693 Russell C. Jackson (Rusty) Branched a Unix only version of the SDP.
Removed extra items to create a cleaner tree.
Moved a few items around to make more sense without Windows in the mix.
//guest/perforce_software/sdp/dev/Maintenance/proxysearch.py
#6 16638 C. Thomas Tyler Routine merge down to dev from main using:
p4 merge -b perforce_software-sdp-dev
#5 16029 C. Thomas Tyler Routine merge to dev from main using:
p4 merge -b perforce_software-sdp-dev
#4 15375 adrian_waters Routine merge-down from main->dev
#3 11477 Russell C. Jackson (Rusty) Updated to use /usr/bin/env python

Added workshop header.

 Changed cfg to config.
#2 11464 Russell C. Jackson (Rusty) Current maintenance scripts.
#1 10638 C. Thomas Tyler Populate perforce_software-sdp-dev.
//guest/perforce_software/sdp/main/Maintenance/proxysearch.py
#1 10148 C. Thomas Tyler Promoted the Perforce Server Deployment Package to The Workshop.