X-Git-Url: http://pere.pagekite.me/gitweb/homepage.git/blobdiff_plain/a93d61e1567d5836402fdadf90f5380108df5d0b..60bf8a3f215da8c82ec727e3045793dea8edd5a8:/blog/archive/2009/02/index.html diff --git a/blog/archive/2009/02/index.html b/blog/archive/2009/02/index.html index 1175b02540..57a3795dc6 100644 --- a/blog/archive/2009/02/index.html +++ b/blog/archive/2009/02/index.html @@ -364,7 +364,7 @@ scraping was written by me based on the Dell code. I know the HTML parsing could be done using nice libraries, but did not want to introduce more dependencies. This is the current incarnation:
-+use LWP::Simple; use POSIX; use WWW::Mechanize; @@ -376,7 +376,7 @@ sub get_support_info { if ( $model =~ m/^Dell / ) { # fetch website from Dell support - my $url = "http://support.euro.dell.com/support/topics/topic.aspx/emea/shared/support/my_systems_info/no/details?c=no&cs=nodhs1&l=no&s=dhs&ServiceTag=$serial"; + my $url = "http://support.euro.dell.com/support/topics/topic.aspx/emea/shared/support/my_systems_info/no/details?c=no&cs=nodhs1&l=no&s=dhs&ServiceTag=$serial"; my $webpage = get($url); return undef unless ($webpage); @@ -384,14 +384,26 @@ sub get_support_info { my @lines = split(/\n/, $webpage); foreach my $line (@lines) { next unless ($line =~ m/Beskrivelse/); - $line =~ s/<[^>]+?>/;/gm; - $line =~ m%;(\d{2})/(\d{2})/(\d{4});+(\d{2})/(\d{2})/(\d{4});%g; - my $start = "$3-$1-$2"; - my $end = "$6-$4-$5"; - $str = "$start -> $end"; + $line =~ s/<[^>]+?>/;/gm; + $line =~ s/^.+?;(Beskrivelse;)/$1/; + + my @f = split(/\;/, $line); + @f = @f[13 .. $#f]; + my $lastend = ""; + while ($f[3] eq "DELL") { + my ($type, $startstr, $endstr, $days) = @f[0, 5, 7, 10]; + + my $start = POSIX::strftime("%Y-%m-%d", + localtime(str2time($startstr))); + my $end = POSIX::strftime("%Y-%m-%d", + localtime(str2time($endstr))); + $str .= "$type $start -> $end "; + @f = @f[14 .. $#f]; + $lastend = $end if ($end gt $lastend); + } my $today = POSIX::strftime("%Y-%m-%d", localtime(time)); tag_machine_unsupported($machine) - if ($end lt $today); + if ($lastend lt $today); } } elsif ( $model =~ m/^HP / ) { my $mech = WWW::Mechanize->new(); @@ -410,7 +422,7 @@ sub get_support_info { # Next step is screen scraping my $content = $mech->content(); - $content =~ s/<[^>]+?>/;/gm; + $content =~ s/<[^>]+?>/;/gm; $content =~ s/\s+/ /gm; $content =~ s/;\s*;/;;/gm; $content =~ s/;[\s;]+/;/gm; @@ -432,12 +444,13 @@ sub get_support_info { if ($end lt $today); } } elsif ( $model =~ m/^IBM / ) { + # This code ignore extended support contracts. my ($producttype) = $model =~ m/.*-\[(.{4}).+\]-/; - if ($producttype && $serial) { + 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"); + 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/<[^>]+?>/;/gm; $content =~ s/\s+/ /gm; $content =~ s/;\s*;/;;/gm; $content =~ s/;[\s;]+/;/gm; @@ -455,22 +468,27 @@ sub get_support_info { } return $str; } -+
Here are some examples on how to use the function, using fake serial numbers. The information passed in as arguments are fetched from dmidecode.
-+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"); -+
I would recommend this approach for tracking support contracts for -everyone with more than a new computers to administer. :)
+everyone with more than a few computers to administer. :) + +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.