#!/usr/bin/perl # # LMCGI - A CGI Script for LM_Sensors # # (C)opyright 1999 Steve Gare # # You May use this code to create your own script as long as you give me # some credit and gimme a copy of whatever you create. # # Suggestions? Bugs? ---> admin@digitald.uk.com # Flames? Hate Mail? ---> /dev/null # # http://www.digitald.uk.com # # SETUP ------------------------------------------------------------------ # ------------------------------------------------------------------------ # Your Chipset Directory (as found in '/proc/sys/dev/sensors') ----------- # ------------------------------------------------------------------------ $chipset = "as99127f-i2c-0-2d"; # ------------------------------------------------------------------------ # Sensors ---------------------------------------------------------------- # ------------------------------------------------------------------------ # This Format: # "FileName , Type , Text Description, Correction (See README)" # Types are: # T for Tempreture # F for Fan # V for Voltage @temps = ( "temp1,T,CPU Temp,0", "temp2,T, Mainboard Temp,0", "fan1,F,CPU Fan,0", "fan2,F,Chassis Fan,0", "in0,V,V Core,0", "in1,V,IO Core,0", "in2,V,3.3V Supply,0", "in3,V,5V Supply,1.68", "in4,V,12V Supply,3.8", "in5,V,12V Return,3.48", "in6,V,5V Return,1.505" ); # ----------------------------------------------------------------------- # Font ------------------------------------------------------------------ # ----------------------------------------------------------------------- $font = "Arial,Helvetica"; $fontsize = "2"; $headersize = "3"; # ----------------------------------------------------------------------- # Text (Don't forget to escape quote's etc (IE bgcolor=\"#fffff\") ------ # ----------------------------------------------------------------------- $refresh = "20"; $title = "Hardware Status"; $sensor = "Sensor"; $value = "Value"; # ----------------------------------------------------------------------- # Files (Must be accessable by user 'nobody in most cases --------------- # ----------------------------------------------------------------------- $header = "/home/httpd/cgi-bin/lmcgi.header"; # ----------------------------------------------------------------------- # Colours --------------------------------------------------------------- # ----------------------------------------------------------------------- $bgcolor = "000000"; $text = "B8A7E1"; $link = "885EF8"; $ok = "B8A7E1"; $warn = "FFFF00"; $panic = "FF0000"; # ----------------------------------------------------------------------- # SETUP Ends Here ------------------------------------------------------- # ----------------------------------------------------------------------- $ver = "1.01"; print "Content-Type: text/html $title "; open(HEADER,$header); print
; close (HEADER); print " "; foreach $e (@temps) { $out = ""; $col=""; $f=""; ($filename, $type, $label, $correct) = split(/\,/,$e,4); open (INFO,"/proc/sys/dev/sensors/$chipset/$filename"); $in = ; chomp($in); ($a,$b,$c)=split(" ",$in); close (INFO); $type = lc $type; if ($type eq "t") { $f = ($c * 1.8) + 32; $out = "$c C ($f F)"; if ($c >= $a) {$col = $panic} elsif ($c >= $b) {$col = $warn} else {$col = $ok} }; if ($type eq "f") { $out = "$b RPM"; if ($b <= $a) {$col = $panic; $out = "$out is too slow"} else {$col = $ok} }; if ($type eq "v") { if ($correct ne "0") { $a = $a * $correct; $b = $b * $correct; $c = $c * $correct; } $out = "$c\V"; if ($c <= $a) {$col = $warn; $out = "$out is too low"} elsif ($c >= $b) {$col = $panic; $out = "$out is too high"} else {$col = $ok} }; print " "; } print "
$sensor $value
$label $out
";