View Full Version : Bandwidth Monitor
Does anyone know of a script that would effectively do the same job as the bandwidth monitor in whm? Preferably in PHP.
I would like to be able to use a cron job to run it as an early warning for transfer overages.
harmonic
08-19-2002, 11:06 AM
what you would have to do is make it analyze log files.. there is no function that just "knows" how much bandwidth has been use....
otter
08-29-2002, 07:03 PM
Mort look here (http://www.pyroxpro.com/phpapps/) and see if this is something like you are looking for
otter, it doesn't appear to be, but thanks for trying.
As harmonic suggested I would need to access the log files, I beleive that the log that whm uses is just one big log file that contains information on every account on the server.
Firstly, I would imagine that this log is in a location accessable only to root.
Secondly, even if we had access to it, because I would imagine it is a quite large file, I can't imagine it being a good thing if all the customers started parsing that file every few hours or so to pull the information regarding our accounts.
This does raise the question of whether it is this large file that gets updated every time some more bandwidth needs to be added, or whether each whm keeps it's own logs, and if so are these accecable?
My question was mainly based on the fact that whm only checks on bandwidth once every twentyfour hours, which could give someone a good run at going seriously over their bandwidth quota, and I wanted to find a way that I could run a script every few hours to check their bandwidth. I assume that whm runs the check once every twenty four hours, either because it is hard coded into whm and cannot be run more frequently, or is quite heavy on the system resourses, and for that reason is only run once every twenty four hours.
I did breifly look at bandmin and erm mrtg?, however both of these require root access, so I didn't bother looking at them too hard.
I believe insiderhosting use bandmin.
I have spoken to Steven regarding this, and he said he would see if he could find a way. I haven't heard back from him yet, so I assume he has had no luck so far.
Steven
08-29-2002, 11:52 PM
We use mrtg, bandmin as well as WHM to track bandwidth. We are trying to get a script coded where it will update a users bandwidth every hour or so. Mort, you are correct in that we do not want users to really setup a cronjob or something like that to post the information every hour or so. The bandwidth files are accessible by root, and we would like to keep it this way, because we don't want users trying to edit their bandwidth stats, can you imagine that.
-Steven
harmonic
08-30-2002, 03:36 AM
I did notice there is a bandwidth monitor in WHM, and also a "WHM Key" that says it is used for 'scripts being able to access whm' .... maybe that might be of some use?
Harmonic, This is used for what is called the accounting module, why it is called that I don't know, it is a way remotely creating/deleting account, and a few other things, but sady not bandwidth.
see using remote access keys at http://www.cpanel.net/docs.htm
harmonic
08-30-2002, 03:54 AM
you could write a script to read awstats or webalizer generated pages into a string and then perform some regular expression matches to find the bandwidth :o but that would be kind of slow
see the way cpanel has it setup is that if we want to update the bandwidth every couple of hours, we will have to update all the stats for the server. That means everyone's webalizer, awstats, analog, bandwidth and more. This creates a larger load on the server, and it just is poor decision by cpanel developers. The stats are updated around 2am PST every night so it really won't affect the clients that much. We have solicited an outside programmer to try and write a custom script for us that will only update the BW stats, and we are waiting for his reply.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.