Sponsored Content
Full Discussion: Test temperature and alert
Top Forums Shell Programming and Scripting Test temperature and alert Post 303023691 by tomislav91 on Friday 21st of September 2018 03:46:37 AM
Old 09-21-2018
Test temperature and alert

i have this script which result is cpu temp in celsius

first install:

apt-get install lm-sensors
YES |sensors-detect --auto


Code:
#!/bin/bash

# 1. get temperature

## a. split response
## Core 0:       +143.6°F  (high = +186.8°F, crit = +212.0°F)
IFS=')' read -ra core_temp_arr <<< $(sensors -f | grep '^Core\s[[:digit:]]\+:') #echo "${core_temp_arr[0]}"

## b. find cpu usage
total_cpu_temp=0
index=0
for i in "${core_temp_arr[@]}"; do :
    temp=$(echo $i | sed -n 's/°F.*//; s/.*[+-]//; p; q')
    let index++
    total_cpu_temp=$(echo "$total_cpu_temp + $temp" | bc)
done
avg_cpu_temp=$(echo "scale=2; $total_cpu_temp / $index" | bc)

## c. build entry
temp_status="CPU: $avg_cpu_temp F"
#echo $avg_cpu_temp
#echo $[(${avg_cpu_temp}*9/5)+32]
tc=$(echo "scale=2;(5/9)*($avg_cpu_temp-32)"|bc)
echo $tc=$avg_cpu_temp

this give a number like: 54

I want to have some condition, possible in new .sh and test if its ok or not.
For the start I want to tell temp is OK or not, just echo. Then i will figure out how to send to email.
I have something similar but for raspberry and mail function, but here on ubuntu i don't figure out just yet.
 

9 More Discussions You Might Find Interesting

1. HP-UX

temperature records

I'm fairly new to hpux, so this is what i've been trying to figure out. Is it possible to get any logs on hpux that would indicate if the system, cpu, or other hardware components reached above normal or critical temperatures? Thanks, -K (0 Replies)
Discussion started by: uzerx
0 Replies

2. SCO

temperature monitor

Is there command in sco unixware 7.1.3 from which i can find the temperature of the system/hardware. Something equivalent to prtdiag in solaris maybe thanks (1 Reply)
Discussion started by: gsb81
1 Replies

3. Solaris

CPU temperature

Hi all I have a SUN V480 server with 4 processores and I've noticed that the temperature for 2 of the 4 processers are quite high (63 degrees Celsius). Does anyone know what the operating temperatures of the Sparc CPU's are? I'm not getting any warning messages yet, but I want to resolve the... (3 Replies)
Discussion started by: soliberus
3 Replies

4. Filesystems, Disks and Memory

Hard Drive Temperature?

Hi, I just set up a raid Z array in solaris xpress and I notice that the drives feel pretty damn hot. I use speedfan to monitor the temperatures of the hard drives in XP. Is there a similar program for solrais? I assume there would be since the drives all have temp sensors in them, but I... (2 Replies)
Discussion started by: ciscocbee
2 Replies

5. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

6. Solaris

CPU Temperature Details

How to get a CPU temperature and current power consumption in T5220 server both from system controller and Operating system. I need details by cores. Thanks in advance. (13 Replies)
Discussion started by: fugitive
13 Replies

7. UNIX for Dummies Questions & Answers

MAKING A SCRIPT FOR TEMPERATURE

People hello to everybody exist a way to do a script for view the temperature. I have Red Hat Linux release 9 (Shrike) Kernel 2.4.20-8 on an i686 THANk YOU FOR YOUR TIME. (4 Replies)
Discussion started by: enkei17
4 Replies

8. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

9. Solaris

reading temperature again and ipmitool

some say '/usr/sfw/bin/ipmitool' can be used to read temperature. has anyone tried it? what options should be used? (1 Reply)
Discussion started by: orange47
1 Replies
sensors(1)							Linux User's Manual							sensors(1)

NAME
sensors - print sensors information SYNOPSIS
sensors [ options ] [ chips ] sensors -s [ chips ] sensors --bus-list DESCRIPTION
sensors is used to show the current readings of all sensor chips. sensors -s is used to set all limits as specified in the configuration file. sensors --bus-list is used to generate bus statements suitable for the configuration file. OPTIONS
-c, --config-file config-file Specify a configuration file. If no file is specified, the libsensors default configuration file is used. Use `-c /dev/null' to tem- porarily disable this default configuration file. -h, --help Print a help text and exit. -s, --set Evaluate all `set' statements in the configuration file and exit. You must be `root' to do this. If this parameter is not specified, no `set' statement is evaluated. -A, --no-adapter Do not show the adapter for each chip. -u Raw output. This mode is suitable for debugging and for post-processing of the output by scripts. It is also useful when writing a configuration file because it shows the raw input names which must be referenced in the configuration file. -v, --version Print the program version and exit. -f, --fahrenheit Print the temperatures in degrees Fahrenheit instead of Celsius. --bus-list Generate bus statements suitable for using in sensors.conf. Such bus statements are only needed if you have several chips sharing the same address on different buses of the same type. As bus numbers are usually not guaranteed to be stable over reboots, these statements let you refer to each bus by its name rather than numbers. FILES
/etc/sensors3.conf /etc/sensors.conf The system wide configuration file. See sensors.conf(5) for further details. SEE ALSO
sensors.conf(5) AUTHOR
Frodo Looijaard and the lm_sensors group http://www.lm-sensors.org/ lm-sensors 3 November 2012 sensors(1)
All times are GMT -4. The time now is 02:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy