Here is a conundrum for you: three AS/400's, one UPS and one UPS cable. All systems were already protected by the...
UPS, but there is only the one cable. This means that in the event of a power outage, only one AS/400 will shut itself down before the UPS runs out of battery power. The other two machines, meanwhile, will run out of power and go down hard. All of the AS/400's need to be notified in the event of a power loss in order to have each machine shut down.
There was talk at first of splitting the UPS cable three ways and attaching a split to each AS/400. That idea would most likely work fine, but IBM doesn't support such a configuration. Another option would be to purchase an additional two UPS's and independent cables so that each AS/400 would have one . That is fully supported, but it's a little costly and produces a lot of extra hardware.
The solution I finally came up with was so simple: Connect one UPS data cable to our primary AS/400 and use remote commands to power down the other machines.
Creating a power-handling program
After a predetermined amount of time on UPS power, we want to notify users on all systems of an imminent shutdown and bring down all AS/400's in a manner more graceful than a hard power loss.
The IBM i Information Center provides an example control language (CL) program for monitoring a message queue allocated exclusively for UPS messages and powering down the system in a controlled fashion. We can take this code and customize it to fit our needs.
In addition to creating the program, we will need to change a few system values and create the message queue to handle UPS-related messages. These steps on power-handling programs are well-documented.
Within the power-handling program, we need to add a submit remote command (SBMRMTCMD) to power down each additional IBM i server. In order to send a remote command to another IBM i, we need to use the CRTDDMF command to set up a distributed data management (DDM) file on the source server for each target server. There will also need to be a file on the target servers that each DDM file will point to and connect.
I'd suggest putting the all of these objects in custom libraries dedicated to UPS-related activities. On my servers and in the IBM Information Center article, the library is defined as UPSLIB.
Create your DDM file with this command:
CRTDDMF FILE(UPSLIB/DDM170) RMTFILE(UPSLIB/GETUPSMSG) RMTLOCNAME(sys2 *IP)
In this command, the DDM file (DDM170) is created on the source server in library UPSLIB. On the target server, I have an existing physical file called GETUPSMSG in library UPSLIB, which the source DDM file uses to identify what file to connect to. The rest of the command specifies the remote location name (sys2) and the method of communication (TCP/IP).
In the execution of my power-handling CL program, I want to send a quick note to all users on remote systems (a model 170 and a model 270 server) informing them that they have limited time to log off. I then want to wait several minutes and power down those systems, as well as the source server.
This code explains how to do this:
/* Notify users on 170 server */ SBMRMTCMD CMD('sndbrkmsg msg(Server will be shutting down in 5 minutes due to power failure. Log off immediately.) tomsgq(*allws)') DDMFILE(upslib/ddm170) /* Notify users on 270 server */ SBMRMTCMD CMD('sndbrkmsg msg(Server will be shutting down in 5 minutes due to power failure. Log off immediately.) tomsgq(*allws)') DDMFILE(upslib/ddm270) /* Notify users on this 515 server */ SNDBRKMSG MSG(Server will be shutting down in 5 minutes due to power failure. Log off immediately.) TOMSGQ(*allws) DLYJOB DLY(300) /* Power down 170 server */ SBMRMTCMD CMD('pwrdwnsys option(*immed)') DDMFILE(upslib/ddm170) /* Power down 270 server */ SBMRMTCMD CMD('pwrdwnsys option(*immed)') DDMFILE(upslib/ddm270) /* Power down this 515 server */ PWRDWNSYS OPTION(*IMMED)
It's simple code with a powerful result. Using remote commands can be very useful in other ways as well, including running queries on a target IBM i and pulling the returned data back to the source IBM i.
ABOUT THE AUTHOR: Steve Pitcher is the Enterprise Servers and Application Analyst for Minas Basin Pulp & Power in NS, Canada. He's been specializing in System i and Lotus Domino solutions for the last decade. His blog, ENDJOBABN covers his adventures in, and amusement with, his work on the IBM i and Lotus Domino.