My only advice is to power it down and unplug it if the power starts fluctuating quickly causing the unit to kick on and off rapidly.
You should never have to unplug an APC. That's the WHOLE point of having one! Are you supposed to notice the lights flickering at 3AM?
I guess APC units or at least my unit has protection for this, if the power goes off and cycles, it will stay off for a good 15 seconds before it clicks back on.
But you could buy one of these things... Maybe even get something inline for the entire home! As, that rapid power flicker can kill, your AC, Fridge, Computer in your washer, light bulbs.... etc...etc... Do a search for "compressor Defender" ... maybe you could make your own relay. Dunno, seems like something that could be made cheaply for expensive devices that are plugged in 24/7.
The Compressor Defender protects home A/C units against the three most common power-related failures. First, it monitors line voltage and shuts down the unit when it detects the kind of low-voltage conditions that happen frequently during high use summer months. Second, the surge protection circuitry safely diverts surges to protect the compressor and condenser fan motors. Third, it shuts down the unit the instant it detects a rapid on/off power flicker. That prevents “short cycling,” which causes premature compressor failure. This summary is from the Family Handyman 'Stuff We Love' article that included the Compressor Defender