Related to my other question, is it possible to parse the latest bandwidth amount (For instance, what I can read manually in cPanel) into PHP?
Asked
Active
Viewed 332 times
1
-
Possible duplicate of [How to get Disk Space Usage and Monthly Bandwidth Transfer from cPanel to my website in PHP](http://stackoverflow.com/questions/6909786/how-to-get-disk-space-usage-and-monthly-bandwidth-transfer-from-cpanel-to-my-web) – richsage Nov 14 '11 at 14:01
-
This unfortunately doesn't allow per-subdomain stats, so not a duplicate. – Marc Fowler Nov 14 '11 at 18:51
1 Answers
0
yes you can. There are many ways. I don't know cPanel so the approaches described further down are generic:
- You can parse the servers log files yourself using PHP. There may be a bunch of ready made classes, maybe even modules doding that out there.
- You may want to explore cPanel and find out if there's an API which tells you that kind of stuff
- You may be able to login to your cPanel and scrape the screen (parse the HTML to get you value)
- If you want the entire traffic of your servers interface, you may want to ask ifconfig (http://blog.kagesenshi.org/2006/03/bandwidth-monitoring-script-through.html)
- If you're using an external counter (e.g. Firewall) find out how you can proble that information from it and use something like Sockets, or simply curl to get it.
I hope one of these ideas may gets you started :)
cu Roman
-
There doesn't seem to be a cPanel API for specifically what I need. Scraping the screen feels like a really hacky solution, although I suppose it is technically possible. As for ifconfig, I do need it to be subdomain-specific. However, parsing the log files sounds reasonable (Although CPU intensive). Do you perhaps have any other ideas? – Marc Fowler Nov 14 '11 at 18:49
-
Specifically, cPanel doesn't seem to let you do it by subdomain, which is integral for me. – Marc Fowler Nov 14 '11 at 18:50
-
Looking for a similar solution have you guys found any solution for this ? – Roop Kumar Sep 12 '16 at 08:59
-
I ended up parsing the access logs I think; it was a super long time ago and I don't recall how I ended up doing it, sorry! – Marc Fowler Sep 12 '16 at 14:41