#!/usr/bin/perl -w # sensors.pl - a sensors client for LCDproc # # This client for LCDproc displays the tail of a specified file. # It's possible to change the visible part of the file with LCDproc # controlled keys # # # Copyright (c) 1999, William Ferrell, Scott Scriven # 2001, David Glaude # 2001, Jarda Benkovsky # 2002, Jonathan Oxer # 2002, Rene Wagner # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # any later version. # # This file is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this file; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # use Encode; use LCDd; ############################################################ # Configurable part. Set it according your setup. ############################################################ # Host which runs lcdproc daemon (LCDd) $HOST = "localhost"; # Port on which LCDd listens to requests $PORT = "13666"; # Seconds between sensor read $WAIT = 5; ############################################################ # End of user configurable parts ############################################################ # Connect to the server... $lcd = LCDd->new( server => $HOST, port => $PORT, name => "Sensors" ) || die "Cannot connect to LCDproc port\n"; # Set up some screen widgets... $screen = LCDd::Screen->new( $lcd, name=>"Sensors" ); $widget[0] = LCDd::Title->new( $screen, title=>"SENSORS"); # Infinite loop to update while(1 == 1) { # Get sensors data: requires lmsensors, hddtemp and nvclock $sys = substr(`sensors | grep temp1 | awk '{print \$2}'`, 1, 2); $mhc = substr(`sensors | grep temp3 | awk '{print \$2}'`, 1, 2); $cpu = substr(`sensors | grep temp2 | awk '{print \$2}'`, 1, 2); $gpu = substr(`nvclock -T | grep temperature | awk '{print \$4}'`, 0, 2); $sda = substr(`/usr/sbin/hddtemp /dev/sda | awk '{print \$3}'`, 0, 2); $sdb = substr(`/usr/sbin/hddtemp /dev/sdb | awk '{print \$3}'`, 0, 2); $fan = `sensors | grep fan1 | awk '{print \$2}'`; $fan =~ s/\s+$//; # Creates each line $lines[1] = "SYS: $sysøC MHC: $mhcøC"; $lines[2] = "CPU: $cpuøC GPU: $gpuøC"; $lines[3] = "SDA: $sdaøC SDB: $sdbøC"; $lines[4] = "FAN: $fan rpm"; # Prints in LCD for($i = 0; $i < @lines; $i++) { $widget[$i] = LCDd::String->new( $screen ); $widget[$i]->set(x=>1, y=>($i + 1), text=>decode("utf-8", $lines[$i])); } # Wait sleep($WAIT); }