My Monitor (CHANGEME)

Author Butch Deal
Compatibility Xymon 4.2
Requirements Linux, python, dmidecode
Download None
Last Update 2009-06-02

Check the Dell service tag against the Dell website to see how many days are remaining of warranty.

returns this information:

Warranty start date: 12/8/2008
End Date: 1/17/2010
Days Left : 229 green
Serial Number: C2T8L61

Client side

Configure sudo so that dmidecode can be run. add these lines to the clientlaunch.cfg file:

	ENVFILE $HOBBITCLIENTHOME/etc/hobbitclient.cfg
	LOGFILE $HOBBITCLIENTHOME/logs/check-warranty.log

Server side

Show Code ⇲

Hide Code ⇱

#!/usr/bin/env python

# Nagios plugin to pull the Dell service tag and check it 
# against Dell's website to see how many days remain. By default it 
# issues a warning when there is less than thirty days remaining and critical when 
# there is less than ten days remaining. These values can be adjusted using
# the command line, see --help.                                                 
# Version: 1.1                                                                
# Created: 2009-02-12                                                         
# Author: Erinn Looney-Triggs                                                 
# Revised: 2009-05-27                                                                
# Revised by: Erinn Looney-Triggs                                                                 
# Revision history:
# 1.1 Fixed string conversions to do int comparisons properly. Remove import
# csv as I am not using that yet. Add a license to the file.  
# License:
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    GNU General Public License for more details.
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <>.
#  Ported to Xymon by Butch Deal of GreenIT Corp.
# needs sudo dmidecode capabilities for serial number
#  sudo dmidecode -s system-serial-number
# add these lines to  etc/clientlaunch.cfg
#  [warranty]
#        ENVFILE $HOBBITCLIENTHOME/etc/hobbitclient.cfg
#        LOGFILE $HOBBITCLIENTHOME/logs/check-warranty.log
#        INTERVAL 1d

import re
import subprocess
import sys
import urllib2

# converted to Xymon
LINE = ""

def extract_serial_number():
    '''Extracts the serial number from the localhost using dmidecode.
    This function takes no arguments but expects dmidecode to exist and
    also expects dmidecode to accept -s system-serial-number
    #Gather the information from dmidecode
        p = subprocess.Popen(["sudo", "dmidecode", "-s",
    except OSError:
        print 'Error:', sys.exc_value, 'exiting!'
    #Strip the newline off of result
    serial_number =
    #Basic check of the serial number, can they be longer, maybe
    if len( serial_number.strip() ) != 7:
        print 'Invalid serial number:%s exiting!' % (serial_number)
    return serial_number.strip()

def get_warranty(serial_number):
    global LINE
    #The URL to Dell's site
#    dell_url=''

    #Regex to pull the information from Dell's site
    pattern=r""".*>                          #Match anything up to >
                (\d{1,2}/\d{1,2}/\d{4})<     #Match North American style date
                .*>(\d{1,2}/\d{1,2}/\d{4})<  #Match date, good for 8000 years
                .*>                          #Match anything up to >
                (\d+)                        #Match number of days
                <.*                          #Match <and the rest of the line
    #Build the full
    full_url = dell_url + serial_number
    LINE = LINE + full_url
    #Try to open the page, exit on failure
        response = urllib2.urlopen(full_url)
    except URLError:
        print 'Unable to open URL: %s exiting!' % (full_url)
    #Build our regex
    regex = re.compile(pattern, re.X)

    #Gather the results returns a list of tuples
    result = regex.findall(
    return result

def parse_exit(result):
    global LINE
    if len(result) == 0:
        print "Dell's database appears to be down for this system."
    start_date, end_date, days_left = result[0]
    COLOR = "green"
    if int(days_left) < options.critical_days:
	COLOR = "red"
    elif int(days_left) < options.warning_days:
	COLOR = "yellow"
	COLOR = "green"
    LINE = LINE + "\nWarranty start date: " + start_date + "\nEnd Date: " + end_date + "\nDays Left : " + days_left + " &" + COLOR
    return COLOR
def sigalarm_handler(signum, frame):
    print '%s timed out after %d seconds' % (sys.argv[0], options.timeout)
if __name__ == '__main__':
    import optparse
    import signal
    import os
    from datetime import date, datetime, timedelta

    BB = os.environ["BB"]
    BBDISP = os.environ["BBDISP"]
    MACHINE = os.environ["MACHINE"]

    parser = optparse.OptionParser(version="%prog 1.1")
    parser.add_option('-c', '--critical', dest='critical_days', default=10,
                     help='Number of days under which to return critical \
                     (Default: 10)', type='int')
    parser.add_option('-t', '--timeout', dest='timeout', default=10,
                      help='Set the timeout for the program to run \
                      (Default: 10 seconds)', type='int')
    parser.add_option('-w', '--warning', dest='warning_days', default=30,
                      help='Number of days under which to return a warning \
                      (Default: 30)', type='int' )
    (options, args) = parser.parse_args()
    signal.signal(signal.SIGALRM, sigalarm_handler)
    serial_number = extract_serial_number()
    result = get_warranty(serial_number)
    COLOR = parse_exit(result)

#    d = + timedelta(hours=24)
    d =
    P1 = "\"status+25h " + MACHINE + ".support " + COLOR + d.strftime(" %a %b %d %H:%M:%S %Z %Y") + " - \n" + LINE + "\nSerial Num
ber: " + serial_number + "\""
    LL = BB + " " + BBDISP + " " + P1
#    print '%s' % (LL)

some servers have multiple lines of support on the dell site. the script only uses the bottom line though occasionally one of the other lines has longer support.

Someone that knows python could really clean this up and probably easily add some features. (please do).

  • Original Nagios author: Erinn Looney-Triggs
  • port to Xymon: Butch Deal
    • Initial release
  • monitors/dell-warranty.txt
  • Last modified: 2009/11/23 05:43
  • (external edit)