check_dell_warranty

IMPORTANT: The 3.x release only works with Python >= 2.6 (as in RHEL 6). The 3.x series also requires the python-requests package as well as the netsnmp-python bindings, if you are using SNMP.  check_dell_warranty will use SNMP, omreport, smbios or dmidecode to grab the system serial number, it will then make a query to Dell's website, parse the results, and print out a return.  By default a warning is issued when the warranty will expire in 30 days and critical is issued when it is going to expire in 10 days. These defaults can be changed on the command line.  Use ./check_dell_warranty --help for options.    A number of caveats: This was tested on Python 2.6 and above.  If you do not have OpenManage installed smbios will be used if not that than dmidecode will be used. Dmidecode needs to be of a newer version, for RedHat environments that means having at least RHEL 5, otherwise dmidecode does not support the 'system-serial-number' option. Smbios requires the plugin to be executed with root privileges dmidecode requires sudo privileges.  Outgoing HTTP connections will have to be enabled for the plugin to work.  omreport or dmidecode has to be in the $PATH.  Let me know if you run into any issues, or have any suggestions: erinn.looneytriggs@gmail.com  From ./check_dell_warranty.py -h:  Usage: check_dell_warranty [options]  Nagios plug-in to pull the  Dell service tag and check it against Dell's web site 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.  Options:  --version        show program's version number and exit  -h, --help       show this help message and exit  -a AUTHPROTOCOL     Set the default authentication protocol for SNMPv3             (MD5 or SHA).  -A AUTHPASSWORD     Set the SNMPv3 authentication protocol password.  -C COMMUNITY, --community=COMMUNITY             SNMP Community String to use. (Default: public)  -c , --critical=             Number of days under which to return critical             (Default: 10).  -H HOSTNAME, --hostname=HOSTNAME             Specify hostname for SNMP  -l SECLEVEL       Set the SNMPv3 security level,             (noAuthNoPriv|authNoPriv|authPriv) (Default:             noAuthNoPriv)  --mtk          Get SNMP Community String from /etc/mtk.conf if mtk-             nagios plugin is installed. NOTE: This option will             make the mtk.conf community string take precedence             over anything entered at the command line (Default:             False)  -p PORT, --port=PORT  Set the SNMP port to be connected to (Default:161).  -s , --serial-number=             Dell Service Tag of system, to enter more than one use             multiple flags (Default: auto-detected)  -S, --short       Display short output: only the status, service tag,             end date and days left for each warranty.  -t , --timeout=             Set the timeout for the program to run (Default: 10             seconds)  -u SECNAME       Set the SNMPv3 security name (user name).  -v VERSION       Specify the SNMP version (1, 2c, 3) Default: 3  -V           Give verbose output (Default: Off)  -w , --warning=             Number of days under which to return a warning             (Default: 30)  -x PRIVPROTOCOL     Set the SNMPv3 privacy protocol (DES or AES).  -X PRIVPASSWORD     Set the SNMPv3 privacy pass phrase.  ChangeLog: 2014-03-26 4.4: Fix for single warranty return issue, thanks actually to many people for sending in the same patch, sorry it took a bit, I was on an extended vacation.  2013-11-07 4.3: Code cleanup thanks to Will Yardley.  2013-11-04 4.2: Minor documentation updates.  2013-05-13 4.1: Catch SSL exceptions from requests module.  2013-04-09 4.0: Moved to using api.dell.com and changed out urllib2 in preference to the requests library.  2012-10-08 3.0.2: Add support for hyphen dates  2012-10-27 3.0.1: Dell dropped the counter for days left from their site, this is now calculated internally. Add patch for European style dates with periods between that numbers.  2012-09-05 3.0: Use Net-SNMP bindings for python allowing SNMPv3 support. Add debugging output using -V, Small cleanups.  2012-08-23 2.2.3: Merge in patch from Colin Panisset to dedup serials before mutex is created  2012-07-30 2.2.2: Make regex slightly more robust on scrape.  2012-07-03 2.2.1: Fix version number mismatch, fix urllib exception catch, thanks go to Sven Odermatt for finding that.  2012-02-09 2.2.0: Fix to work with new Dell website.  2010-07-19 2.1.2: Patch to again fix Dell's web page changes, thanks to Jim Browne http://blog.jbrowne.com/ as well as a patch to work against OM 5.3  2010-04-13 2.1.1: Change to deal with Dell's change to their website dropping the warranty extension field.  2009-12-17 2.1: Change format back to % to be compatible with python 2.4 and older.  2009-11-16 2.0: Fix formatting issues, change some variable names, fix a file open exception issue, Dell changed the interface so updated to work with that, new option --short for short output.  2009-08-07 1.9: Add smbios as a way to get the serial number. Move away from old string formatting to new string formatting.  2009-08-04 1.8: Improved the parsing of Dell's website, output is now much more complete (read larger) and includes all warranties. Thresholds are measured against the warranty with the greatest number of days remaining. This fixes the bug with doubled or even tripled warranty days being reported.  2009-07-24 1.7: SNMP support, DRAC - Remote Access Controller, CMC - Chassis Management Contorller and MD/PV Disk Enclosure support. A huge thanks to Harald Jensas for the code and Trond Amundsen for the testing and suggestions.  2009-07-09 1.6: Threads!  2009-06-25 1.5: Changed optparse to handle multiple serial numbers. Changed the rest of the program to be able to handle multiple serial numbers. Added a de-duper for serial numbers just in case you get two of the same from the command line or as is the case with Dell blades, two of the same from omreport. So this ought to handle blades, though I don't have any to test against.  2009-06-05 1.4 Changed optparse to display %default in help output. Pretty up the help output with ARG instead of variable names. Add description to optparse. Will now prefer omreport to dmidecode for systems that have omreport installed and in $PATH. Note, that you do not have to be root to run omreport and get the service tag.  2009-05-29 1.3 Display output for all warranties for a system. Add up the number of days left to give an accurate count of the time remaining. Fix basic check for Dell's database being down. Fixed regex to be non-greedy Start and end dates for warranty now takes all warranties into account. Date output is now yyyy-mm-dd because we don't all live in America ;)  2009-05-28 1.2 Added service tag to output for nagios. Fixed some typos. Added command-line option for specifying a serial number. This gets rid of the sudo dependency when you use -s as well as the newer python dependency allowing it to run on older RHEL distros. Thanks to Justin Ellison for the service tag option.  2009-05-27 Version 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.    Future plans (in no order): Output to file (In a format that is pretty) Read input(s) from file  Known bugs: