How can I monitor usage on my Linux Dedicated Server?
Posted by - NA -, Last modified by on 21 July 2009 05:18 AM
If your server comes with a control panel such as cPanel, Plesk or ServerCP you will most often be able to login via the control panel as 'root' and click on the 'view status' buttons there. However in cases where the server is sluggish, or the control panel not responding (or you do not have a control panel on your dedicated server) you can use the command line access method via SSH (login as root using SSH).|
Once you login via the SSH access (as 'root') you can type the following commands to get a better idea of what your server is doing:
The 'free' command will show the current memory usage in your dedicated server, the output looks something like this:
total used free shared buffers cached
Mem: 4143940 3988792 155148 0 89740 3000964
-/+ buffers/cache: 898088 3245852
Swap: 8385920 14896 8371024
The above output means you have 4 GB of ram, 8 GB of 'swap sapce' (simulated ram that can be used in the event your main memory is all consumed). The above output shows that you have 4 gb of ram, aand about 3.2 GB of it is 'free' (in the buffers/cache line) and you are not utilizing 'swap space'. The time to be concerned about memory would be if you had a lot of swap space being 'used', that would mean your server is going to run very slow as it tries to use disk 'swap space' ram instead of real ram, leading to performance hits about 100x slower than usual.
> ps axuww
the "ps auxww" command shows all the running processes in the server
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 2064 624 ? Ss Jul18 0:00 init 
root 2814 0.0 0.1 25432 11660 ? Ss Jul18 0:00 /usr/local/apache/bin/httpd -DSSL
nobody 2828 0.0 0.0 5852 1084 ? Ss Jul18 0:00 proftpd:
root 2846 0.0 0.0 5284 1116 ? Ss Jul18 0:00 crond
nobody 2875 0.0 0.1 25696 9984 ? S Jul18 0:00 /usr/local/apache/bin/httpd -DSSL
The output above is a partial output of a linux dedicated server, showing the processes (proftpd being the ftp daemon, httpd is the apache web daemon, etc). If you seea process 'stuck' you can terminate it with the 'kill' command such as "kill -9 2875" would kill process ID number 2875.
If your server is overloaded, or having trouble (perhaps a bad piece of web code you deployed is looping) you can restart the software like
service httpd restart
service mysqld restart
The first restarts the web daemon, the 2nd will restart the database (mysql) daemon. This is the SAFEST way to restart software, and should be tried first before you consider doing a full server reboot via the TurnKey Internet customer care center. Remember if you reboot a server via our
customer care center, it will disconect power (and reconnect it) suddenly and can lead to data loss or even prevent the server from returning to service properly (just like your home PC, if you loose power and don't properly shut down you can loose data). So only use the reboot feature in the turnkey customer care center as a last resort if the server is not responding at all.
You can monitor what is going on inside mysql (login to your mysql via either phpmyadmin, or if thats not responding which would be the case based on your description) you would have to access mysql via command line like this
A) login as 'root' via ssh
B) type "mysql -uroot -p" it will prompt for password, or if you have no password set for local access you would just type "mysql -uroot"
C) You are now 'inside' mysql's command line interface, you want to type
show processlist; <--- that ; is required
The output will be every sql process currently running, you may possibly see something like the syntax of a very bad querry 'stuck' in the system, which may help your developers to locate the issue.
All the above 'restart' commands are safe, and suggested before you ever consider a server hardware reboot (the potential down time of a reboot done when say the mysql database was writing can lead to significant lost time/productivity while backups have to be recovered and such).