Automating the download of UNIX Health Check

It is easy to automate the download of the latest version of UNIX Health Check to your UNIX system. Doing so, removes the need for downloading UNIX Health Check manually each time a new version of UNIX Health Check is released, and removes the need to transfer the downloaded file onto your UNIX systems manually.

What do you need?
  • Install either curl or wget on your UNIX system, if not already installed. For AIX: These tools are not part of a regular AIX installation. You can download the RPM for these tools from the AIX Toolbox for Linux Applications. For Red Hat Enterprise Linux: You can use the familiar yum command to install the packages.
  • Your UNIX system needs Internet access, and needs to be able to resolve the "unixhealthcheck.com" domain through DNS.

    For example, test with a simple ping:
    # ping unixhealthcheck.com
  • You need a valid license for UNIX Health Check, which provides you a login (in the format of an email address) and a password to access the UNIX Health Check download page. If you are unable to download the UNIX Health Check software manually from the download page, then you won't be able to automate the download as well.
Examples of using curl and wget to download UNIX Health Check

Here's an example of how you can use curl to download the latest version of UNIX Health Check (assuming your login/email address is "user@email.com" and your password is "mypassword"):

For AIX:
curl -d "emailaddress=user@email.com&password=mypassword&os=$(uname)" \
   --referer http://www.unixhealthcheck.com \
   http://www.unixhealthcheck.com/downloadauto.php \
   -o ahc_latest.tar
For Red Hat Enterprise Linux, CentOS, Oracle Linux and Scientific Linux:
curl -d "emailaddress=user@email.com&password=mypassword&os=$(uname)" \
   --referer http://www.unixhealthcheck.com \
   http://www.unixhealthcheck.com/downloadauto.php \
   -o rhc_latest.tar
This command will download file ahc_latest.tar or rhc_latest.tar in your current folder. Please note that providing the email address, password and referer is required. Without it, the download will fail.

The same download can be accomplished with wget:

For AIX:
wget --post-data \
   "emailaddress=user@email.com&password=mypassword&os=$(uname)" \
   --referer=http://www.unixhealthcheck.com \
   http://www.unixhealthcheck.com/downloadauto.php \
   -O ahc_latest.tar
For Red Hat Enterprise Linux, CentOS, Oracle Linux and Scientific Linux:
wget --post-data \
   "emailaddress=user@email.com&password=mypassword&os=$(uname)" \
   --referer=http://www.unixhealthcheck.com \
   http://www.unixhealthcheck.com/downloadauto.php \
   -O rhc_latest.tar
Once you have downloaded the ahc_latest.tar or rhc_latest.tar file, you will be able to un-pack the file and use UNIX Health Check.

Automating download with a script

You can automate downloading UNIX Health Check easily with the use of a shell script. The script that is shown below downloads UNIX Health Check with the use of wget, will un-pack the downloaded file, run UNIX Health Check, send an HTML style report through email, and clean up afterwards.

For AIX:
#!/usr/bin/ksh
 
# VARIABLES
emailaddress="user@email.com"
password="mypassword"
folder="/uhc"
wget="/usr/bin/wget"
myfile="ahc_latest.tar"
 
# Test if folder already exists.
if [ -d ${folder} ] ; then
        echo "Folder ${folder} already exists. Aborting."
        exit
fi
 
# Test if wget is executable.
if [ ! -x ${wget} ] ; then
        echo "Wget does not exist or is not executable. Aborting."
        exit
fi
 
# Create a folder to store UNIX Health Check:
echo "Creating folder ${folder}..."
mkdir -p ${folder}
 
# Download the file.
echo "Downloading UNIX Health Check..."
${wget} --post-data \
   "emailaddress=$emailaddress&password=$password&os=$(uname)" \
   --referer=http://www.unixhealthcheck.com \
   http://www.unixhealthcheck.com/downloadauto.php \
   -O ${folder}/${myfile} >/dev/null 2>&1
 
# Un-pack the downloaded file.
if [ -s ${folder}/${myfile} ] ; then
        cd ${folder}
        echo "Un-packing the downloaded file..."
        tar -xvf ${folder}/${myfile} >/dev/null 2>&1
        cd - >/dev/null 2>&1
        echo "Removing downloaded file..."
        rm -f ${folder}/${myfile}
 
        # Run UNIX Health Check.
        if [ -x ${folder}/checkall.ksh ] ; then
                echo "Running UNIX Health Check..."
		${folder}/checkall.ksh -hdm ${emailaddress}
                echo "Removing folder ${folder}..."
                rm -rf ${folder}
        else
                echo "Encountered an error with checkall."
                echo "Removing folder ${folder}..."
                rm -rf ${folder}
                exit
        fi
else
        echo "Error downloading UNIX Health Check."
        echo "Removing folder ${folder}..."
        rm -rf ${folder}
        exit
fi
For Red Hat Enterprise Linux, CentOS, Oracle Linux and Scientific Linux:
#!/bin/bash
 
# VARIABLES
emailaddress="user@email.com"
password="mypassword"
folder="/uhc"
wget="/bin/wget"
myfile="rhc_latest.tar"
 
# Test if folder already exists.
if [ -d ${folder} ] ; then
        echo "Folder ${folder} already exists. Aborting."
        exit
fi
 
# Test if wget is executable.
if [ ! -x ${wget} ] ; then
        echo "Wget does not exist or is not executable. Aborting."
        exit
fi
 
# Create a folder to store UNIX Health Check:
echo "Creating folder ${folder}..."
mkdir -p ${folder}
 
# Download the file.
echo "Downloading UNIX Health Check..."
${wget} --post-data \
   "emailaddress=$emailaddress&password=$password&os=$(uname)" \
   --referer=http://www.unixhealthcheck.com \
   http://www.unixhealthcheck.com/downloadauto.php \
   -O ${folder}/${myfile} >/dev/null 2>&1
 
# Un-pack the downloaded file.
if [ -s ${folder}/${myfile} ] ; then
        cd ${folder}
        echo "Un-packing the downloaded file..."
        tar -xvf ${folder}/${myfile} >/dev/null 2>&1
        cd - >/dev/null 2>&1
        echo "Removing downloaded file..."
        rm -f ${folder}/${myfile}
 
        # Run UNIX Health Check.
        if [ -x ${folder}/checkall.sh ] ; then
                echo "Running UNIX Health Check..."
		${folder}/checkall.sh -hdm ${emailaddress}
                echo "Removing folder ${folder}..."
                rm -rf ${folder}
        else
                echo "Encountered an error with checkall."
                echo "Removing folder ${folder}..."
                rm -rf ${folder}
                exit
        fi
else
        echo "Error downloading UNIX Health Check."
        echo "Removing folder ${folder}..."
        rm -rf ${folder}
        exit
fi
The script above can be used to download UNIX Health Check to your UNIX system in folder /uhc. Please make sure to provide the correct login/email address and password combination in the beginning of the script for variables email address and password, and if you wish to specify a different location for storing UNIX Health Check, you can change this in the script as well, by updating the folder variable.

The output of the script above, will look like this (assuming you have named the script "run-uhc"):
# ./run-uhc
Creating folder /uhc...
Downloading UNIX Health Check...
Un-packing the downloaded file...
Removing downloaded file...
Running UNIX Health Check...
Removing folder /uhc...