Today’s sysadmin tip: Monitoring Dell support contracts

We have quite a few Dell boxes. They tend to work allright, but from time to time, we need to call Dell, and make them change a broken thingamajing. When we do, it’s never a good feeling to hear that your support contract ended just a week ago, so sorry, goodbye.

While Dell have been better on selling support contract renewals, I have gone through my boxes from time to time to make sure that their support contracts are still valid. Takes a lot of browsing and time, so hey, why not automate it.

Here’s check_dell_support – a small script that does the trick for you. DO NOT PUT THIS INTO PRODUCTION for a lot of boxes without taking care of spreading the load out over time. I don’t want a call from some Dell techie who tells me my script is hammering his web server down every whole hour or something :-)

The script will probably work until Dell changes their web pages. It uses the Dell service tag, so you have to know it. You also need to have curl installed.

Updates:

  • Added a -L option to curl to make it do redirects, needed by users in the US
  • Added an extra filter to fix an error when the counter reaches 0
  • Added a check if the server state could not be reached, resulting in UNKNOWN (mortis)
#!/bin/bash
#
# check_dell_support
# check your Dell system support contract
#

crit=2
warn=30

if [ "$1" = "" ]
then
        echo usage: $0 servicetag
        exit 0
fi

tag=$1

URL='http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&servicetag='

days=$(
        curl -L -s "${URL}${tag}" | \
        sed -rn 's/.+Days Left.+class="contract_oddrow">[<font color="red"><b>]*([0-9]+).*/\1/p' 
)

if [ -z $days ]; then
        echo "UNKNOWN: Could not retrieve info from support.dell.com."
        exit 3
fi

if (( days <= crit ))
then
        echo "CRITICAL: $tag has less than $crit days of hardware support ($days days left)"
        exit 2

elif (( days <= warn ))
then
        echo "WARNING: $tag has less than $warn days of hardware support ($days days left)"
        exit 2

else
        echo "OK: $tag has more than $warn days of hardware support ($days days left)"
        exit 0
fi

9 Responses to “Today’s sysadmin tip: Monitoring Dell support contracts”

  1. Scott Baker says:

    I tried your script and I don’t get correct results.

    bakers@snikt(/tmp)
    :sh dell_warranty.sh 2gc1yd1
    CRITICAL: 2gc1yd1 has less than 2 days of hardware support ( days left)

    But if I go to that url I see the correct data.

  2. Shane Falco says:

    I had to change around the if/then block to avoid syntax errors (older bash?) but once I changed that it’s been clear sailing. Great script! Thanks!

  3. Ingvar says:

    Scott: The US version of that page uses a redirect. Add a -L option to curl in the script, and it should work.

    Shane: What changes did you have to do? Check that your script starts with #!/bin/bash. /bin/sh won’t do, as the (( … )) arithmetics are bash only.

    Ingvar

  4. Shane Falco says:

    I just changed it to the old ksh [ ] style. With bash 3.2.25 I received syntax errors on yours (cut-and-pasted directly from this page).

  5. ingvar says:

    Shane, I guess you called the script with the wrong interpreter. It works well with bash-3.2.39 and bash-3.1.17.

    Ingvar

  6. Shane Falco says:

    Ignore the above. Apparently I was getting redirected initially which was causing the script to bomb. At the same time I was messing around with the conditional block my requests started going through which made it appear that the if block change fixed it. I’ll go sit in the dunce chair now. :)

  7. mortis says:

    Hi!
    Thanks for this. I’ve implemented it for our company and it works good.
    Just noticed tho, that the plugin exited with a CRITICAL if it couldnt look up the info at dells webpages, so i added a few lines to the script :

    if [ -z $days ]; then
    echo “UNKNOWN: Could not retrieve info from support.dell.com.”
    exit 3
    fi

Leave a Reply