Automating APC 7922B PDU to turn on IP KVM during server reboots

Doing remote server upgrades is risky and usually requires a reboot of the system to load the new kernel, modules and binaries. To lower the risk of downtime due to a misconfigured firewall or mount settings, I would usually follow the following routine:

  1. Login to local PDU
  2. Turn on IP KVM port
  3. Reboot server
  4. Wait until server becomes reachable
  5. Login to local PDU
  6. Turn off IP KVM port

3.6 – not great, not terrible. Usually being the key word above – sometimes I would simply forget to turn on the IP KVM or vice versa… However, we can automate all of that with Systemd and its support for dependency management:

https://github.com/eAndrius/apc_utility

Provided Systemd scripts will do the following:

  1. Turn on the remote PDU outlet for IP KVM just before the server shuts down / reboots
  2. Turn off the remote PDU outlet for IP KVM 3 hours after system boots up

For the completeness of this topic, I also have the PDU setup to automatically turn on the IP KVM outlet on resume of power outage / cold boot.