Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.


Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.


Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.


Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Monitoring

Simple Host Monitoring with SSH

Submitted by on September 23, 2011 – 12:10 am 6 Comments

There are many complex host and service monitoring solutions available for Unix systems. But sometimes you just need something very simple to monitor a server or an application on a temporary basis. A basic ping monitor is fine, but it will only tell you if a server is responding on the network. It will not tell you if there is some other problem on the system. The script below relies on passwordless SSH setup to periodically log into the monitored nodes and check on their health by executing a local or remote script.

There are two pre-requisites to make this method work. First, you need to configure passwordless SSH from the monitoring host to the monitored client. Instructions are available here. Second, for notification this script uses “mailx”, so you need sendmail configured on the monitoring host to enable it to send you emails. Test both passwordless SSH and email (example: echo “text” | mailx -s “test email from `hostname`”

Save the script below as hostmon.ksh; chmod 755; and run as “nohup /full/path/to/hostmon.ksh /dev/null 2>&1 &”. The script will loop through a list of monitored clients. If a problem is detected, it will send you an email. At this point, the script will stop monitoring this particular client, so you will not receive duplicate emails.

# Simple remote host monitor using SSH. Requires passwordless SSH setup.

configure() {
        remotehosts="client1 client2 client3"

sshmon() {
        for i in ${remotehosts}
                ssh ${i} "uptime" ; status=$(echo $?)
                if [ ${status} -ne 0 ]
                        echo "`date` - Can't communicate with ${i}!"
                        echo "`date` - Can't communicate with ${i}!" | mailx -s "hostmon error on ${i}" "${email}"
                        remotehosts=$(echo "${remotehosts}" | sed "s/${i}//g" | sed 's/  //g')
                        if [ `echo ${remotehosts} | wc -m | awk '{print $1}'` -lt 3 ]

while [ 1 ]
        sleep ${interval}
Print Friendly, PDF & Email


  • Sergio says:

    I’m a comp. sci. major. This is my first time remotely accessing stuff I do at school (on Linux computers that have terminals that can run gvim in its own window) on my home computer (Windows using PuTTY to get to my files). Is there a way to get some kind of text editor like gvim to open in its own window?

    I get this when doing something like gvim

    E233: cannot open display
    Press ENTER or type command to continue

    And pressing enter just loads the file in the terminal window, which I’m not used to editing files in.

    If you know how to get a nice visual text editor to open up for me and can explain it in pretty simple terms, I’d be forever grateful :D

  • davemc74656 says:

    any ports and commands would be great

  • Heath says:

    I’m looking at running SSH on my school laptop because pretty much everything useful has been blocked, but I don’t want to run my home internet cap over by doing this. If i use an SSH tunnel to get past the proxy will I use up my home internet cap?

  • Joe M says:

    I have a JB iPhone 3G and I want to improve it’s ram memory but in order to follow the tutorials I have to SSH via WiFi. I don’t have Internet at home nether a router. I’m using MyWi for teetering.

  • Brian says:

    I have a jailbroken iPhone 3G. How do I download/get SSH on my iPhone so I can use Cyder and install apps from my computer. I need this because my wifi feature died and doing it from the computer is the only way I have left.

Leave a Reply

%d bloggers like this: