From 2b627fa7b417d5efd71f886c41efb9576dd555f1 Mon Sep 17 00:00:00 2001 From: liaou3 Date: Tue, 9 Jan 2024 16:51:43 +0800 Subject: [PATCH] Put the command field for eclite/temperature-reading-from-thermal-acpitz into shell script --- providers/base/bin/monitor_acpitz_thermal.sh | 35 ++++++++++++++++++++ providers/base/units/ishtp/jobs.pxu | 34 +------------------ 2 files changed, 36 insertions(+), 33 deletions(-) create mode 100755 providers/base/bin/monitor_acpitz_thermal.sh diff --git a/providers/base/bin/monitor_acpitz_thermal.sh b/providers/base/bin/monitor_acpitz_thermal.sh new file mode 100755 index 000000000..9c02f9eb9 --- /dev/null +++ b/providers/base/bin/monitor_acpitz_thermal.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +THERMAL_PATH="/sys/class/thermal/thermal_zone" +THERMALS=$(find $THERMAL_PATH*[0-9]) +ACPITZ_THERMAL_PATH="" +# Get the acpitz thermal +for t in $THERMALS; do + THERMAL_TYPE=$(cat "$t/type") + if [ "$THERMAL_TYPE" = "acpitz" ]; then + ACPITZ_THERMAL_PATH=$t + break + fi +done +# Check acpitz thermal can be found +if [ -z "$ACPITZ_THERMAL_PATH" ]; then + echo "Cannot find the acpitz thermal" + exit 1 +fi +echo "The path of acpitz thermal: $ACPITZ_THERMAL_PATH" +# Do testing and monitor the temperature +ACPITZ_TEMP="$ACPITZ_THERMAL_PATH/temp" +TEMP_BEFORE=$(cat "$ACPITZ_TEMP") +echo "Temperature before stress: $TEMP_BEFORE" +if ! [ "$TEMP_BEFORE" -gt 0 ]; then + echo "Invalid temperature, it should be more than 0" + exit 1 +fi +echo "Running stress for 5 minutes" +stress-ng --matrix 0 -t 5m +TEMP_AFTER=$(cat "$ACPITZ_TEMP") +echo "Temperature after stress: $TEMP_AFTER" +if ! [ "$TEMP_AFTER" -gt "$TEMP_BEFORE" ]; then + echo "The temperature after stress testing should be higher than before" + exit 1 +fi \ No newline at end of file diff --git a/providers/base/units/ishtp/jobs.pxu b/providers/base/units/ishtp/jobs.pxu index c92303f49..358e77e23 100644 --- a/providers/base/units/ishtp/jobs.pxu +++ b/providers/base/units/ishtp/jobs.pxu @@ -77,36 +77,4 @@ _description: plugin: shell user: root command: - THERMAL_PATH="/sys/class/thermal/thermal_zone" - THERMALS=$(find $THERMAL_PATH*[0-9]) - ACPITZ_THERMAL_PATH="" - # Get the acpitz thermal - for t in $THERMALS; do - THERMAL_TYPE=$(cat "$t/type") - if [ "$THERMAL_TYPE" = "acpitz" ]; then - ACPITZ_THERMAL_PATH=$t - break - fi - done - # Check acpitz thermal can be found - if [ -z "$ACPITZ_THERMAL_PATH" ]; then - echo "Cannot find the acpitz thermal" - exit 1 - fi - echo "The path of acpitz thermal: $ACPITZ_THERMAL_PATH" - # Do testing and monitor the temperature - ACPITZ_TEMP="$ACPITZ_THERMAL_PATH/temp" - TEMP_BEFORE=$(cat "$ACPITZ_TEMP") - echo "Temperature before stress: $TEMP_BEFORE" - if ! [ "$TEMP_BEFORE" -gt 0 ]; then - echo "Invalid temperature, it should be more than 0" - exit 1 - fi - echo "Running stress for 5 minutes" - stress-ng --matrix 0 -t 5m - TEMP_AFTER=$(cat "$ACPITZ_TEMP") - echo "Temperature after stress: $TEMP_AFTER" - if ! [ "$TEMP_AFTER" -gt "$TEMP_BEFORE" ]; then - echo "The temperature after stress testing should be higher than before" - exit 1 - fi + monitor_acpitz_thermal.sh