PHP Driven Stats

This forum contains information about 3rd party applications which may be of use to those who run the FAH client and one place where you might be able to get help when using one of those apps.

Moderator: Site Moderators

Post Reply
ericbarch
Posts: 4
Joined: Sun Oct 19, 2008 5:10 am

PHP Driven Stats

Post by ericbarch »

Not sure if anyone would be interested in this quick script I threw together but I figured I'd post it to see if anyone would like to see it released:

http://andrew.ericbarch.com/~eric

All you have to do is point it to the directories where your F@H unitinfo.txt is located and it will parse it and display the info (with the choosing of your label).

It's only 50 lines of code, so it's not a whole lot...but if there's enough interest I'll consider putting up the source code for download.

What does everyone think?

EDIT:

I'm going to go ahead and release the source (please post cool mods and updates you make...I know the script is super basic right now.)

Source Code:
http://andrew.ericbarch.com/~eric/index.php.txt
Last edited by ericbarch on Fri Nov 28, 2008 10:28 pm, edited 2 times in total.
toTOW
Site Moderator
Posts: 6309
Joined: Sun Dec 02, 2007 10:38 am
Location: Bordeaux, France
Contact:

Re: PHP Driven Stats

Post by toTOW »

Simple and efficient ;)

Just a little question : how do you host your stats ? Do you need a local webserver ? or do you have to upload to host the results somewhere ?
Image

Folding@Home beta tester since 2002. Folding Forum moderator since July 2008.
ericbarch
Posts: 4
Joined: Sun Oct 19, 2008 5:10 am

Re: PHP Driven Stats

Post by ericbarch »

It's just hosted on a local apache webserver for simplicity...but if you wanted to use 1 server as your "stat" server you could always have your machines just auto-FTP the unitinfo.txt files to the stat server and have that machine generate the progress page with PHP.
parkut
Posts: 364
Joined: Tue Feb 12, 2008 7:33 am
Hardware configuration: Running exclusively Linux headless blades. All are dedicated crunching machines.
Location: SE Michigan, USA

Re: PHP Driven Stats

Post by parkut »

Nicely done Eric
BuddhaChu
Posts: 77
Joined: Wed Apr 16, 2008 2:38 am

Re: PHP Driven Stats

Post by BuddhaChu »

In case this gets popular and for efficiency sake, I'd suggest switching to a stylesheet rather than inline styles. That would reduce the amount of text sent to the client.

gj n1 ;)
BuddhaChu
Posts: 77
Joined: Wed Apr 16, 2008 2:38 am

Re: PHP Driven Stats

Post by BuddhaChu »

I went ahead and did a stylesheet for you...

- break tags are now closed (helps when coding in XSL...all tags must be closed...a good habit to get into)
- since I assume you're doing some math to calculate the white part of the progress bars, I left that style inline so you can drop in the % complete number
- specifying a font color for the .bar class is redundant (since your body text is white and so is the text in the progress bar) but it'll make it easier to change it in the future (if needed)
- got rid of a bunch of < span > tags that weren't being used (in the "Core x" lines and other places). The span tags weren't being closed, so I knew they weren't used at all.

Only ~9% reduction in size, but stylesheets make changing the look so much easier plus the PHP code will be easier to edit (less HTML mixed in with the PHP). For example, to change the color of the progress bars, you now have to change only one thing, not the same thing in four places.

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>F@H Stats</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<meta http-equiv="refresh" content="60">

<style type="text/css">
<!--
body {background-color:#000000; font-family:arial; font-size:12px; color:#FFFFFF;}
.header {font-size:28px; font-weight:bold;}
.box {width:300px; background-color:#CCCCCC;}
.bar {background-color:#0000CC; color:#FFFFFF;}
.uptime {font-size:13px;}
.footer {font-size:10px;}
-->
</style>
</head>

<body>
<div class="header">F@H Stats - PHP Edition</div>
<br /><br />
<b>Core 1</b><br />Name: p896_p53longpeptides_GB


<br />Download time: October 20 07:29:30
<br />Due time: December 6 07:29:30
<br /><div class="box"><div class="bar" style="width:51px;">&nbsp;17%</div></div><br /><b>Core 2</b><br />Name: p896_p53longpeptides_GB
<br />Download time: October 19 23:46:49
<br />Due time: December 5 23:46:49
<br /><div class="box"><div class="bar" style="width:120px;">&nbsp;40%</div></div><br /><b>Core 3</b><br />Name: p895_p53peptides_gb
<br />Download time: October 19 23:59:43
<br />Due time: December 3 23:59:43
<br /><div class="box"><div class="bar" style="width:153px;">&nbsp;51%</div></div><br /><b>Core 4</b><br />Name: p895_p53peptides_gb
<br />Download time: October 20 04:13:21
<br />Due time: December 4 04:13:21


<br /><div class="box"><div class="bar" style="width:108px;">&nbsp;36%</div></div><br /><span class="uptime"> 09:22:57 up 4 days, 14:12,  0 users,  load average: 4.00, 3.99, 3.91</span><br />
<span class="footer">Page auto-refreshes every 60 seconds. Engine by <a href="http://ericbarch.com">Eric Barch</a>.</span>

</body>
</html>
ericbarch
Posts: 4
Joined: Sun Oct 19, 2008 5:10 am

Re: PHP Driven Stats

Post by ericbarch »

Sweet, thanks for the suggestions. I've implemented most of it now and I'm going to go ahead and release the source (please post cool mods and updates you make...I know the script is super basic right now.)

Here's the working demo:
http://andrew.ericbarch.com/~eric/index.php

Source Code:
http://andrew.ericbarch.com/~eric/index.php.txt
Post Reply