Asterisk Limits



I was reading about ulimits, but its not immediately clear to me how they work.

NOFILE max number of open files 1024 4096

Is there link that someone could point me to that clearly covers the topic?

More importantly, is there a bash or cli command that I can use to determine how close my Asterisk/FreePBX box is getting to the max?

Thanks for your help!