his maybe is not the most sophisticated solution, but - especially if you do not have other processes opening so many sockets - you could check the output of
netstat -nutp
(n: no name resolution, t: TCP, u: UDP, p:show PID and program - you might want to only provide only one of u or t based on whether your process opens UDP or TCP connections).
You can grep for the pid from the output:
netstat -nutp | grep -c ' 12345/progname$'
where '12345' should be replaced with your PID and 'progname' with the name of your process. The option -c for grep counts the matches. You might want to refine the search to more accurately match your needs (e.g. include only ESTABLISHED connections).
Also 'lsof' might be your friend. You can try
lsof -p 12345 -a -i4
and check the output and do some grepping. Have a look into lsof manual page to see if you can modify the output format to better suit scripted parsing.
You can write a simple script to run the command periodically. For huge number of connections, you better experiment how much resources running netstat or lsof takes and adjust the interval. E.g. once per minute (by default)
#!/bin/sh
prog=progname
if [ -z "$1" ]; then
interval=60
else
interval="$1"
fi
pid=$(pidof $prog)
while :; do
n=$(netstat -nutp | grep -c " ${pid}/${prog}$')
date +"Number of connections [%Y-%m-%d %H:%M:%S]: $n" > connection.log
if [ "$n" -gt $TRESHOLD ]; then
# warn the admin
fi
sleep "${interval}"
done