1 Title: Checking server hardware support status for Dell, HP and IBM servers
5 <p>At work, we have a few hundred Linux servers, and with that amount
6 of hardware it is important to keep track of when the hardware support
7 contract expire for each server. We have a machine (and service)
8 register, which until recently did not contain much useful besides the
9 machine room location and contact information for the system owner for
10 each machine. To make it easier for us to track support contract
11 status, I've recently spent time on extending the machine register to
12 include information about when the support contract expire, and to tag
13 machines with expired contracts to make it easy to get a list of such
14 machines. I extended a perl script already being used to import
15 information about machines into the register, to also do some screen
16 scraping off the sites of Dell, HP and IBM (our majority of machines
17 are from these vendors), and automatically check the support status
18 for the relevant machines. This make the support status information
19 easily available and I hope it will make it easier for the computer
20 owner to know when to get new hardware or renew the support contract.
21 The result of this work documented that 27% of the machines in the
22 registry is without a support contract, and made it very easy to find
23 them. 27% might seem like a lot, but I see it more as the case of us
24 using machines a bit longer than the 3 years a normal support contract
25 last, to have test machines and a platform for less important
26 services. After all, the machines without a contract are working fine
27 at the moment and the lack of contract is only a problem if any of
28 them break down. When that happen, we can either fix it using spare
29 parts from other machines or move the service to another old
32 <p>I believe the code for screen scraping the Dell site was originally
33 written by Trond Hasle Amundsen, and later adjusted by me and Morten
34 Werner Forsbring. The HP scraping was written by me after reading a
35 nice article in ;login: about how to use WWW::Mechanize, and the IBM
36 scraping was written by me based on the Dell code. I know the HTML
37 parsing could be done using nice libraries, but did not want to
38 introduce more dependencies. This is the current incarnation:</p>
46 sub get_support_info {
47 my ($machine, $model, $serial, $productnumber) = @_;
50 if ( $model =~ m/^Dell / ) {
51 # fetch website from Dell support
52 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";
53 my $webpage = get($url);
54 return undef unless ($webpage);
57 my @lines = split(/\n/, $webpage);
58 foreach my $line (@lines) {
59 next unless ($line =~ m/Beskrivelse/);
60 $line =~ s/<[^>]+?>/;/gm;
61 $line =~ s/^.+?;(Beskrivelse;)/$1/;
63 my @f = split(/\;/, $line);
66 while ($f[3] eq "DELL") {
67 my ($type, $startstr, $endstr, $days) = @f[0, 5, 7, 10];
69 my $start = POSIX::strftime("%Y-%m-%d",
70 localtime(str2time($startstr)));
71 my $end = POSIX::strftime("%Y-%m-%d",
72 localtime(str2time($endstr)));
73 $str .= "$type $start -> $end ";
75 $lastend = $end if ($end gt $lastend);
77 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
78 tag_machine_unsupported($machine)
79 if ($lastend lt $today);
81 } elsif ( $model =~ m/^HP / ) {
82 my $mech = WWW::Mechanize->new();
84 'http://www1.itrc.hp.com/service/ewarranty/warrantyInput.do';
87 'BODServiceID' => 'NA',
88 'RegisteredPurchaseDate' => '',
90 'productNumber' => $productnumber,
91 'serialNumber1' => $serial,
93 $mech->submit_form( form_number => 2,
95 # Next step is screen scraping
96 my $content = $mech->content();
98 $content =~ s/<[^>]+?>/;/gm;
99 $content =~ s/\s+/ /gm;
100 $content =~ s/;\s*;/;;/gm;
101 $content =~ s/;[\s;]+/;/gm;
103 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
105 while ($content =~ m/;Warranty Type;/) {
106 my ($type, $status, $startstr, $stopstr) = $content =~
107 m/;Warranty Type;([^;]+);.+?;Status;(\w+);Start Date;([^;]+);End Date;([^;]+);/;
108 $content =~ s/^.+?;Warranty Type;//;
109 my $start = POSIX::strftime("%Y-%m-%d",
110 localtime(str2time($startstr)));
111 my $end = POSIX::strftime("%Y-%m-%d",
112 localtime(str2time($stopstr)));
114 $str .= "$type ($status) $start -> $end ";
116 tag_machine_unsupported($machine)
119 } elsif ( $model =~ m/^IBM / ) {
120 # This code ignore extended support contracts.
121 my ($producttype) = $model =~ m/.*-\[(.{4}).+\]-/;
122 if ($producttype && $serial) {
124 get("http://www-947.ibm.com/systems/support/supportsite.wss/warranty?action=warranty&brandind=5000008&Submit=Submit&type=$producttype&serial=$serial");
126 $content =~ s/<[^>]+?>/;/gm;
127 $content =~ s/\s+/ /gm;
128 $content =~ s/;\s*;/;;/gm;
129 $content =~ s/;[\s;]+/;/gm;
131 $content =~ s/^.+?;Warranty status;//;
132 my ($status, $end) = $content =~ m/;Warranty status;([^;]+)\s*;Expiration date;(\S+) ;/;
134 $str .= "($status) -> $end ";
136 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
137 tag_machine_unsupported($machine)
146 <p>Here are some examples on how to use the function, using fake
147 serial numbers. The information passed in as arguments are fetched
151 print get_support_info("hp.host", "HP ProLiant BL460c G1", "1234567890"
153 print get_support_info("dell.host", "Dell Inc. PowerEdge 2950", "1234567");
154 print get_support_info("ibm.host", "IBM eserver xSeries 345 -[867061X]-",
158 <p>I would recommend this approach for tracking support contracts for
159 everyone with more than a few computers to administer. :)</p>
161 <p>Update 2009-03-06: The IBM page do not include extended support
162 contracts, so it is useless in that case. The original Dell code do
163 not handle extended support contracts either, but has been updated to