How is disk space usage calculated?
Starting from DirectAdmin version 1.59.6, the new internal default config variable below will apply to all existing and new installs alike:
This will make use of the system quotas to let Users see their usage in realtime. If set to 2, the panel will use fastest kernel-level quotactl function calls to get usage.
realtime_quota=0 - for a nightly tally to update disk usage per user
realtime_quota=1 - for a slower binary 'quota -v username'
NOTE: DA needs the device names to pass to the quotactl call. This is done with the "mount" program, but for efficiency purposes, this is only done once at startup in the master process. This means that you'll need to be sure to restart DA to get an updated mount list if you make any changes to your partitions/quotas.
Inode counts are also updated in realtime with
realtime_quota turned on.
SPECIFIC OS CASES
Use realtime_quota=2 when possible.
FreeBSD often does not have quotas compiled into the kernel. If that's the case, you cannot use 2. However, if that's the case, then you might as well stick with 0, as it's probably a nightly quotacheck cron anyway, so you'd gain nothing from realtime quotas. After testing back to FreeBSD 9, a value of 1 was the best that worked in these trials.
CentOS 5 "quota -v user" does not support "no-wrap" -w, so you must use 2.
CentOS 6/7 is fine with both 1 and 2, but the quota command does not support
--show-mntpoint, so DA uses the block device lookup, which should already be cached anyway for mode 2. Use 2 for CentOS 6 when possible.
Debian 7+ works for both cases.
If you're noticing that the quotas returned seem to be too low, ensure the correct quota type is set in the directadmin.conf.
Check your mount of / (or /home), e.g.,
[root@server directadmin]# mount | grep ' / ' /dev/mapper/vg_es664-lv_root on / type xfs (rw,relatime,attr2,inode64,usrquota,prjquota)
If that's showing xfs, then ensure you're using
use_xfs_quota=1 and change it to 1 if you are not:
cd /usr/local/directadmin ./directadmin config | grep use_xfs_quota ./directadmin set use_xfs_quota 1 service directadmin restart
If the mount shows ext4, and you see
use_xfs_quota=1, then set it to 0.
Why is the used disk usage above the limit?
If you're wondering why a User might be using more space than is assigned to him in his disk usage limit, there are a few reasons:
There is a soft limit and a hard limit. The hard limit will be 1.1x the value you set in DA. This is to allow some grace if files are too big. http://www.directadmin.com/features.php?id=918open in new window
You can lower it to 1.0 if you prefer to not have any room for temporary overusage.
Also, not all files counted by DA are governed under the system quotas, e.g.,
- MySQL databases
- Files owned by apache
- Data for mailing lists
Since they're not chown'd to the User, they won't be under the system quotas, and thus are not enforced by the system quotas, even though DA does count them.
- If you want to suspend for overusage (not recommended), see the following: http://www.directadmin.com/features.php?id=713open in new window
What bandwidth does DirectAdmin calculate?
DirectAdmin will log all bandwidth that it is able to, but does not monitor at the device level and so is restricted to certain logs. All banwidth that is logged by DA must be able to be assigned to a specific user, then all user bandwidth totals are added up, thus giving the box total in DA. This value will always be lower than the device total since many things that cannot be assigned to one user will be in the device's count but not DAs.
What DirectAdmin does count:
- Apache Usage: Any data sent out for a request on that User's domain. Logging for /~username traffic is also counted.
- FTP Usage: Any files uploaded and downloaded are logged.
- Outgoing Email: All outgoing email where DA is able to determine who sent the email is logged in /etc/virtual/usage/username.bytes.
- Incoming Email: Any email that is addressed to a valid email account is counted in the username.bytes log. Forwarders, spam, and invalid accounts are not logged.
- Pop/Imap: As of DA 1.40.0, if you're using dovecot, this data will be logged.
- DirectAdmin: Everything DA-related is counted, including FTP downloads and uploads for backups (can be disabled).
What DirectAdmin does not count:
- Data transfers from within scripts, such as uploads/downloads done by code within a script.
- SSH level commands such as wget
- Service updates using custombuild, yum, apt-get
- The named (bind) dns service
- Any low level network traffic, pings, etc.
The reseller.usage will now log the bandwidth calculated from the Reseller's:
which is used to count the bandwidth used by a User prior to their deletion (so you're not also deleting the bandwidth usage).
A new field was added to the
reseller.usage file, so it can be displayed to Admins when viewing the Reseller usage.
This count will be a subset of the total bandwidth already shown.
The variable in the reseller.usage file is:
which, like the bandwidth option, is in Megabytes.
This value is only there for efficiency. It's recounted each night based on the
deleted_user_bandwidth= value is missing or 0, then the field will not be shown.
The monthly reset clears the
bandwidth.reseller.tally file for anyone whose deletion time is within the previous stats window.
Notifying users about overusage
User Limit Templates
Message system email templates used for notifying Users and Resellers about overusage exist here:
SUSPENDATLIMIT LANG BANDWIDTHUSAGEGIG BANDWIDTHLIMITGIG QUOTAUSAGEGIG QUOTALIMITGIG TIMELEFT BANDWIDTH_MAY_RUN_OUT DAYS_REMAINING_THIS_MONTH REASON=quota|bandwidth|inode INODE INODELIMIT INODEUSAGE BANDWIDTH_EXCEEDED=yes QUOTA_EXCEEDED=yes INODES_EXCEEDED=yes
The "exceeded" wording in the tokens above refers to the threshold in order to generate the warning email, not necessarily a 100% usage, but the following
directadmin.conf settings in percents:
user_warning_thresh=80 user_warning_thresh_disk=95 user_warning_thresh_inode=95
user_limit.txt checks are allowed. The check order is as follows:
The custom script to be called after a warning/notice email is sent out is:
The custom script to be called before a warning/notice email is sent out is:
Environmental variables available for these pre/post scripts include:
USERNAME BANDWIDTH QUOTA BANDWIDTHLIMITGIG BANDWIDTHUSAGEGIG BANDWIDTHLIMITMEG BANDWIDTHUSAGEMEG QUOTALIMITGIG QUOTAUSAGEGIG QUOTALIMITMEG QUOTAUSAGEMEG TIMELEFT SUSPENDATLIMIT CREATOR LANG
Disabling overusage notices if the account is suspended
There are three variables to be used in the
sentwarning_bandwidth=yes|no sentwarning_inode=yes|no sentwarning_quota=yes|no
which are used to determine if an overusage notice on specified resource was sent or not.
When an Admin or Reseller manually suspends an account, this will also set account=OFF in the
user.conf file, so the overusage warning messages for such accounts aren't sent.
The sentwarning=yes will not be set in the
user.conf, allowing it to be sent at a later date should the account=ON be set later on.
overusage_notice_post.sh script will still be called, if it exists.
Bandwidth breakdown for previous months
Since we already have the
bandwidth.tally.cache file, just before the monthly reset, save a copy of this file for future viewing. This will allow comparisons between past months.
Will have a new folder:
/usr/local/directadmin/data/users/username/history and each file would be called YYYY-MM.log:
Note that the creation of this log is not merely a file copy. Instead it's a smart merge, in case the reset is run many times.
Only the last months data will be set there. For the current month, use the normal "Details" button on your stats page.
To view these history files, they'll be under the "User History" button. If more than 0 files exist in the "history" directory, a new "Details" column will be added to the User History page, where a JS pop-up will show the previous months.
CMD_API_BANDWIDTH_BREAKDOWN URI will be able to use this as well. Just add
year=2012&month=9 to the end of your call (either the ?user=user method, or the "self" method with no "user").