00001 #!/bin/bash
00002 #
00003 # sensors.sh
00004 # Retrieves sensors output and formats it for inclusion in the MythTV backend
00005 # status page.
00006
00007 # The following line outputs information to include the CPU temperature
00008 # information in the backend status page. Though the sensors output includes
00009 # the °C unit marker, it is stripped out of the data before being placed in the
00010 # output page, so the display value includes a proper HTML entity.
00011
00012 #sensors | awk '/CPU Temp/ { printf "Current CPU Temperature: %s ℃.[]:[]temperature-CPU[]:[]%s\n", $3, $3 };'
00013
00014 # The following lines output CPU and Motherboard temperature and CPU and Case
00015 # fan speed information. Modify the patterns (i.e. /CPU Temp/) to match the
00016 # sensors output lines containing the data you want to grab (i.e. /Core0
00017 # Temp/). Continue adding lines to the awk program as desired to incude
00018 # additional information.
00019
00020 sensors | awk '
00021 /CPU Temp/ {
00022 printf "Current CPU Temperature: %s ℃.[]:[]temperature-CPU[]:[]%s\n", \
00023 $3, $3
00024 };
00025 /M\/B Temp/ {
00026 printf \
00027 "Current Motherboard Temperature: %s ℃.[]:[]temperature-MB[]:[]%s\n", \
00028 $3, $3
00029 };
00030 /CPU Fan/ {
00031 printf "Current CPU Fan Speed: %s.[]:[]fan-CPU[]:[]%s\n", $3, $3
00032 };
00033 /Case Fan/ {
00034 printf "Current Case Fan Speed: %s.[]:[]fan-case[]:[]%s\n", $3, $3
00035 };
00036 ' | sort
00037
00038 # With appropriate authentication in place (i.e. using SSH Certificate
00039 # Authentication), you may also retrieve sensors data from remote system (i.e.
00040 # slave backends, remote frontends, etc.). Do so with commands of the format
00041 # below (provide an appropriate hostname in place of "slave" (3 places) and
00042 # replace the awk script with one providing the desired information as shown
00043 # above):
00044
00045 #ssh -q slave sensors | awk '/CPU Temp/ { printf "Current CPU Temperature (slave): %s ℃.[]:[]temperature-CPU-slave[]:[]%s\n", $3, $3 };'
00046
00047 # Alternatively, this information could be retrieved from an appropriate
00048 # monitoring program (monit, mrtg) or by using SNMP, depending on the system
00049 # and network configuration.