Steve Scrimpshire Posted October 17, 2003 Report Share Posted October 17, 2003 Going off of this concept I talk about here: http://www.mandrakeusers.org/viewtopic.php...namic+signature I adjusted it to be an avatar (this board's bbcode in sigs is messed up) to show my temps, too, because of my cool state-of-the-art MoBo that has sensors on it. Here's the whole script <?php Header ("Content-type: image/png"); Header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); Header("Expires: Thu, 19 Nov 1981 08:52:00 GMT"); Header("Pragma: no-cache"); $ut = strtok( exec("cat /proc/uptime"), "." ); $cputemp = exec("cat /proc/sys/dev/sensors/it87-isa-0290/temp1"); $cputemps = explode(" ",$cputemp); $roundcpu = explode(".",$cputemps[2]); $mobotemp = exec("cat /proc/sys/dev/sensors/it87-isa-0290/temp2"); $mobotemps = explode(" ",$mobotemp); $roundmobo = explode(".",$mobotemps[2]); $days = sprintf( "%2d", ($ut/(3600*24)) ); $days = trim($days); $hours = sprintf( "%2d", ( ($ut % (3600*24))/3600) ); $hours= trim($hours); $min = sprintf( "%2d", ($ut % (3600*24) % 3600)/60 ); $min = trim($min); $recorduptime= "uptimebest"; $fp2 = isset($fp2) ? $fp2 : fopen("$recorduptime",'r'); $fp2 = fopen("$recorduptime",'r'); flock ($fp2,1); $best= fread ($fp2, filesize ($recorduptime)); flock($fp2,3); fclose($fp2); $record = explode("|",$best); if ($days > $record[0]){ $fp2 = fopen("$recorduptime",'w'); flock ($fp2,2); fwrite($fp2,"$days|$hours|$min"); flock($fp2,3); fclose($fp2); } if ($days == $record[0]){ if ($hours > $record[1]){ $fp2 = fopen("$recorduptime",'w'); flock ($fp2,2); fwrite($fp2,"$days|$hours|$min"); flock($fp2,3); fclose($fp2); } if ($hours == $record[1]){ if ($min >= $record[2]){ $fp2 = fopen("$recorduptime",'w'); flock ($fp2,2); fwrite($fp2,"$days|$hours|$min"); flock($fp2,3); fclose($fp2); } } } $fp2 = fopen("$recorduptime",'r'); flock ($fp2,1); $best= fread ($fp2, filesize ($recorduptime)); flock($fp2,3); fclose($fp2); $record = explode("|",$best); $days = "$days"."d"; $hours = "$hours"."h"; $min = "$min"."m"; $dayz = "$record[0]"."d"; $hourz = "$record[1]"."h"; $minz = "$record[2]"."m"; $roundcpu[0] = $roundcpu[0] + 3; $realcpu = "$roundcpu[0]"."°C"; $realmobo = "$roundmobo[0]"."°C"; $img = imagecreatefrompng("button.png"); $bg = ImageColorAllocate($img, 211, 211, 211); $text_color = ImageColorAllocate ($img, 255, 255, 255); $title_color = ImageColorAllocate ($img, 205, 205, 205); ImageString($img, 3, 57, 25, "Uptime", $title_color); ImageString($img, 3, 48, 38, "$days $hours $min", $text_color); ImageString($img, 3, 36, 58, "Record Uptime", $title_color); ImageString($img, 3, 48, 71, "$dayz $hourz $minz", $text_color); ImageString($img, 3, 20, 108, "CPU", $title_color); ImageString($img, 3, 17, 121, "$realcpu", $text_color); ImageString($img, 3, 115, 108, "MoBo", $title_color); ImageString($img, 3, 115, 121, "$realmobo", $text_color); ImagePNG($img); ImageDestroy($img); ?> Of course this line: $img = imagecreatefrompng("button.png"); pulls from the background image I mad with Gimp named button.png and plced it in the same directory. I got the info for the sensors from installing the lm_sensors package and running sensors-detect. Your path to the two temps are going to be named differently depending on the MoBo sensor. Of course, the adjustment I make to the CPU temp (+3) is only because Linux reports the temp 3 degrees lower than the BIOS does. Quote Link to comment Share on other sites More sharing options...
paul Posted October 17, 2003 Report Share Posted October 17, 2003 nice work !!!! Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted October 17, 2003 Author Report Share Posted October 17, 2003 Uh, thanks. I wasn't fishing for compliments. ;) I posted this because someone PM'ed me asking about it and I thought it would be useful for others to know, too. Plus, I thought that when I tried to send him a PM with the code in it that it didn't go because I didn't see it in my sent box until like ten minutes after I sent it. :D Quote Link to comment Share on other sites More sharing options...
paCkeTroUTer Posted October 17, 2003 Report Share Posted October 17, 2003 that someone was me :wink: unfortunately I can't get this to work as none of the monitoring files in /proc have any info in them(0 bytes). Anyone knows whats going on here ? Quote Link to comment Share on other sites More sharing options...
paCkeTroUTer Posted October 17, 2003 Report Share Posted October 17, 2003 just an other update to my problem. I understood from one of Steve Scrimpshire's pm that I had to install lm_sensors to get the sensors active. While I was installing it via MCC >> install packages... it picked up a couple of other dependencies, ksensors-0.7.2-4mdk.i586.rpm and liblm-sensors1-2.7.0-2mdk.rpm I installed all 3 and then did a re-boot(not knowing if i had to) and then when I logged-in I found a programme called ksensor start automatically. I realised it was the rpm package I just installed. I then configure it and I see some graphical displays of my system... swp, cpu state, up time, ram, etc So that means the sensor is working. ... but my problem is still with the /proc sensor files containing nuthing in there. Could anyone be able to shed some light on this ? Quote Link to comment Share on other sites More sharing options...
paCkeTroUTer Posted October 19, 2003 Report Share Posted October 19, 2003 anyone help :roll: :? Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted October 20, 2003 Author Report Share Posted October 20, 2003 You might want to post a new topic about this. BOT: My avatar that this topic refers to is temporarily offline until I move. I had to move the cable modem over to the Win2K computer here which will not forward ports properly. My avatar should return next week when I get back to Mississippi and get all settled in. Edit: As you can now see...my avatar is back. :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.