Sensors in terminal?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Sensors in terminal?
# 1  
Old 04-09-2009
Sensors in terminal?

I just installed lm-sensor in my terminal and it's working, however i really don't know how to analyze what I have, Any help will be appreciated, Thanks
Here is the reading in my terminal,
sensors
acpitz-virtual-0
Adapter: Virtual device
temp1: +40.0°C (crit = +124.0°C)

k8temp-pci-00c3
Adapter: PCI adapter
Core0 Temp: +7.0°C
Core0 Temp: -3.0°C
Core1 Temp: -3.0°C
Core1 Temp: +2.0°C ________________
# 2  
Old 04-10-2009
You could setup a cron job that runs lm-sensor and puts the into a temporary log file and then continue in the same script to compare the values given with what the upper thresholds should be, e.g. using the temp1 line:
Code:
lm-sensor > ${TEMPFILE} 2>&1
TEMP=`grep temp1 ${TEMPFILE} | awk '{ print $2 }' | sed -e 's/+//' | awk -F"." '{ print $1 }'`
THRESHOLD=`grep temp1 ${TEMPFILE} | awk '{ print $5 }' | sed -e 's/+//' | awk -F"." '{ print $1 }'`
if [ ${TEMP} -ge ${THRSHOLD} ]; then
  logger -p local0.crit2 "temp1 is too high!"
fi

Crude and only handles integer temperatures.
The logger line could of course send an email.
# 3  
Old 04-10-2009
I'm sorry I'm too new to get what you've written, I'm totaly new.
Thanks
# 4  
Old 04-11-2009
Okay, if you save the above script as say /usr/local/sbin/lm_sensor_temperature_check.sh with the lines:
#!/bin/ksh
or
#!/bin/bash
as the very first line to specify what shell the script is to run in. Run:
Code:
# chmod 500 /usr/local/sbin/lm_sensor_temperature_check.sh

to make it executable.

Add a line to root crontab to run this script once an hour do the following:
Code:
# crontab -l > /tmp/root.crontab
# echo "0 * * * * /usr/local/sbin/lm_sensor_temperature_check.sh" >> /tmp/root.crontab
# crontab  /tmp/root.crontab

This will now run every hour and if the temp1 line from lm_sensor indicates that the measured temperature is above the 124 critical temperature then it will add a line to the /var/log/syslog log file (check the /etc/syslog.conf log to confirm where the alarm you select gets logged to) that you can then get HP OVO of BMC patrol (or whatever system monitoring software you are using) to look for the "temp1 is too high" string and raise an alert, or else you could replace the "logger -p" line in the script with a line to send an email somewhere, e.g.:
Code:
echo "ALERT: The measured temperature of ${TEMP} is great then critical temp. of ${THRSHOLD}." > /tmp/temp.log
mailx -s "Machines `uname -n` temperature is too high" user@foo.com < /tmp/temp.log


Last edited by TonyFullerMalv; 04-11-2009 at 11:52 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Trying monitor of sensors through smartphones

I was able to enable the Mosquitto MQTT using instructable Now I need to communicate my new wireless sensor to communicate with Mosquito in such a way that it will display tracker in which it shows the readings of sensor, Also need to know how can to display the notification on smartphones... (0 Replies)
Discussion started by: Brandy85
0 Replies

2. Shell Programming and Scripting

Print Terminal Output Exactly how it Appears in the Terminal to a New Text File

Hello All, I have a text file containing output from a command that contains lots of escape/control characters that when viewed using vi or view, looks like jibberish. But when viewed using the cat command the output is formatted properly. Is there any way to take the output from the cat... (7 Replies)
Discussion started by: mrm5102
7 Replies

3. Shell Programming and Scripting

Cannot get terminal application to launch with a graphical launcher when successful in terminal

I have been having an extremely annoying problem. For the record, I am relatively new at this. I've only been working with unix-based OS's for roughly two years, mostly Xubuntu and some Kali. I am pretty familiar with the BASH language, as that's the default shell for debian. Now, I've made this... (16 Replies)
Discussion started by: Huitzilopochtli
16 Replies

4. UNIX for Dummies Questions & Answers

Does DOS has a terminal or pseudo terminal?

I am wondering if the DOS console works like the unix terminal? (1 Reply)
Discussion started by: vistastar
1 Replies

5. UNIX for Dummies Questions & Answers

Sensors Explanations

Hello, I am trying to get some information from the sensors on my pc. But i get confuse with what i get. I don t know where to find out which sensors watches what.. I use "sensors" under ubuntu 10.10. Here is the result of the cmd line sudo sensors. the temp 3 indicates 79°C which... (0 Replies)
Discussion started by: Mat_k
0 Replies

6. Shell Programming and Scripting

Need help with Expect script for Cisco IPS Sensors, Expect sleep and quoting

This Expect script provides expect with a list of IP addresses to Cisco IPS sensors and commands to configure Cisco IPS sensors. The user, password, IP addresses, prompt regex, etc. have been anonymized. In general this script will log into the sensors and send commands successfully but there are... (1 Reply)
Discussion started by: genewolfe
1 Replies

7. UNIX for Dummies Questions & Answers

Gnuplot wxt terminal vs x11 terminal

Hi, I installed ubuntu recently on my pc. And I installed gnuplot as well. When I first started working with gnuplot it was working . I did a plot and when I wanted to fit my data something happened and not the default terminal of gnuplot is xwt! I changed it to: set terminal x11, but it... (0 Replies)
Discussion started by: cosmologist
0 Replies

8. UNIX for Advanced & Expert Users

Pseudo-terminal will not be allocated because stdin is not a terminal.

I am trying to automate a SSH login using Keys using the following command ssh -i id_rsa usernamw@ipaddr. I am successful in doing this and i am getting the Warning Screen and I logon successfully. but when I am executing the command tail -1cf put.dat | ssh -i id_rsa username@ipaddr > get.dat ... (1 Reply)
Discussion started by: Shivdatta
1 Replies

9. UNIX for Advanced & Expert Users

connecting to unix through hyper terminal - as a dumb terminal

I just changed from windows NT to XP and I am no longer able to connect to my unix system. I used to use hyper terminal -- which acts as dumb terminal to my main frame unix system. I think one of the options used to be "direct to comX". This option isn't listed now. I use a serial port and the... (2 Replies)
Discussion started by: michelle
2 Replies
Login or Register to Ask a Question