#!/usr/bin/perl # this script checks server CPU temperature # will send email messages at over temp and subsequently mormal temp # these emails go to the admin account use strict; use warnings; # email setup my $to = 'admin'; my $from = 'root'; my $subject = 'Server Temperature'; my $tlimit = 60; my @file = ("/etc/server-overtemp"); my $msg = 0; my $out = ""; system "cat /proc/cobalt/sensors/thermal | cut -c10-11 > /etc/server-temp"; open (DATA, "/etc/server-temp") || die "couldn't open the file DATA!"; my $cput = ; close (DATA); chomp $cput; if (($cput > $tlimit ) && (-e "/etc/server-overtemp")) { exit 0; }else{ if ($cput > $tlimit) { $out = "The CPU is at $cput max temp is set to $tlimit, consider checking fans or other methods of reducing server load\n\n"; $msg = 1; system "touch /etc/server-overtemp"; } } if (($cput < $tlimit ) && (-e "/etc/server-overtemp")) { $out = "The CPU is now at $cput which is within normal limits\n\n"; $msg = 1; unlink @file; } if ($msg > 0) { open(MAIL, "|/usr/sbin/sendmail -t"); print MAIL "To: $to \n"; print MAIL "From: $from\n"; print MAIL "Subject: $subject\n\n"; print MAIL $out; close(MAIL); } exit 0;