Zend certified PHP/Magento developer

How to see the percentage of ports being used by an application compared to the total number of ports available

Having some rare port exhaustion issues and was wondering if there is a way to see the number of ports being used by a single application. I would like to have it in a percentage-like manner but anything works.

The way I am handling the solution now is just to calculate the total amount of ports over a period of time and calculate the relative percentage compared to others using netstat. This is not really accurate and might lead to false positives. I was also thinking of just dividing the number by 65535 but I don’t think that will be very good either.