The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do You find User's Disk Usage?

Discussion in 'General Discussion' started by trakwebster, May 3, 2003.

  1. trakwebster

    trakwebster Well-Known Member

    Joined:
    Jan 29, 2003
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    I'm stumped. Searching reveals many threads that the WHM display of disk usage, for example in the Quota Modification section, is incorrect. (I kinow of no other place to view disk usage.)

    For example, I've got one directory with about 950 megs of mp3 files. I know how much these are because I've measured their sizes. When I go to that mp3 account and do a du -chs it reports approximately 1.1 Gig usage. Close enough.

    However, the WHM reports 3183 meg, about three times as much. Oddly, WHM does not report the user as begin over his quota of 1600 meg.

    This user has no mysql files, and the account has never been used. It's just storage actually.

    I have a backup drive, and in fact there are six copies of this account there. If WHM was adding those in, the total should read about 6.6 gigs.

    In other words, the WHM readout seems to have no direct correlation with actual disk usage.

    Which brings me to the question -- if the WHM cannot give you the disk usage, how in the world does anybody monitor and/or charge for disk usage?

    I suppose I could write my own script to go to add up mysql then home dir, but surely somebody has already solved this problem.

    Would somebody please share the solution here? I would be grateful.
     
    #1 trakwebster, May 3, 2003
    Last edited: May 5, 2003
  2. CodyFrisch

    CodyFrisch Active Member

    Joined:
    Apr 3, 2003
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Helena, MT
    well

    du -hs /home/mp3

    this is a good way to start, as it gives you the total of this directory.

    repquota -v /home | grep mp3

    this will give you an idea of what the quota system is seeing.

    if in doubt:

    repquota -va | grep mp3

    this will give you what the quota system says is being used by this user on all drives with quota support enabled.

    Mysql databases belong to the user mysql, so the quota system reports them as mysql not as the user.

    All in all its not a VERY exact science.

    If all else fails trust "du -hs /home/mp3" as its going to be "correct" for that directory.

    I'm of course the one whose been pointing out the quota problems so much today. It is not an exact science.

    TRUST DU FIRST!
     
  3. trakwebster

    trakwebster Well-Known Member

    Joined:
    Jan 29, 2003
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    Hi, CodyFrisch,

    Thanks for the reply. I'm exhausted now, but will check these out in the morning. I'd never heard of the repquota.

    I've been using du, and I trust it just fine. But the question is just a little different.

    Every month, at billing time, do you sit down with a list of all your user names and type them all into the du command?

    Surely somebody has scripted this, no?

    And for mysql, at least the way the databases are created on cpanel, you can just go to /var/lib/mysql, and use the du on every db directory you find there, as they're all named like username-something. That too, could be scripted, I'm sure. And I'll bet there are other, smarter ways to automate this process. And that's the question I'm asking --

    Has anybody got a working script that (a) counts up actual usage for all the customers, (b) compares it to their quota, and (c) lets you know who's over?

    If not, it's just stupifying to discover that the entire webhosting industry represented here, after selling packages with this or that amount of diskspace, don't have any way to see who uses what?

    What? Can that be?

    Anybody?
     
  4. CodyFrisch

    CodyFrisch Active Member

    Joined:
    Apr 3, 2003
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Helena, MT
    Hence the reason I use the XFS file system, I can trust its quota reports. I typically disregard the database for all but the most database intensive sites.

    Obviously I wouldn't ever charge people for the logs we keep on thier domain. They are primarily for our use and for the stats runs, which are a service the customer pays for.

    The only thing besides the account home directory you'd want to worry about is mysql. You'd be suprised how small this data is for each account usually. But its still pretty simple to find this disk usage

    #!/bin/sh
    du -hs /home/mysql/$1_*
    du -hs /home/$1.

    invoke with:

    diskusage username (assuming you named the script diskusage, and chmod'ed correctly)

    Obviously there would be more to this script, that would add all of this up, and that would generate a report for each user. Obviously it would also have to parse your resellers list and list it in that fashion too.

    Then also the OTHER option is to do this:

    gunzip /backup/cpbackup/daily/$USER.tar.gz > /tmp/$USER.tar
    du -hs /tmp/$USER.tar

    This would tell you everything in thier backup uncompressed, but this is SLOW and a system hog.

    I personally wouldn't worry about databases, unless they are massive. Do a du -h within the mysql data directory and check for any databases that are extraordinarily large esp. compared to thier account size. If a 50MB account has 200MB in databases, then yeah, charge them. If a 500MB account has 50MB in databases, I wouldn't worry so much, esp if they aren't using but 300MB of thier account.

    Since I use XFS, I get an accurate report in whm for disk usage except the database. I just manually check the databases for anybody that is out of control with them.

    In this business, you can either be laid back, not worry about every last megabyte used by a customer, and let them be happy - and not go crazy. OR you can account for every last drop they use, and be a hard nosed jerk about the whole think, and die of a coronary yourself - because you've driven all your customers away because you're charging them for stuff that doesn't show up in thier cpanel at all and such.

    Be resonable, don't be a bean counting penny pinching scrooge.
     
    #4 CodyFrisch, May 4, 2003
    Last edited: May 4, 2003
  5. CodyFrisch

    CodyFrisch Active Member

    Joined:
    Apr 3, 2003
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Helena, MT
    Hmm, new one to me. So many scripts from cpanel, so little DOCUMENTATION of it all.

    All this does is changes the USER on the database directory to match. Really shouldn't have to run this EVERY time, only to update for new databases.

    In reality it ought to be part of the script that makes the database, or an option.

    to see the change

    repquota -va | grep username

    should see the total of everything that is OWNED by them. This may be a PROBLEM though, if you don't want to charge them for EVERYTHING.

    i moved my mysql data to /home/mysql just so it wasn't on one of my smaller partitions. Just symlink it. Then I only have quota enabled on /home, nothing else.

    This way I can basically get what I need with the quota reports.
     
  6. trakwebster

    trakwebster Well-Known Member

    Joined:
    Jan 29, 2003
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    Hi, Cody Frisch,

    Thanks for the good tips and the good advice. I fear that changing to XFS file system is not in the cards for me at this time, but I can certainly use most everything else.

    I'm new to webhosting, after 14 years running a voicemail business, which has surprisingly similar issues. For local voicemail, it doesn't matter much how much space they use unless it's truly monstrous, so the 'eyeball-it-now-and-then' method works just fine. For the 800-number voicemail, it's a different thing entirely as I pay for every minute of use. So I guess I'm familiar with both approaches. (Laid-Back and Beano)

    However, in this case, I'm more concerned because (a) I had not even a clue how to measure, and (b) the cpanel is lying to the customer, which is going to cause me great time and hassle, forever, unless I find a solution. (I'm using a custom cpanel skin, so of course I can just remove that info; but I'd rather find a way to make it work.)

    As regards being a jerk, don't get me wrong. I'm *plenty* a jerk, and all too often. But maybe not right now. ;)

    -- Arthur Cronos from Voltos
     
  7. CodyFrisch

    CodyFrisch Active Member

    Joined:
    Apr 3, 2003
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Helena, MT
    hehe, alright :)

    Yeah, I agree that this whole method of accounting for everything is rather haphazard. Its definately not a science with this stuff (unless you do lots of stuff to figure it all out.)

    Unfortunately, you can't report the disk usage to your customers in cpanel accurately without XFS (which journals meta-data only, not every bit of data. But since a webserver isn't really a mission critical situation most of the time this isn't a big deal. You can loose data with XFS (you can with ext3 too, but XFS is faster than ext3 and has lots of other benefits.))

    Really switching to XFS isn't too big of a deal, if you got the room to backup first of course. Basically you'd have the downtime to restore the backup and thats about it - presumably.

    http://oss.sgi.com/projects/xfs/

    Check that out for all the info on XFS.

    IBM's JFS is probably a superior filesystem in regards to performance and maybe its journalling. But it still relies on the regular quota support like ext2/3 reiserfs does. Which doesn't solve the reporting problem.

    If you used XFS, and setup say a daily or twice daily cron job to run that updatemysqlquota script, you could offer fairly accurate reports to your users. that updatemysqlquota owns all databases by the user, so it counts toward quota.

    I've put mysql databases in /home/mysql because that way everything is on one partition, and i only need to enable quota support on that one partition (since XFS has you enable the quota in the fstab, and requires a reboot - oh well.) Since with this method you can setup to account for quota on only the one partition (that matters most), it means a few strays get away - not a big deal.


    For now, use du, write some perl or shell scripts to give you a nice report for billing. Or switch to XFS for your customers understanding it better.

    If you read the XFS site, you'll realize how simple XFS REALLY is to get up and running with. (backup, format the partition, restore...) (well and recompile your kernel, and install the software for it. Should be recompiling your kernel to 2.4.20 anyway... with the ext3 and xfs patches, and a few other good patches you may need.)
     
  8. trakwebster

    trakwebster Well-Known Member

    Joined:
    Jan 29, 2003
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    Hi, Cody Frisch,

    Thanks for the info about XFS. I had actually been a bit intrigued with it in the past. But, remembering that one man's 'simple' is another man's 'spaghetti', I wouldn't feel comfortable undertaking the conversion of an existing machine. I'm still learning, and have many other things to break before getting to work on the file system or kernal.

    However, using your good ideas, I've made some progress: Here's where the problem is coming from --

    I have a second drive on the machine, used only for storage and backups. The standard cpanel backups of user info has everybody being tarred, and ownership changes to root (or cpanel) so that stuff doesn't get counted toward the user's quota.

    However on this backup drive, I have my own complete mirror copy, which I update each day using rsync. This mirror copy has all files still 'owned' by their usual owners. And quota is including these files in the count.

    Reading up on the quota program, and its brothers quotaon, repquota, quotaedit, and quotactl, I discover that:

    1) although in theory the quotactl should enable me to turn off a filesystem such as my backup drive, the doc is peculiar and hard to understand;

    2) quota uses the /etc/mtab (mounted filesystems table) to determine what it's going to count. And the /etc/mtab appears to be a copy of fstab. And the /etc/mtab has a create date of two days ago, which probably means it's created anew from time to time.

    You seem to know quite a bit about this, so I'm hoping that you would know the answers to these questions --

    1) Is the /etc/mtab used by anything other than quota? (Meaning could I mess with /etc/mtab without breaking anything other than quota?)

    2) Would you know when and by whom the /etc/mtab is created?

    Or, perhaps you could suggest some other ideas for solving this nicely?

    -- Arthur Cronos
     
  9. CodyFrisch

    CodyFrisch Active Member

    Joined:
    Apr 3, 2003
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Helena, MT
    /etc/mtab is created by mount, it lists all the mounted file systems. Everything from df to find etc uses it. Don't touch it :)

    There is one quota tool you don't know about ;)

    quotaoff -v /home (or whatever partition it is) (this is just a symlink to quotaon, same as quotaon -fv /home) (the -f tells quotaon to act like quotaoff)

    Unfortunately quota is on a filesystem by filesystem basis as I think you know.

    Hope this helps.
     
  10. trakwebster

    trakwebster Well-Known Member

    Joined:
    Jan 29, 2003
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    By Jove, I think you've got it!

    Hi, Cody Frisch,

    I think you just hit the nail on the head!

    You are right, I did *not* see the quotaoff, and failed to get how it would work. I have therefore read again (with apparent comprehension) the man quotaon, and there it is.

    Accordingly, I have issued a 'quotaoff -v /mybackupdrive' and the quotaoff program has told me very nicely that
    '/dev/hdc1 [/mybackupdrive]: user quotas turned off'.

    Well, you couldn't speak nicer than that!

    I do not know when cpanel makes its rounds to see what space everybody is using, but I think it's more often than once per day. I think that because I found some erasable stuff earlier today on the storage drive, and noticed that the user's reported usage has dropped. So most likely I should see user space more or less correctly reported sometime tonight or tomorrow morning.

    Thanks again for your help! Your suggestions were right on!

    -- Arthur Cronos
     
  11. CodyFrisch

    CodyFrisch Active Member

    Joined:
    Apr 3, 2003
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Helena, MT
    /scripts/quotacheck

    I think this will update everything for you :)
     
  12. trakwebster

    trakwebster Well-Known Member

    Joined:
    Jan 29, 2003
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    Well, bummer.

    Hi Cody Frisch,

    This is a mystery. Although I issued the command quotaoff -v /mybackupdrive, and the quotaoff program responded that the user quotas were now off on that drive, in actual fact the contents of the backup drive are still being added to the clients's total.

    For example, the command
    quota -v username
    produces output showing that he has, for example, 900 megs in home, and another 900 megs in the /mybackupdrive. Likewise, both cpanel and WHM are still reporting the incorrect, larger disk usage figure.

    Am I missing anything here?

    Is a reboot needful?

    I did run the /scripts/quotacheck, but it seemed to make no difference. In the scripts directory, I find --

    editquota
    fixquotas
    initquotas
    mkquotas
    pedquotas
    quotacheck
    resetquotas, and
    updatemysqlquota

    Any ideas on that some of these other [UNDOCUMENTED-DAMMIT!] scripts might do?
     
    #12 trakwebster, May 6, 2003
    Last edited: May 6, 2003
  13. trakwebster

    trakwebster Well-Known Member

    Joined:
    Jan 29, 2003
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    Wanted to see if a reboot would make a difference so -- just to be sure -- I reissued the command quotaoff -v /mybackupdrive.

    It responded that the userquotas were now off on the backupdrive.

    I did a graceful reboot. Everything came up nicely.

    But there is still no change in the disk space being charged to my unfortunate user. He's still seen as having disk space on both his home directory and on the storage drive.

    For the moment, I'm stumped.
     
  14. trakwebster

    trakwebster Well-Known Member

    Joined:
    Jan 29, 2003
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    Maybe not stumped for long ...

    Hi, Cody Frisch,

    I think I've found it. I got to thinking, maybe cpanel has little documentation, but *somebody* wrote that quota system. Since I'd not found the answers, or comprensible ones anyway, in the man pages, I searched further.

    First I checked a couple of the man pages, at the end to see if they had a 'bugs to' or other reference. Didn't see that.

    Went to google, but then thought about RedHat. RedHat has cleaned up a lot of the documentation, and further they only have the RedHat-utlized stuff on board.

    So I went to Redhat main page, did a search on 'quota', and up pops lots but the first was the 'Mini-Howto'. In the contents, 'configuration.'

    In the configuration, instructions for setting (or not setting) the word 'usrquota' into the /etc/fstab. Well, duh, I've seen that there. Only, when I saw it, I didn't know what it meant!

    So, checking /etc/fstab I see that 'usrquota' is currently enabled on the root directory (/), plus /home, /usr, /var, and (ta-da!) /mybackupdrive. So I'm going to fix that. I will be careful. I've modified the fstab before.

    [Edit} I've now modified the fstab -- carefully -- and rebooted. Everything seems to have come up nicely, and BY GOLLY! the user no longer has any extra stuff charged against his account because of what's in the /mybackupdrive! I can now see the correct disk usage with the quota command, in WHM, and in cpanel!

    But before I leave this, I wanted to ask your opinion. You seem to know quite a bit about this. When I check the normal users other than root, I see that they have valid, working space in /home, and in /var (mysql). They generally have little or nothing in the others.

    Can you think of any reason why I'd want quotas enabled on root (/), or /usr?

    I cannot think how a user uses space on root (/) at all.

    My users in general won't be installing stuff. (I think that's a common use for /usr, no?) But would it be good to monitor /usr, for example, so I could see if stuff did get installed? Or is this just needless?

    What do you suggest?
     
    #14 trakwebster, May 6, 2003
    Last edited: May 6, 2003
  15. CodyFrisch

    CodyFrisch Active Member

    Joined:
    Apr 3, 2003
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Helena, MT
    There are some programs out there, like Tripwire which will tell you everything that gets modified on your system (with lots of configuration so it doesn't tell you about stuff you expect to get modified.)

    I'd recommend this as a START. Its also good if your server gets compromised, since you know what the jerks messed with (hopefully, there are things you can do to make sure you know if they messed with tripwire itself too.)

    No, I see no reason to have quota's on ANYTHING but /home. As far as mysql, I'd stop mysql, move the mysql directory to /home and create a symlink to it in /var.

    When you move it, check the help for the mv command and make sure you are going to preserve permissions and owners and such (usually fine with moving, copying is different story though, as typically the ownership will change to whoever is copying it.)

    But I'd recommend you only run quota on the one partition, that contains the user data and mysql. This mean you only count stuff that matters to you.
     
  16. trakwebster

    trakwebster Well-Known Member

    Joined:
    Jan 29, 2003
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    Hi, Cody Frisch,

    Thank you for all your kindness and assistance. I am grateful and promise to pass along the help to somebody else soon.

    Although some of your recommendations I 'm timid to use now, I will try them on the next server.

    -- Arthur Cronos

    How's the weather there in Helena? My wife and I have been searching to relocate. We've got it down to Whitefish MT, Nelson BC, and Lake Shastina CA. We haven't visited Helena.
     
  17. CodyFrisch

    CodyFrisch Active Member

    Joined:
    Apr 3, 2003
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Helena, MT
    Helena doesn't get near the snow of Whitefish. Typically less rain too, though this year is shaping up to be nice.

    Its definately a lot more urban than Whitefish - if you can call Helena urban. There are more people up in that county than down here, but its more spread out.

    Its closer to a desert here than you'd think. We're east of the divide so most the water gets trapped on the other side. But its not like Arizona.

    Temps get into the 100's sometimes, very rare. Normal peaks are in the 80's. Normal winter temps are in the 20's and up with occassional drops below that, with a few days every year below zero. Normal snowfall is a few inches at a time, though this year we got a couple feet in a few hours. Thats once ever 30 years though.

    As far as the essentials, we have pretty widely availible DSL within the city limits. We have cable internet availible pretty widely both in and out of the city limits, though right now the cable is stinking it up because Comcast bought ATT - then sold it to Bresnan Communications (small company, but looking good.) But anyway Comcast and ATT shut off all the excess bandwidth they could before they sold it, so now it creeps. Bresnan promised to have it fixed in the next month, as they rebuild it all - new routers, new lines, etc. Hopefully they come through!

    The county has about 55,000 city limits has just under 30,000. We have a walmart, shopko, target, kmart (for a while at least), and are getting a home depot. So we are not a small town. Whitefish is smaller but not really less modern or anything. Whitefish is definately more of a tourist town than Helena.

    Hope that helps you out a little.
     
  18. trakwebster

    trakwebster Well-Known Member

    Joined:
    Jan 29, 2003
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    Cody Frisch, you are the *man*!
     
  19. CodyFrisch

    CodyFrisch Active Member

    Joined:
    Apr 3, 2003
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Helena, MT
    I would be if it weren't for the fact I'm a woman :D (joking)

    You can don't have to call me Johnson.... just Cody
     
  20. danimal

    danimal Well-Known Member

    Joined:
    Jul 14, 2003
    Messages:
    79
    Likes Received:
    0
    Trophy Points:
    6
    user quotas, fstab, mount points, backups...

    This thread is very helpful, but I still have a few questions for anyone out there. I've been having the usual quota problems and realized it's because of having incremental backups. I suppose I could turn them off and just do full backups, but I'd rather solve the problem at the source, rather than a workaround.

    My system came with just two partitions: /boot and /
    Unfortunately, this means that everything under / is "usrquota"'d. So, my questions are:

    1) Is there a way to specify a "virtual" mountpoint in fstab that doesn't map to a physical partition? That way, I can specify /backup even though it isn't on it's own partition?

    2) If not, is there a safe way to repartition this drive without screwing things up? I'd rather not mess with it

    3) Barring repartitioning, are there any other options to turn quotas off for /backup/ ?

    I guess if I can't get some other solution, I'll just turn off the incremental backups. Kinda a bummer, though. Seems like either (a) cpanel should have the ability to assign backups to a different user/group so as to not count towards quota, or (b) the quota system should have the ability to turn off directories, not just mount points.

    Anyway, any help would be greatly appreciated!

    Thanks,

    Danimal :cool:

    cPanel.net Support Ticket Number:
     
Loading...

Share This Page