Kumar Thangavel | 29949f4 | 2022-07-15 20:33:28 +0530 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Power off the hosts when fan sensors crossed thresholds. |
| 3 | |
| 4 | echo "Power off the hosts if fansensors threshold crossed ::" |
| 5 | |
| 6 | HOST_INSTANCES="HOST_INSTANCES_SED_REPLACEMENT_VALUE" |
| 7 | |
| 8 | DBUS_SERVICE="xyz.openbmc_project.State.Chassis" |
| 9 | DBUS_OBJECT="/xyz/openbmc_project/state/chassis" |
| 10 | DBUS_INTERFACE="xyz.openbmc_project.State.Chassis" |
| 11 | DBUS_PROPERTY="RequestedPowerTransition" |
| 12 | PROPERTY_VALUE="xyz.openbmc_project.State.Chassis.Transition.Off" |
| 13 | |
| 14 | # Power off the hosts. |
| 15 | power-off-all-hosts() |
| 16 | { |
| 17 | for host_id in $HOST_INSTANCES |
| 18 | do |
| 19 | echo "chosen host id :::$host_id" |
| 20 | |
| 21 | # host power off |
Andrew Geissler | d96085e | 2023-04-13 15:34:50 -0600 | [diff] [blame^] | 22 | output=$(busctl set-property $DBUS_SERVICE"$host_id" $DBUS_OBJECT"$host_id" $DBUS_INTERFACE $DBUS_PROPERTY s $PROPERTY_VALUE) |
Kumar Thangavel | 29949f4 | 2022-07-15 20:33:28 +0530 | [diff] [blame] | 23 | echo "$output" |
| 24 | |
| 25 | done |
| 26 | } |
| 27 | |
| 28 | power-off-all-hosts |