Monitor Your Web Server Using Your iPhone

Warning: this post is for uber geeks who are comfortable with SSH, Linux command line operations, and showing off their server uptime stats to strangers.

Default monitoring tools from many hosting services leave a lot to be desired.  You have to log in to the server to use them, they’re often several clicks deep into your control panel, they rarely display everything you want to see, and most importantly, they’re not on your iPhone.

Thankfully, iStat, an iPhone app by Bjango, solves this problem.  Installing the iPhone App is easy, but it will set you back a whopping $0.99.  Getting your server to talk to the App is just a bit trickier.  It took me an hour or so to do it the first time, but using these instructions, it should only take you 10 minutes.

To get started, log in to your server using an SSH client like Putty if you’re using a PC, or terminal on a Mac.  Once you’ve logged in, use “cd/” to drop down the root directory, and then using the following commands to create a directory for iState and then download, configure, and install the program:

mkdir istat
cd istat
wget http://istatd.googlecode.com/files/istatd-0.5.4.tar.gz
tar -zxvf istatd-0.5.4.tar.gz
cd istatd-0.5.4
./configure –prefix=/usr –sysconfdir=/etc
make
make install

Create a new user account for the program so it can run in a shielded environment:

useradd istat -s /sbin/nologin
mkdir -p /var/{cache,run}/istat
chown istat /var/{cache,run}/istat

Start the service:

/usr/bin/istatd -d

Create a script to restart service upon reboot using vi:

vi /etc/init.d/istatreboot.sh

Then, and add the following lines:

# Start istatd upon reboot/startup
/usr/bin/istatd -d

Make sure to set this file to the right permissions to allow it to run:

chmod 0755 /etc/init.d/istatreboot.sh

Edit the /etc/rc.local file:

vi /etc/rc.local

Now add “/etc/init.d/istatreboot.sh” to the bottom of the script

Next, you’ll want to edit /etc/istat.conf

vi /etc/istat.conf

In this file you’ll want to edit the server_code value to a five digit code you will later enter on your iPhone.  This serves as a password for access to iStat.

Next, you’ll want to change the values of monitor_net and monitor_disk to this:

monitor_net              ( venet0 )
monitor_disk             ( /dev/vzfs )

You’re done!  Reboot the server to make sure your service will startup upon restart and configure the app on your phone.

Note: These instructions are based on a Media Temple dedicated virtual server running CentOS. Your server’s configuration may vary, so you may need to adapt these instruction to your specific configuration.  Check out the iStat user Google group.