Web Hosting Talk







View Full Version : 1 day server stats script


Félix C.Courtemanche
10-08-2001, 05:47 PM
Hey,

I just made this 1day-stat graph program for use with web.cp, the control panel I am building.

I figured this might be usefull or interesting to a lot of people to have this info. Check the 4 available graphs right now (more will come as time pass): http://www.can-host.com/php/tfx.html

Graphs are rendered on the fly, and no, it definately does not compete with MRTG :) This is for a single system only, to be used locally (although it could eaily be expanded for multiple servers)

Well... enjoy and let me know if you have anysuggestion.

ReliableServers
10-08-2001, 06:08 PM
Looks good. Just one suggestion, on the graphs maybe use some more contrasting colors to its easier to tell them apart :)

Félix C.Courtemanche
10-08-2001, 06:29 PM
Do you have suggestions for 4 colors that are nice on white?

If possible, give me the RGB info :) I am open to suggestions.

cperciva
10-08-2001, 06:34 PM
Probably a dumb question, but... why go to all this work when you yourself say that MRTG is better?

Félix C.Courtemanche
10-08-2001, 07:22 PM
There are a few differences between MRTG and this.

First of all, I needed a stat tool for web.cp, because I cannot assume everyone can use MRTG.

Secondly, in our configuration, MRTG reports are backward and don't show RAM usage or CPU time info anyway. This little script combine the 4 info on 1 graph, which makes it usefull to track events.

It will eventually be much better than right now, but I figured it might be usefull, seeing it works from any account that has PHP with GDlib (png format).

Its easy to setup & use, MRTG is less :)

cperciva
10-08-2001, 07:31 PM
It is easy to reverse the direction of the MRTG graphs; in the unlikely event that my memory is correct, I think the appropriate configuration line is "Options[_]: growright".

As for plotting memory and CPU usage, MRTG will plot whatever data you feed it. It is trivial to write a script to feed the latest CPU + Memory usage data to MRTG; it is equally easy to plot the current number of Apache processes, the free disk space... whatever. MRTG may have been originally designed for plotting traffic, but it is certainly not restricted to that.

I'm not trying to say that your code isn't useful; all I'm saying is that this could probably have been done with much less effort via MRTG.

teck
10-08-2001, 11:52 PM
So I take it that it won't work on Cpanel boxes huh? Damn! Maybe you can whip something up :)

dektong
10-09-2001, 12:08 AM
strange, I don't have php executable (for /usr/bin/php part) and I have searched anywhere to no avail ... hm .... strange!

Felix, you definitely had what I have been thinking of doing! Good job! Now if I can find that php executable ...

cheers,
:beer:

Félix C.Courtemanche
10-09-2001, 03:28 AM
Wrong!

All you need is PHP4 with GD lib compiled... That mean the latest versions if possible, but that should not be especially hard to find.

if you cannot run the php scrip from cgi (i.e you do not have the php executable on your system), remove the #!/usr/bin/php -q line and check the script through a browser. This is far less than optimal, but it can work.

Unrelated, I fail to understand how a free web hosting administration script is a request... oh well :)

Starhost
10-09-2001, 05:05 AM
Felix, your script is great. But I have a problem. Afther a while tfxgraph.php isn't working anylonger. Because the script want to devide a number by 0 online 45.
When I remove /var/log/eth.transfer everything is working alright (again) but then I've lost the stats. Do you know what went wrong?

teck
10-09-2001, 05:01 PM
I don't have eth.transfer either :( But then again, my machine is CP/WHM based.

dektong
10-09-2001, 05:40 PM
Originally posted by Félix C.Courtemanche
if you cannot run the php scrip from cgi (i.e you do not have the php executable on your system), remove the #!/usr/bin/php -q line and check the script through a browser. This is far less than optimal, but it can work.


Hm ... but then don't you need to have this script run every minute to get the values of free memory, CPU load, etc every minute?

BTW, I do have the latest php (as apache module) with gdlib compiled.

cheers,
:beer:

dektong
10-09-2001, 05:40 PM
Originally posted by teck
I don't have eth.transfer either :( But then again, my machine is CP/WHM based.

I think the file eth.transfer is generated by the script. If you do not run source.php, then you won't get that file...

cheers,
:beer:

Félix C.Courtemanche
10-09-2001, 08:52 PM
Exactly,

If you remove the #! line, you will wtill need to run it from cron at every minute to gather data... there is no way around it, it can't be done magically :)

eth.php GATHERS the system data
tfxgraph.php RENDERS the system data into graphs.

You need both, correctly installed...

I am not sure with those having problems, it has been working for a few days without any error here.

Of course, the script is not 'easy' to setup... if you don't know anything about web hosting. And if it's the case, you don't need this anyway :)

ReliableServers
10-09-2001, 11:45 PM
Possible to get this to work with freebsd?

Félix C.Courtemanche
10-10-2001, 02:40 AM
Well, the script gathers information taken from standard linux commands:
free -mo
uptime

and information from /proc/net/dev

Basically, eth.php is pretty much platform specific, but it can be modified to gather from any ways. As long as the raw data logged keeps the same format, tfxgraph.php will be able to graph it correctly.