====== My Monitor (CHANGEME) ====== ^ Author | [[ butchdeal@yahoo.com | Butch Deal ]] | ^ Compatibility | Xymon 4.2 | ^ Requirements | Linux, python, dmidecode | ^ Download | None | ^ Last Update | 2009-06-02 | ===== Description ===== 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 ===== Installation ===== === Client side === Configure sudo so that dmidecode can be run. add these lines to the clientlaunch.cfg file: [warranty] ENVFILE $HOBBITCLIENTHOME/etc/hobbitclient.cfg CMD $HOBBITCLIENTHOME/ext/check_dell_warranty.py LOGFILE $HOBBITCLIENTHOME/logs/check-warranty.log INTERVAL 1d === Server side === ===== Source ===== ==== check_dell_warranty.py ==== #!/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 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 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 # CMD $HOBBITCLIENTHOME/ext/check_dell_warranty.py # 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 try: p = subprocess.Popen(["sudo", "dmidecode", "-s", "system-serial-number"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) except OSError: print 'Error:', sys.exc_value, 'exiting!' sys.exit(1) #Strip the newline off of result serial_number = p.stdout.read() #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) sys.exit(WARNING) return serial_number.strip() def get_warranty(serial_number): global LINE #The URL to Dell's site # dell_url='http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&ServiceTag=' dell_url='http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?ServiceTag=' #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 ===== Known Bugs and Issues ===== 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. ===== To Do ===== Someone that knows python could really clean this up and probably easily add some features. (please do). ===== Credits ===== * Original Nagios author: Erinn Looney-Triggs * port to Xymon: Butch Deal ===== Changelog ===== * **YYYY-MM-DD** * Initial release