hi,
this is my first shell-script. It is a small script to tell me if the CPU is too hot (because my core is in a small room).
#!/bin/bash
. /usr/pluto/bin/SQL_Ops.sh
. /usr/pluto/bin/Config_Ops.sh
typ=$1
grenze=$2
temp=$(sensors |grep $typ |grep +)
echo $temp
declare -i temp1=${temp:6:10}
str='Temperatur von '$typ' ist:'$temp1'!'
echo $str
## Generate a list containig all orbiter ids ($OrbiterIDList)
Q=" SELECT PK_Device
FROM Device
JOIN DeviceTemplate ON PK_DeviceTemplate = FK_DeviceTemplate
JOIN DeviceCategory ON PK_DeviceCategory = FK_DeviceCategory
WHERE
PK_DeviceCategory IN (5,2,3)"
OrbiterList=$(RunSQL "$Q")
OrbiterIDList=""
for Orbiter in $OrbiterList; do
if [[ $OrbiterIDList != "" ]]; then
OrbiterIDList="$OrbiterIDList,"
fi
Orbiter_ID=$(Field 1 "$Orbiter")
OrbiterIDList="$OrbiterIDList""$Orbiter_ID"
done
if [ $temp1 -gt $grenze ]; then
echo ">> $grenze"
/usr/pluto/bin/MessageSend $DCERouter 0 $OrbiterIDList 1 741 159 53 9 "$str"
else
echo "<< $grenze"
fi
Save this on your core (like /usr/pluto/bin/CPU.sh). And now you have to add a Timed Event to call the script every 1 minute. To call the script you have to add the App Server and the Spawn Application Command.
Add the path to your script and as the Parameter CPU and your alarm-level in Celsius. Like this: /usr/pluto/bin/CPU.sh CPU 60.
I hope someone can help me a little bit to make the script better - maybe with some more features... i'm not so good in shell...
best wishes
avajon