[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cobalt-users] Faster Source for Fans?



Thanks for the store links, everybody.

> Could you share the script that you use to get paged 
> when the servers over heat... Sounds like a good idea 
> to me... I have a RaQ3 & RaQ4

Certainly, though this is very rudimentary code, and there may be
bugs... Obviously there's no warranty expressed or implied, and you can
consider this public domain.

Simply cut and paste this into a script on your cobalt, and make the
appropriate changes (such as the pager email address).

---- tempwatch.pl ----
#! /usr/bin/perl -w
# Crude script to watch a RaQ4's cpu temperature.
# 
# Fred Damstra
# Think Extreme, Inc.
# fdamstra@xxxxxxxxxxxxxxxx
use strict;

my $threshold = 60; # Page if over this temperature (Celsius)
my $buffer    = 10; # page again if the temperature has continued to
rise.
my $delay     = 30; # number of seconds between checks
my $Debug = 1;

my $lasttemp = 0;
my $curtemp;

while(1) {
	sleep $delay;
	open CPUINFO, "< /proc/cpuinfo" or die "Could not open
cpuinfo.";
	while(<CPUINFO>) {
		chomp;
		$curtemp = $1 if(/^temperature\s*:\s*(.*)$/);
	}
	close CPUINFO;

	next if(!$curtemp); # exit if no temperature
	
	print "Current temp: $curtemp\n" if($Debug);

	if($curtemp > $threshold) {
		# We're hot.  
		print "Over threshold.\n" if $Debug;
		next if(($curtemp - $lasttemp) < $buffer);
		print "Paging.\n" if $Debug;
		open PAGER, "| /bin/mail 6165551212\@page.nextel.com";
		print PAGER "Blue's is hot!  Current temperature is
$curtemp.\n";
		close PAGER;
	}
	$lasttemp = $curtemp;
}