Just because the major manufacturers rate their batteries for 3 to 5 years doesn't mean you should leave them in service that long. Most models of UPS will beep and light an alarm indicator to tell you that the battery has gone bad. There's a big problem with this indication: it is too late! If the "replace-battery" alarm does come on, you must remove the batteries immediately or they will very soon (within a few hours) start overheating, swelling and/or leaking. Bear in mind that in the few months before the "replace-battery" alarm comes on you will have essentially zero reserve capacity to carry you through a power-outage. Since reserve capacity and load-carrying run-time are the reason you bought your UPS in the first place, it makes no sense to let the capacity go to zero and leave yourself vulnerable to power outages again. So, you should replace the batteries before they get near zero and long before the alarm indicator comes on.
On a recent customer visit I pointed out the "replace-battery" alarm on their 2200VA APC SMartUPS and they mentioned it had been on for for some months so I suggested a replacement battery cartridge and they said that because it was a 24 hour operation they could’t afford downtime to replace the battery although the batteries are hot swappable on that model. What would happen in the event of a small power outage where the UPS did not hold the load up and cause corruption on the servers. Such logic is hard to fathom.
Another customer found several new-in-box APC SmartUPS 1000 rack mount units in their basement that were 6 years old and is essentially scrap because the batteries had swelled to such an extent that it was not possible to remove the battery tray without major surgery.
How do you know when to replace the batteries? Schedule! The batteries that APC originally supplies in their SmartUPS and BackUPS products are rated for 3 to 5 years of normal service. These good quality batteries are fairly predictable in their performance and after 30 months of service the batteries most likely will have declined to less than half of the original capacity they had when new. They will still be capable of carrying your computer through a short power-outage but they won't be able to carry it as long as when they were new. If you've previously replaced your batteries with a lesser quality brand than APC uses, your batteries may not even last that long. Whenever you replace your batteries, write the replacement date with a marker on the the battery cover. Then replace them after 30 months or whatever period of time makes you feel comfortable.
APC's SmartUPS line has a "run-time calibration" function that will test and predict how many minutes your current batteries will carry your computer during a power outage. The PowerChute software can perform this test whenever you want but only if you have installed it on your computer and connected the UPS with the USB or serial cable that it came with. This "run-time calibration" will use your computer as a test load to discharge the batteries to 50% of their stored energy and report to you how many minutes your computer should be able to run during an outage. You can run this test once a month if you want to, without hurting your batteries. Then you can decide when to replace the batteries based on how much run-time you think you should have for the type of power-outages you expect in your area.