Short and sweet, your server must be notified by the UPS that the power is out, and the computer needs to shutdown now. How that notification happens, there are various methods as Ford mentioned.
I differ from him on how much capacity you should use, for several reasons. I prefer to have things set up to be fully shut down BEFORE the battery in the UPS reaches 50% discharge. 1st reason, battery lifespan. The shallower the discharge, the longer lifespan the battery should have. 2nd reason, the nature of power outages. A second outage within a short period of the power returning is very likely, as the crews temporarily restore power to the greatest number of customers, then come back through and make permanent repairs. The recharge time is WAY longer than the time used on battery, 10 to 20 times. So, if you drain the batteries to 30% left, and start everything back up as soon as power is restored, you will likely not have enough capacity left for a clean shutdown if the power is lost a second time.
The goal of a consumer level battery backup is NEVER to replace power during an outage, it's to safely shut things down in a controlled timeframe. If you want extended runtime, there are commercial units available with add on battery banks, or size things so you can fire up a generator to replace the mains for an extended outage.
In my area, if the power is out more than a minute, it's probably going to be out way longer than a UPS can handle, so I have things start shutting down pretty much immediately, with the server the last to go down after 10 minutes of outage. VM's get the signal from the server that the power is out using the apcupsd program, there are clients available for pretty much any OS. So the VM's start shutting down after 1 minute of outage, various desktops as well. If everything goes as planned, the server has no client connections after 5 minutes or so, and can shut down.