I need a Script to rsh multiple hp boxes and shutdown

Here is a script that logs into different boxes to change the password:
changepass automate password changes on multiple systems

Most UPS systems have a monitor port which can be read with a serial connection. The system can monitor this and shut itself down when there is a power problem. Do you have any indicator which you can monitor? That might be a better approach.