Use PHP with Samba to keep watch on your work units

diabolousmentus

Limp Gawd
Joined
Jun 27, 2002
Messages
203
I have two machines at home folding for me. One is a Linux box with four clients on it (finstall decided to set four up a long time ago) the other is my winbox that runs a 6.22 client and a gpu client. I like to keep track of my home machines because that produce most of the work I'm responsible for. This is an example of what the monitor looks like.

wuprogressdo5.jpg


It works by reading the the unitinfo.txt files from your folding directory and graphs the bars by parsing the current percentage out. I've also had it display the download time so if there is a work unit more than 2 -3 days old I know that something may have went wrong.
 
Very creative setup. I've seen many types of remote monitoring solutions, but yours is by far the most aesthetic one yet.

And I'm sure you know that switching those 4 console clients for 2 SMP clients will give you a pretty good boost in PPD. :D
 

@ diabolousmentus

I whole heartedly agree with brother alan2308 :) As alan2308 said " I've seen many types of remote monitoring solutions, but yours is by far the most aesthetic one yet". I too, have seen a few remote monitoring solutions (ie FAHmon 2.3 2b, FahSpy or SpyFAH or what ever it is, Gkrellm plugins, etc), but yours is the most aesethetic (best lookin' :p) program or script I've seen yet. Please post it.
Thanks in advance.

FOLD ON!

 
I set mine up on an Apache webserver running on Debian Etch With PHP 5. I used samba to access the shares on my Windows box (You wouldn't need to do that if you just wanted to show the progress of clients on the machine that your php is running on).

You'll have two PHP files in the web directory. Your index.php file will have similar code:

--------------------------------

<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<title>The Mike's Page!</title>
</head>
<body>

<?php

//GET VALUES
$cpu1 = file('/root/foldingathome/CPU1/unitinfo.txt'); //local machine
$cpu2 = file('/root/foldingathome/CPU2/unitinfo.txt'); //local machine
$cpu3 = file('/root/foldingathome/CPU3/unitinfo.txt'); //local machine
$cpu4 = file('/root/foldingathome/CPU4/unitinfo.txt'); //local machine
$cpu5 = file('/mnt/buzz/F1/unitinfo.txt'); //windows box shared and accessed via Samba
$gpu1 = file('/mnt/buzzgpu/unitinfo.txt'); //windows box shared and accessed via Samba

//PERCENTAGES LINES
$s_cpu1 = strval($cpu1[5]);
$s_cpu2 = strval($cpu2[5]);
$s_cpu3 = strval($cpu3[5]);
$s_cpu4 = strval($cpu4[5]);
$s_cpu5 = strval($cpu5[5]);
$s_gpu1 = strval($gpu1[6]);

//PARSE OUT PERCENTAGE VALUES
$val1 = substr($s_cpu1, 9, -16);
$val2 = substr($s_cpu2, 9, -16);
$val3 = substr($s_cpu3, 9, -16);
$val4 = substr($s_cpu4, 9, -16);
$val5 = substr($s_cpu5, 9, -16);
$val9 = substr($s_gpu1, 9, -16);

//DOWNLOAD TIMES
$dt1 = strval($cpu1[3]);
$dt2 = strval($cpu2[3]);
$dt3 = strval($cpu3[3]);
$dt4 = strval($cpu4[3]);
$dt5 = strval($cpu5[3]);
$dt9 = strval($gpu1[4]);

//WORK UNIT NAMES
$name1 = strval($cpu1[2]);
$name2 = strval($cpu2[2]);
$name3 = strval($cpu3[2]);
$name4 = strval($cpu4[2]);
$name8 = strval($cpu8[2]);

?>
<h1 class="mono">Current Work Units</h1>
<table align="center" width="1000">
<th>bruce</th><th>buzz gpu</th><th>buzz</th>
<tr>
<td class="datacell"><?php echo "<img src='graph.php?per=$val1' alt='$val1%' /><br />$dt1<br />"; ?></td>
<td class="datacell"><?php echo "<img src='graph.php?per=$val9' alt='$val9' /><br />$dt9<br />"; ?></td>
<td class="datacell"><?php echo "<img src='graph.php?per=$val5' alt='$val5' /><br />$dt5<br />"; ?></td>
</tr>
<tr>
<td class="datacell"><?php echo "<img src='graph.php?per=$val2' alt='$val2%' /><br />$dt2<br />"; ?></td>


</tr>
<tr>
<td class="datacell"><?php echo "<img src='graph.php?per=$val3' alt='$val3%' /><br />$dt3<br />"; ?></td>


</tr>
<tr>
<td class="datacell"><?php echo "<img src='graph.php?per=$val4' alt='$val4%' /><br />$dt4<br /><br />"; ?></td>


</tr>
</table>


</body>
</html>

-------
The other file in this case would be named graph.php and is as follows:
NOTE: There are several different ways of doing this but this is the path I used.
-------

<?php
$per = imagecreate(302,52);
$background = imagecolorallocate($per, 0x00, 0x00, 0x00);
$foreground = imagecolorallocate($per, 0x00, 0x8A, 0x01);
$border = imagecolorallocate($per, 0x99, 0x99, 0x99);
if ($_GET['per'] > 0)
{
$grad = imagecreatefrompng("images/grad1.png");
$per2 = imagecopy($per, $grad, 0, 0, 0, 0, ($_GET['per'] * 3), 50);
imagerectangle($per, 0, 0, 300, 50, $border);
}
header("Content-type: image/png");
imagepng($per, NULL, 5);
?>

--------
This is the image I used for the bar graph:
grad1mb3.png
 
Lovely, it is a great way to monitor boxens :)

 
I was looking for something to monitor my boxes per box and keep track of the projects they were getting,also actual complete units per day per box,ect in a data base, I saw many things for bionic, but non for FAH, I got a programer buddy who could make it but hes not a folder adn lazy.LOL
 
This code could definately be improved upon, have features added to it, so on and so forth. I would appreciate if anyone comes up with anything else to post it in this thread to share. I've thought of some things to add, such as counters, but with work and family I stopped. I may eventually add more to it to spice it up some and if so will post the additional code/instructions.

Fold On!
 
Back
Top