You are not logged in.

#1 2011-06-11 22:02:03

kveras
Member
From: Uppsala, Sweden
Registered: 2011-03-22
Posts: 54

Need help with temperature script

Hi.

I am trying to create a script that gathers thermal information from my various sensors on my server, and sends it to me via mail once per day. I have managed to generate the content, but I need help with some polishing.

temp.sh

#!/bin/bash

sensors | grep temp && aticonfig --odgt --adapter=0 && aticonfig --odgt --adapter=1

tempmon.sh

#!/bin/bash

echo “Current Temperature Is: $(/home/user/bin/temp.sh)” | mail -s “Thermal_Status” mail@example.com

The output I receive in my mail is this:

“Current Temperature Is: k10temp-pci-00c3 temp1: +32.5°C (high = +70.0°C) temp1: +42.0°C (low = +127.0°C, high = +127.0°C) sensor = thermistor temp2: +35.0°C (low = +127.0°C, high = +127.0°C) sensor = thermal diode temp3: +78.0°C (low = +127.0°C, high = +127.0°C) sensor = thermistor Adapter 0 - AMD Radeon HD 6800 Series Sensor 0: Temperature - 72.00 C Default Adapter - AMD Radeon HD 6800 Series Sensor 0: Temperature - 72.00 C”

I have 2 questions:

1. How can I specify the first script to omit the "k10temp-pci-00c3"-part?
2. How can I generate more readable text? This is all sent to me as one long line of text. However, if I issue the temp.sh in a ssh terminal the information is presented with new lines after every sensor, and distance between the values, making it a lot more readable.

Thank you in advance.

Offline

#2 2011-06-11 22:07:56

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,673
Website

Re: Need help with temperature script

Why not store the output in variable and call it at will.  Example:

#!/bin/bash
mb=`sensors | grep "Mobo" | cut -c16-17`
cpu=`sensors | grep "CPU0 Temp" | cut -c16-17`
hdd=`sudo hddtemp /dev/sda | cut -c34-35`
gpu=`nvidia-smi -q -d TEMPERATURE|grep Gpu|cut -c35-36`
mhz=`cat /proc/cpuinfo  | grep MHz | cut -c12-19`
echo
echo CPU: $cpu °C @ $mhz MHz
echo GPU: $gpu °C
echo M/B: $mb °C
echo HDD: $hdd °C
$ temps

CPU: 47 °C @ 1733.546 MHz
GPU: 53 °C
M/B: 34 °C
HDD: 37 °C

Something more graphically rich (although this isn't what you asked for) if monitorix.  PKGBUILD in AUR.

Last edited by graysky (2011-06-11 22:09:02)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2011-06-12 13:03:37

kveras
Member
From: Uppsala, Sweden
Registered: 2011-03-22
Posts: 54

Re: Need help with temperature script

Thank you Graysky. As usual, you pointed me in the right direction. smile

Will also check out to see what monitorix is.

Cheers.

Offline

#4 2011-06-12 13:51:52

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,673
Website

Re: Need help with temperature script

You're welcome.  Love your avatar - Deadwood was once of HBO's best series.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#5 2011-06-12 13:53:56

kveras
Member
From: Uppsala, Sweden
Registered: 2011-03-22
Posts: 54

Re: Need help with temperature script

graysky wrote:

You're welcome.  Love your avatar - Deadwood was once of HBO's best series.

Totally, I still enjoy watching it through once every year. smile

Offline

Board footer

Powered by FluxBB