I've seen various online applications that show a percentage bar of an accounts bandwidth usage. For instance, some web host providers display a guage or a meter showing how close an acccount it to reaching their alloted bandwidth limit.

It there a way of coding something like this to put into m own application? I first though to install my own copy of Awstats and somehow extract that particular data pertaining to bandwidth usage into php so that I can display it as a percentage bar. But thats not working out and it really weighs down my application to have an additional install of awstats.

Any thoughts?

    What's your question? How to determine bandwidth usage via PHP? Where do you propose PHP gathers that information from?

      from a database obviously or xml or text file....I notice that cpanel logs this in a byte-log per domain...but I cant access it above the public folder right?

      I successfully worked out the disk space usage...now I need a bandwidth meter too lol. Diskspace usage was far easier...but since the only logs that the server keeps of bandwidth are

      A) in the cpanel byte-log (bandwidth stats)
      😎 Awstats plugin shows bandwidth

      Then im not sure of the best way and most efficient way to go about calling this info into php..im used to database queries mostly.....

        storyboo wrote:

        but I cant access it above the public folder right?

        Maybe.. what do you mean by "above the public folder" ? If the log can be read by cPanel, then there's a good chance that you can read it as well in a PHP script. As I don't have cPanel, however, I'm not sure where it stores such log files nor do I have any insight as to how permissions are setup on your server.

          the log files are stored in the root of the domain...not under the public www folder...which means that cpanel access is needed to view bandwidth...but want to eliminate the need of having a cpanel login for anything for my customers...and have everything all in on area...this is one of the last things to address.

            PHP isn't limited to only accessing files that reside within the root of your website... (assuming, of course, that open_basedir hasn't been used)

              I dont have that restriction...I have the software (shopping cart) set up so that it sends mail etc. So that means that that is available...but im lost as to how to go about getting to that byte log and when i get there what the hell to do with it in php lol

                storyboo wrote:

                how to go about getting to that byte log

                Well you'd have to know the filepath to the location where the cPanel logs are stored. That'd be something you'd either have to poke around in cPanel to find it or, more likely, ask your host.

                storyboo wrote:

                what the hell to do with it in php

                Again, since I don't have cPanel I don't have any idea what the raw log files look like; you'd have to examine the log file and determine how the data is recorded and how cPanel manipulates the data into a "Total Bandwidth:" figure.

                  Its in /tmp/cpbandwidth

                  Heres a snippet of the file to see how its arranged....I also see three image files (png) of draw table graphs for today, 7 day, and year (no month whcih is what I need)

                  1273608992 151 .
                  1273609004 499 .
                  1273609012 505 .
                  1273609021 153 .
                  1273609165 15030 .
                  1273609186 15047 .
                  1273609210 15052 .
                  1273609240 185 .
                  1273609272 3959 .
                  1273609294 15042 .
                  1273609331 4007 .
                  1273609347 4012 .
                  1273609379 4002 .
                  1273609423 3129 .
                  1273609560 3182 .
                  1273609615 3182 .
                  1273609628 3182 .
                  1273609724 14866 .
                  1273609742 14865 .
                  1273609772 14844 .
                  1273609802 14864 .
                  1273609818 14864 .
                  1273609853 14825 .
                  1273609874 14805 .
                  1273609919 14590 .
                  1273610004 14571 .
                  1273610026 14591 .
                  1273610078 3239 .
                  1273610120 3260 .
                  1273610251 3270 .
                  1273610265 3273 .
                  1273610302 14590 .
                  1273611142 4963 .
                  1273611262 4911 .

                    Looks like those are Unix timestamps (first one corresponds to 05/11/2010 15:16:32, second corresponds to 05/11/2010 15:16:44, etc.), followed by the number of (?)bytes used, followed by a period, with the three columns delimited by a single space.

                    Assuming my assumptions are correct (:p), you could simply use [man]fgetcsv/man to read in the file and parse it.

                      Zstar Electronic Co.Ltd, Sell fire cards for DS/NDSL/NDSi, also have Wii, DSiLL, NDSi, NDSL, PSP2000, PSP3000, PS2, PS3, PSP go, PSP, Xbox360 accessories, all kinds of phones are available
                      www.zstar.hk
                      WWW.TIGERSUPERMALL.COM

                        Write a Reply...