More elegant one-Liner:
if cpstat os -f power_supply | grep -qi "down"; then logger -s -p kern.crit -t kernel 'PSU is down !!! Please replace faulty PSU.'; fi
This command will check if output of "cpstat os -f power_supply" contains string "down" (not case sensitive) and in case yes, issue command logger with facility kern and priority crit to print desired text in /var/log/messages in order to be caught by any Syslog server as critical message (or check it some other way within logs).
Just schedule this one line using cron job every day and you have monitoring of PSU in place 🙂
Please note that there are some exceptions where PSU is considered as down, but not really:
sk107199 - Power Supply sensors are shown as "Up" or "Down" when using one Power Supply and one Powe...
Another solution is to use snmpwalk to get status of PSUs, or create trap for it:
OID Name: powerSupplyStatus
OID Number: 18.104.22.168.4.1.2622.214.171.124.126.96.36.199