ARCHIVE
LinuxMCE Forums
May 19, 2013, 11:40:55 pm GMT-1 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Rule #1 - Be Patient - Rule #2 - Don't ask when, if you don't contribute - Rule #3 - You have coding skills - LinuxMCE's small brother is available: http://www.agocontrol.com
 
   Home   Help Search Chat Login Register  
Pages: [1]
  Print  
Author Topic: Script for lm_sensors  (Read 929 times)
archived
Hello, I'm new here

Posts: 0


View Profile
« 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:


#!/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
Logged
archived
Hello, I'm new here

Posts: 0


View Profile
« 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:


#!/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
Logged
archived
Hello, I'm new here

Posts: 0


View Profile
« 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.
Logged
archived
Hello, I'm new here

Posts: 0


View Profile
« 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
Logged
archived
Hello, I'm new here

Posts: 0


View Profile
« 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
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Pluto provided a snapshot of their forums with approximately 5,000 posts in February, 2007 when LinuxMCE branched off. Browse those forum posts in the Archive section. Those posts have been included in the search engine and can be found with keyword searches.