Count open connections for a process – SOLARIS
October 14, 2010 at 4:49 pm Leave a comment
Had an issue in SIT server , where all the connections of the MQManager server got exhausted.
This was because some process was holding the entire available connections and not releasing it.
The following code finds all the process id’s for a particular user and finds the count of all connections opened by each of that processes . This will be logged to a file.
username – the user name for which the process belongs
/folder/data.txt – the file which stores process id’s.
result.txt – results with PID – COUNT generated
AF_INET 127.0.0.1 – denotes the server to which connections are made
#!/bin/bash
ps -eaf -u username -opid > /folder/data.txt
echo > result.txt
while IFS= read -r file
do
[ -f "$file" ] && rm -f "$file"
cnt=$(pfiles $file |egrep 'AF_INET 127.0.0.1' | wc -l)
if [ $cnt -ne "0" ]
then
echo $file $cnt >> result.txt
fi
done < "/folder/data.txt"
This script helped me zero in on the process holding up all the connections
~HTH
Entry filed under: tips and tricks. Tags: open connections count for a process, PID, Solaris.
Trackback this post | Subscribe to the comments via RSS Feed