Syphic
07-10-2009, 04:04 AM
Is there a way to monitor how much bandwidth is used by each user under home with php?
I had the idea of making a site that people would add $xx amount and then it would take out of that amount according to the space and bandwidth they used each month.
I am looking into rddtools but it seems to do graphs not the data itself.
alons
07-10-2009, 06:03 AM
Many control panels have it inbuilt.
Which one are you using ?
Its not possible through PHP alone.
PHP doesnt cover images, txt files, audio and video.
Matt R
07-11-2009, 10:52 AM
You can do it in php, but you would still need to interface it with something else. PHP is unable to retrieve information about the server in most production servers as methods such as "exec" are disabled for [obvious] security reasons.
Your best bet would be to write a shell script that gathers the information, dumps it into a file (csv, xml, etc...) and the php script just parses that file.
It's not for the average user on a shared account, but for a server administrator it might be more useful than the standard WHM readouts as the only way to get truly detailed information about an account is to log into that accounts cPanel account and check AWStats or a similar script (which works pretty much the way I mentioned above).
Syphic
07-11-2009, 02:42 PM
Thank you, that is what I figured I would have to do. I do have a VPS at the moment but will have to figure out how to calculate the bandwidth and space according to the logs.
Layershift Damien
07-14-2009, 12:33 PM
You'd need to parse the access logs from Apache (or other web server), or otherwise the only other way I can think of would be to analyse the traffic as it comes in (a kind of virtual ethernet device): though just for a web server you could potentially do it by a sort of reverse proxy thing (obviously PHP isn't best placed to handle that - you'd need to write something in C or similar I suppose).
There's a reason why most/all control panels do this by parsing logs, and if you think about how to go about the two options I mentioned I think it's pretty clear :)