Author Topic: Script for lm_sensors  (Read 4864 times)

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
Script for lm_sensors
« on: January 04, 2007, 05:59:50 pm »
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).

Code: [Select]


#!/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

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
Re: Script for lm_sensors
« Reply #1 on: January 07, 2007, 11:36:22 am »
Quote from: "avajon"
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).

Code: [Select]


#!/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


Nice idea!

but i dont think /usr/pluto/bin/ is the place to store the script as it will likely get overwritten if you re-install.

Andrew

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
Script for lm_sensors
« Reply #2 on: January 07, 2007, 12:07:08 pm »
Hi,

I guess this is important question. And I'd kindly ask Pluto guys to prepare some standard way of contributing. That means that one certain directory should be dedicated to extra apps that will be installed based on suer's wishes. Also some standard procedure for creating proper installation (.deb) files would be fine.

It's always productive to provide ways of convenient contributing - otherwise we will all make hacks in our local systems and noone will really benefit from that....

I know Pluto guys are busy, but maybe this would pay off in really short time.

I'm also thinking to contribute/write few Perl scripts that would sit in background and run certain things (downloading podcasts into media directories for instance), but it would be fine to have somestandard way of adding those to Pluto system so others would benefit from that too....

I think we should try to do things and contact Pluto guys with questions...

Regards,

Rob.

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
Script for lm_sensors
« Reply #3 on: January 07, 2007, 12:46:50 pm »
Quote from: "tinia"
Hi,

I guess this is important question. And I'd kindly ask Pluto guys to prepare some standard way of contributing. That means that one certain directory should be dedicated to extra apps that will be installed based on suer's wishes. Also some standard procedure for creating proper installation (.deb) files would be fine.

It's always productive to provide ways of convenient contributing - otherwise we will all make hacks in our local systems and noone will really benefit from that....

I know Pluto guys are busy, but maybe this would pay off in really short time.

I'm also thinking to contribute/write few Perl scripts that would sit in background and run certain things (downloading podcasts into media directories for instance), but it would be fine to have somestandard way of adding those to Pluto system so others would benefit from that too....

I think we should try to do things and contact Pluto guys with questions...

Regards,

Rob.


Hi Rob,

I totally agree with you. In every way this must a be a good idea and a good approach. Once CES is over maybe this could be looked at.

Andrew

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
Script for lm_sensors
« Reply #4 on: January 07, 2007, 03:11:16 pm »
hi,

i agree with you too. My idea was only: is it possible to do such small scripts - and yes, it works. so it should be a standard way to add such applications... i think there could be a lot of good applications from the plutousers like us.

regards
avajon