Wrote a quick and dirty script to scan the listener log for incoming connections and produce a count of how many connections came from which host. Here is the URL:
https://github.com/bobbydurrett/miscpython/blob/master/gethostcounts.py
All it does is hack out the ip address from the second HOST= entry of the lines in the listener log that have HOST= in them. Then it uses the Python function socket.gethostbyaddr to get the hostname for those that can be looked up this way.
Counts the number of lines for a given ip address and sorts them from most to least connections. Might be useful to someone.
Bobby
Unix shell version … if I translated correctly … YMMV 🙂
=====
cat ${ORACLE_BASE}/diag/tnslsnr/myhost/listener/trace/listener.log | grep -E ‘\(HOST=’ | tr -s ‘ ‘ | cut -d ‘*’ -f3 | sed -e ‘s#^ (A#(A#g’ | cut -d ‘=’ -f4 | sed -e ‘s#)(PORT##g’ | grep -E ‘^[1-9]’ | sort | uniq –count | sort -s -n -k 1,1
Tim…
Thanks!
Great.
Is there a shell script to shut and start the database and listener.
From Python? I don’t have a Python script for that but someone could make one using subprocess to run the necessary shell scripts. Thanks for your comment.
Bobby