If your UPS is made by APC, you could set up apcupsd.
A more generic tool with support for a wide range of vendors is NUT - Network UPS Tools. Nagios has a "check_ups" plugin which uses nut.
If you are using an APC SMART UPS unit, and connecting it via the USB port rather than the proprietary serial cable, then in /etc/nut/ups.conf your configuration stanza should use the non-obvious driver named newhidups, rather than the driver called apcsmart. (The older hidups driver results in syslog getting lots of "hidups: Unhandled event 0x84005x" messages). This is with nut version 2.0.4.
The device file for this (for me) is /dev/usb/hiddev0. This device file needs to be read/writable by the "nut" group. nut comes with UDev rules to do this, but if you install nut after connecting the USB cable then you can either modify the permissions of the file manually, or simply unplug and replug in the cable.
In /etc/nut/ups.conf, I originally had the port set to /dev/usb/hiddev0, but this resulted in nut occasionally losing the connection (and consequently nagios telling me that there is a problem with the UPS). I assume this is caused by the UPS doing its own self-test or something, but changing the port setting to be auto seems to have stopped it losing the connection (or at least, automatically reconnecting).