Uninterruptible power supply: Difference between revisions
|  →Declare UPS units:  rationale |  →Delay UPS Shutdown:  do not use slice | ||
| (9 intermediate revisions by the same user not shown) | |||
| Line 25: | Line 25: | ||
| needs a new battery every four years, under optimal operating | needs a new battery every four years, under optimal operating | ||
| conditions. | conditions. | ||
| The end of ConfigExample book says: | |||
|  Joe's server will still be allright | |||
|  if power drops off in the night. | |||
|    That 8 year old pack | |||
|    of battery backup | |||
|  will easily handle th connection lost | |||
| = Components of NUT Software = | = Components of NUT Software = | ||
| Line 50: | Line 58: | ||
| * upsd.conf, control access to upsd, power.ups.upsd option | * upsd.conf, control access to upsd, power.ups.upsd option | ||
| * upsd.users, add user with access to upsd, power.ups.users option | * upsd.users, add user with access to upsd, power.ups.users option | ||
| * upsmon.conf, connect to upsd, power.ups.upsmon.monitor section; | * upsmon.conf, connect upsmon to upsd, power.ups.upsmon.monitor section; | ||
| * upsmon.conf, set how upsmon should react to status changes, power.ups.upsmon.settings section | * upsmon.conf, set how upsmon should react to status changes, power.ups.upsmon.settings section | ||
| * delayed UPS shutdown systemd unit, to make Restore Power on AC Return BIOS option functional, systemd.services.nut-delayed-ups-shutdown section | * delayed UPS shutdown systemd unit, to make Restore Power on AC Return BIOS option functional, systemd.services.nut-delayed-ups-shutdown section | ||
| Line 63: | Line 71: | ||
|      # this UPS device is named UPS-1. |      # this UPS device is named UPS-1. | ||
|      ups."UPS-1" = { |      ups."UPS-1" = { | ||
|        description = "Eaton Ellipse ECO 650 with 12V 7Ah Batt"; |        description = "Eaton Ellipse ECO 650 with 12V 7Ah lead-acid Batt"; | ||
|        # driver name from https://networkupstools.org/stable-hcl.html |        # driver name from https://networkupstools.org/stable-hcl.html | ||
| Line 94: | Line 102: | ||
|          # upsmon initiate shutdown once this threshold is reached. |          # upsmon initiate shutdown once this threshold is reached. | ||
|          "lowbatt = 40" |          "lowbatt = 40" | ||
|         # ignore it if the UPS reports a low battery condition | |||
|         # without this, system will shutdown only when ups reports lb, | |||
|         # not respecting lowbatt option | |||
|         "ignorelb" | |||
|        ]; |        ]; | ||
|      }; |      }; | ||
| Line 127: | Line 140: | ||
|      # declarations. upsd.users |      # declarations. upsd.users | ||
|      users."nut-admin" = { |      users."nut-admin" = { | ||
|        passwordFile = ../resources/ups-passwd.txt; |        passwordFile = "${../resources/ups-passwd.txt}"; | ||
|        upsmon = "primary"; |        upsmon = "primary"; | ||
|      }; |      }; | ||
| Line 142: | Line 155: | ||
|        powerValue = 1; |        powerValue = 1; | ||
|        user = "nut-admin"; |        user = "nut-admin"; | ||
|        passwordFile = ../resources/ups-passwd.txt; |        passwordFile = "${../resources/ups-passwd.txt}"; | ||
|        type = "primary"; |        type = "primary"; | ||
|      }; |      }; | ||
| Line 212: | Line 225: | ||
| During the system shutdown, systemd service unit runs the command | During the system shutdown, systemd service unit runs the command | ||
| upsdrvctl shutdown. This tells the UPS that it is to shut down | <code>upsdrvctl shutdown</code>. This tells the UPS that it is to shut down | ||
| offdelay seconds later. The system powers down before offdelay seconds | offdelay seconds later. The system powers down before offdelay seconds | ||
| have passed. Wall power returns before the UPS shuts down Less than | have passed. Wall power returns before the UPS shuts down. Less than | ||
| offdelay seconds have passed. The UPS continues it's shutdown | offdelay seconds have now passed. The UPS continues it's shutdown | ||
| process. | process. | ||
| After offdelay seconds the UPS shuts down, disconnecting it's | After offdelay seconds the UPS shuts down, disconnecting it's | ||
| outlets. The beeping stops.  With some UPS units, there is an audible | outlets. The beeping stops.  With some UPS units, there is an audible | ||
| clunk. An interval of ondelay | clunk. An interval of ondelay minus offdelay seconds later: After ondelay | ||
| seconds the UPS turns itself on, and repowers it's outlets. The system | seconds the UPS turns itself on, and repowers it's outlets. The system | ||
| BIOS option Restore Power on AC return has hopefully been selected and | BIOS option Restore Power on AC return has hopefully been selected and | ||
| Line 233: | Line 246: | ||
|    # copied from ConfigExamples 3.0 book, Appendix B.2. |    # copied from ConfigExamples 3.0 book, Appendix B.2. | ||
|    systemd.services.nut-delayed-ups-shutdown = { |    systemd.services.nut-delayed-ups-shutdown = { | ||
|      enable = true; | |||
|     environment = config.systemd.services.upsmon.environment; | |||
|     description = "Initiate delayed UPS shutdown"; | |||
|     before = [ "umount.target" ]; | |||
|     wantedBy = [ "final.target" ]; | |||
|      serviceConfig = { |      serviceConfig = { | ||
|        Type = "oneshot"; |        Type = "oneshot"; | ||
|        ExecStart = ''${pkgs. |       # need to use '-u root', or else permission denied | ||
|        ExecStart = ''${pkgs.nut}/bin/upsdrvctl -u root shutdown''; | |||
|       # must not use slice: if used, upsdrvctl will not run as a late | |||
|       # shutdown service | |||
|       # Slice = ""; | |||
|     }; | |||
|     unitConfig = { | |||
|       ConditionPathExists = config.power.ups.upsmon.settings.POWERDOWNFLAG; | |||
|       DefaultDependencies = "no"; | |||
|      }; |      }; | ||
|    }; |    }; | ||
| </syntaxhighlight> | </syntaxhighlight> | ||