{"id":17,"date":"2010-07-17T13:47:47","date_gmt":"2010-07-17T20:47:47","guid":{"rendered":"http:\/\/blog.jbrowne.com\/?p=17"},"modified":"2010-07-17T13:48:05","modified_gmt":"2010-07-17T20:48:05","slug":"quick-fixes-for-nagios-plug-in-check_dell_warranty","status":"publish","type":"post","link":"http:\/\/blog.jbrowne.com\/?p=17","title":{"rendered":"Quick fixes for NAGIOS plug-in check_dell_warranty"},"content":{"rendered":"<p>Erinn Looney-Triggs wrote a nice <a href=\"http:\/\/www.monitoringexchange.org\/inventory\/Check-Plugins\/Hardware\/Server-%2528Manufacturer%2529\/Dell\/check_dell_warranty\">plug-in for NAGIOS<\/a> to check the  warranty status of your Dell boxes with Dell.\u00a0 However, some of the systems I support are running a seriously old version of Dell OMSA.\u00a0 I sent him a quick patch back in May to handle old OMSA versions:<\/p>\n<pre>[root@x plugins]# diff -p check_dell_warranty\r\ncheck_dell_warranty_test\r\n*** check_dell_warranty\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Thu Apr 15 14:27:43 2010\r\n--- check_dell_warranty_test\u00a0 Thu May\u00a0 6 11:45:16 2010\r\n*************** def extract_serial_number_snmp( hostname\r\n*** 314,319 ****\r\n--- 314,320 ----\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hostname,\r\ncommunity_string).split('\\n')\r\n&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for encl_id in snmp_out:\r\n+\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if not encl_id: continue\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #Get enclosure type.\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u00a0\u00a0 1: Internal\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u00a0\u00a0 2: DellTM PowerVaultTM 200S (PowerVault 201S)<\/pre>\n<p>This morning it looks like Dell has a few back-end servers that are serving up an older version of the warranty status table.\u00a0 I put together a quick patch to handle either warranty status table returned by Dell:<\/p>\n<pre>[root@x plugins]# diff -p check_dell_warranty- check_dell_warranty\r\n\r\n<pre>*** check_dell_warranty-\u00a0\u00a0 \u00a0Thu May\u00a0 6 11:47:42 2010\r\n--- check_dell_warranty\u00a0\u00a0 \u00a0Sat Jul 17 13:24:29 2010\r\n*************** def get_warranty(serial_numbers):\r\n*** 438,444 ****\r\n\r\n return result_list\r\n\r\n! def parse_exit(result_list, short_output=False):\r\n '''This parses the results from the get_warranty() function and outputs\r\n the appropriate information.\r\n '''\r\n--- 437,443 ----\r\n\r\n return result_list\r\n\r\n! def parse_exit(result_list, debug, short_output=False):\r\n '''This parses the results from the get_warranty() function and outputs\r\n the appropriate information.\r\n '''\r\n*************** def parse_exit(result_list, short_output\r\n*** 505,515 ****\r\n warranties = parse_table(match)\r\n\r\n #Remove the header lines.\r\n!\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 warranties.pop(0)\r\n!\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\n for entry in warranties:\r\n!\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (description, provider, start_date, end_date,\r\n!\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 days_left) = entry[0:5]\r\n\r\n #Convert the dates to international standard\r\n start_date = str(i8n_date(start_date))\r\n--- 504,524 ----\r\n warranties = parse_table(match)\r\n\r\n #Remove the header lines.\r\n!\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 header = warranties.pop(0)\r\n!\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 notice_present = (header[2].find(\"Warranty\") &gt;= 0)\r\n! \u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0 if debug:\r\n! \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0print \"header is %s\", header\r\n! \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0print \"notice_present is \", notice_present\r\n!\r\n for entry in warranties:\r\n! \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0if debug:\r\n! \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0print \"entry is %s\", entry\r\n! \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0if notice_present:\r\n!\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0(description, provider, notice, start_date, end_date,\r\n!\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0days_left) = entry[0:6]\r\n! \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0else:\r\n!\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0(description, provider, start_date, end_date,\r\n!\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0days_left) = entry[0:5]\r\n\r\n #Convert the dates to international standard\r\n start_date = str(i8n_date(start_date))\r\n*************** remaining. These values can be adjusted\r\n*** 633,638 ****\r\n--- 642,652 ----\r\n help=('Number of days under which to return a warning '\r\n '(Default: %default)'), type='int', metavar='&lt;ARG&gt;' )\r\n\r\n+\u00a0\u00a0\u00a0\u00a0 parser.add_option('-d', '--debug', dest='debug', action=\"store_true\",\r\n+\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 default=False,\r\n+\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 help=('Print debugging information '\r\n+\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 '(Default: %default)'), metavar='&lt;ARG&gt;' )\r\n+\u00a0\u00a0\u00a0 \u00a0\r\n (options, args) = parser.parse_args()\r\n\r\n signal.signal(signal.SIGALRM, sigalarm_handler)\r\n*************** remaining. These values can be adjusted\r\n*** 651,654 ****\r\n\r\n signal.alarm(0)\r\n\r\n!\u00a0\u00a0\u00a0\u00a0 parse_exit(RESULT, options.short_output)\r\n--- 665,668 ----\r\n\r\n signal.alarm(0)\r\n\r\n!\u00a0\u00a0\u00a0\u00a0 parse_exit(RESULT, options.debug, options.short_output)\r\n<\/pre>\n<p>I should really use a name mapping hash and should probably use a better debug logging method, but this was a quick fix for a Saturday morning.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Erinn Looney-Triggs wrote a nice plug-in for NAGIOS to check the warranty status of your Dell boxes with Dell.\u00a0 However, some of the systems I support are running a seriously old version of Dell OMSA.\u00a0 I sent him a quick patch back in May to handle old OMSA versions: [root@x plugins]# diff -p check_dell_warranty check_dell_warranty_test [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,7],"tags":[],"class_list":["post-17","post","type-post","status-publish","format-standard","hentry","category-nagios","category-systems-administration"],"_links":{"self":[{"href":"http:\/\/blog.jbrowne.com\/index.php?rest_route=\/wp\/v2\/posts\/17","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.jbrowne.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.jbrowne.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.jbrowne.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.jbrowne.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17"}],"version-history":[{"count":5,"href":"http:\/\/blog.jbrowne.com\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":22,"href":"http:\/\/blog.jbrowne.com\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions\/22"}],"wp:attachment":[{"href":"http:\/\/blog.jbrowne.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.jbrowne.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.jbrowne.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}