PS Server Status Script

From DreamHost
Jump to: navigation, search
Dh-kb-important-icon.fw.png Important: This article contains information/examples about root/sudo/admin users.

On December 9, 2015, DreamHost disabled admin users on VPS machines (private servers). For details of why this was done, please review the following article:

If you still require sudo/admin access, you must upgrade to a Dedicated server.


If you have a Private Server (VPS), you might be interested in finding the status of that server without having to wait at a terminal window. Instead, you can run a script that emails you this information about the status of your PS.

It works by outputing HTML 4.01 Strict compliant content containing information on your server, including:

  • load average
  • memory usage
  • open network connections
  • top 10 memory processes
  • top 10 CPU processes
  • netstat output
  • top snapshot of all running processes
Dh-kb-note-icon.fw.png Note: This only applies to your web server VPS. Shell access to MySQL PS is not available.

Installing a server script

Download a copy of the script in one of two ways:

  • Visit the URL of the script. You can then download it in your browser:
If you download the file by visiting the URL, you still must upload the file via FTP.
  • If you’re able to SSH into your VPS, you can simply run:
curl -s -o status.rb

The script is named status.rb, and the script itself is written in Ruby to take advantage of the ERB templating system to produce the HTML content.

Confirming if mailx is installed

Once you've downloaded the script successfully, you must make sure that the mailx package is installed on your PS.

To find out, run this command:

dpkg -l | grep mailx

If you see output something like this:

ii  bsd-mailx                                         8.1.2-0.20100314cvs-1        simple mail user agent

then that means it's installed.

If instead you see output like this:

rc  mailx                                   8.1.2-0.20050715cvs-1                A simple mail user agent

then that means you need to install it.

To install, log in with your VPS admin user. Once logged in, run the following command:

sudo apt-get install mailx

Creating a cron job

View the Crontab article for details on how to create a cron job under your shell user. Enter the following command in the panel when creating the cron job.

/usr/bin/ruby /path/to/script/status.rb | /usr/bin/mail -a "Content-type: text/html;" -s "Status Report: $HOSTNAME" ""

If the above command does not work, try modifying '/user/bin/ruby' to be '/user/bin/ruby1.8'.

  • You can change the subject to anything you like.
  • You can also change the email to any address you’d like the cron email sent to.
  • If you want to CC the email to more email addresses, you can use the -c flag and pass it a comma separated list of email addresses.
  • Running it once per hour is probably not a bad idea, but you can run it as frequently or infrequently as you like.


If you set everything up properly, then you should start getting emails that look roughly like this:

Server status script preview.png

Keep in mind that this script is likely to update as time progresses if things change with PS configurations. So, if this stops working on your PS, be sure to check back to see if the script has updated. This was tested with the new SSD VPS on Ubuntu 12.04 LTS and so far there are no problems.