OS performance and optimization
Minimizing disk I/O with DirectAdmin
DirectAdmin does quite a few things, many of which require a fair amount of disk read/writes.
If your disk is experiencing high I/O, causing a bottleneck in your system's performance, there are a few things you can do to reduce the disk access during various tasks DirectAdmin does.
Backup: Enable direct_imap_backup so that email data is directly added into the tar.gz backup file, rather than being copied first. On new installations, this is enabled by default.
Backup: Disable the backup_hard_link_check by setting it to 0 in the directadmin.conf, but ENSURE you have strict_backup_permissions=1 set. Without the hard-link checks, you must run backups in strict mode, so tar.gz files are created as the User.
Backup: A more complex solution is to use rsync for copying
/homedata to a remote box, and use the DA backups for everything else (restorations are more difficult, and this setup only saves a single copy).
Backup: Add a load checker before the backups are run, which either waits for a lower load, or will abort after the maximum number of attempts is reached.
Tally: Use the simple_disk_usage setting so that the tally only relies on system quotas (apache owned files would not be found).
Messages: Keep your message system pruned by automatically deleting old messages and tickets. An oversized list of messages/tickets can really degrade DA's ability to add new messages to the list. If you trust that your IP blocking is working as desired, you can also prevent BFM messages from being added in the first place.
File Manager: Do not count folder usage.
The system says that I have used up all my RAM
Unix (Linux/FreeBSD) boxes can often cause confusion with memory usage. If you run "top", it will normally show you that about 98% of the memory has been used up. This is actually normal and no, you probably have not run out of RAM.
Unix is always doing its own internal house keeping with the system, thus will use up the available memory to do so. If a real program is started up and it needs that memory, the house keeping tasks are instantly dropped and that memory is freed up for the program that needs it.
You only have to be concerned with memory usage once your swap memory starts to grow. If the swap usage is less than about 10 Mb and isn't moving or growing, then you are still in the green. Only once you see your swap memory usage starting to climb do you have to worry. If that happens, then you either need more RAM, or one of your programs is using up memory quickly due to either heavy system load (e.g., volumes of MySQL queries) or possibly program memory leaks. Sometimes restarting Apache and MySQL can reduce the amount of memory used, but it will usually increase gradually back up to where it was over time.
More info at this website: http://www.linuxatemyram.com/
How to create a swap file
Some VPSs do not come with a swap file. DirectAdmin recommends to have at least 2 Gig of RAM, and some swap space as needed. The more RAM, the better, but having more than 4Gig of swap isn't as useful.
To add 4 Gig of swap, assuming you have enough space on disk, run:
dd if=/dev/zero of=/swapfile count=4096 bs=1MiB chmod 600 /swapfile mkswap /swapfile swapon /swapfile
Confirm it's loaded with:
or by running top.
If it works, then add this to your
/swapfile swap swap sw 0 0
Finding runtime information on a specific process ID
If you know the process ID number (PID) of a specific process, and want to know more about it (who called it, where it's running, what files it's accessing, etc.), then you can check the proc folder.
For example, if the PID number is 1234, type:
cd /proc/1234 ls -la
which will show a lot of data. The usual things to check are:
cwd which is a link pointing to the current working directory. This is usually where the program was started from, but can be changed by the program, so cannot always be trusted.
exe will be a link pointing to the binary that is running.
status The contents of the status file will hold a human readable list of information. The important part will usually be the UID field, as that number is what the process is running as (roughly the same as "ps aux | grep 1234")
fd This directory will list all open file descriptors, which are files that the process is accessing. This can be handy to find out what it's doing, if anything locally.
Another quick tool to see the details is lsof :
lsof -n -p 1234
How to track which process is using a certain port
If you need to figure out what is coming in or going out of your server, there are a few useful commands for this.
In this example, we're going to track connections that are using port 25.
On Linux (CentOS/Debian), you can use the netstat command:
netstat -np --protocol=inet | grep ESTABLISHED | grep :25
or on FreeBSD:
sockstat -c -p 25 -P tcp
Both types should generate a PID number. The netstat command will provide the PID number on the far right, and sockstat is the 3rd column.
Once you know the PID number that is using the connection, you can find a runtime information (see the guide above).
How to install Netdata metrics
Netdata Metrics is used for real time, highly detailed server information.
cd /usr/local/directadmin/custombuild ./build netdata
The new command in DA will be:
where DA is nothing more than a proxy to
This is an Admin Level only command. Access netdata with the following:
Add connection info into the high load notice
DirectAdmin will use
/usr/local/directadmin/scripts/connection_info.sh script to provide connection information in high load message report. Script will spit out the netstat info for:
- list top number of connected IPs, with their connection count
- the IP with the most number of connections, with all connection info (including ports)
- if /usr/sbin/ss exists, a full dump of "ss -n" for more info.
A custom copy can be used at
/usr/local/directadmin/scripts/custom/connection_info.sh to fully override the default, or a hook is called from within the script, which can be created here, so you can include your own output to the Admin message
/usr/local/directadmin/scripts/custom/connection_info_post.sh so that the default output is still included, without needing you to manage it if copied.. plus your own output from the connection_info_post.sh script.
Template for message may be found at