- $content =~ s/<[^>]+?>/;/gm;
- $content =~ s/\s+/ /gm;
- $content =~ s/;\s*;/;;/gm;
- $content =~ s/;[\s;]+/;/gm;
-
- my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
-
- while ($content =~ m/;Warranty Type;/) {
- my ($type, $status, $startstr, $stopstr) = $content =~
- m/;Warranty Type;([^;]+);.+?;Status;(\w+);Start Date;([^;]+);End Date;([^;]+);/;
- $content =~ s/^.+?;Warranty Type;//;
- my $start = POSIX::strftime("%Y-%m-%d",
- localtime(str2time($startstr)));
- my $end = POSIX::strftime("%Y-%m-%d",
- localtime(str2time($stopstr)));
-
- $str .= "$type ($status) $start -> $end ";
-
- tag_machine_unsupported($machine)
- if ($end lt $today);
- }
- } elsif ( $model =~ m/^IBM / ) {
- # This code ignore extended support contracts.
- my ($producttype) = $model =~ m/.*-\[(.{4}).+\]-/;
- if ($producttype && $serial) {
- my $content =
- get("http://www-947.ibm.com/systems/support/supportsite.wss/warranty?action=warranty&brandind=5000008&Submit=Submit&type=$producttype&serial=$serial");
- if ($content) {
- $content =~ s/<[^>]+?>/;/gm;
- $content =~ s/\s+/ /gm;
- $content =~ s/;\s*;/;;/gm;
- $content =~ s/;[\s;]+/;/gm;
-
- $content =~ s/^.+?;Warranty status;//;
- my ($status, $end) = $content =~ m/;Warranty status;([^;]+)\s*;Expiration date;(\S+) ;/;
-
- $str .= "($status) -> $end ";
-
- my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
- tag_machine_unsupported($machine)
- if ($end lt $today);
- }
- }
- }
- return $str;
-}
-</pre>
-
-<p>Here are some examples on how to use the function, using fake
-serial numbers. The information passed in as arguments are fetched
-from dmidecode.</p>
-
-<pre>
-print get_support_info("hp.host", "HP ProLiant BL460c G1", "1234567890"
- "447707-B21");
-print get_support_info("dell.host", "Dell Inc. PowerEdge 2950", "1234567");
-print get_support_info("ibm.host", "IBM eserver xSeries 345 -[867061X]-",
- "1234567");
-</pre>
-
-<p>I would recommend this approach for tracking support contracts for
-everyone with more than a few computers to administer. :)</p>
-
-<p>Update 2009-03-06: The IBM page do not include extended support
-contracts, so it is useless in that case. The original Dell code do
-not handle extended support contracts either, but has been updated to
-do so.</p>