Get number of ports/connections used on NetScaler SNIP/MIP

In the old times, there used to be a one-command-solution for getting the number of ports used and available on your NetScaler IPs (most interestingly MIPs and SNIPs). Meanwhile this command, which I do not state here, because it has way too much power to be loosely published, does show useless numbers with six or even seven digits. No idea why, but Tech Support was not able to tell me either.

There are no statistics on how many ports are already used on your SNIPs and MIPs so you could set alarms and plan for provisioning of additional IPs for back-end communication early enough, before the sockets are eaten up. You could go counting in the connection table – and that’s what this command does for you. Go to shell and run:

nscli -U :<user>:<password> sh connectiontable | cut -d “ “ -f 1 | grep <ip> | wc -l

word count (wc) will give you the number of lines and thus the number of connections originating from that IP (by cutting after the first field, which is SOURCEIP, we only get the outbound connections).

Note: password might need single quotes to protect special characters.