1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" dir=
"ltr">
5 <meta http-equiv=
"Content-Type" content=
"text/html;charset=utf-8" />
6 <title>Petter Reinholdtsen: Checking server hardware support status for Dell, HP and IBM servers
</title>
7 <link rel=
"stylesheet" type=
"text/css" media=
"screen" href=
"http://people.skolelinux.org/pere/blog/style.css" />
8 <link rel=
"stylesheet" type=
"text/css" media=
"screen" href=
"http://people.skolelinux.org/pere/blog/vim.css" />
13 <a href=
"http://people.skolelinux.org/pere/blog/">Petter Reinholdtsen
</a>
21 <div class=
"title">Checking server hardware support status for Dell, HP and IBM servers
</div>
22 <div class=
"date">28th February
2009</div>
23 <div class=
"body"><p>At work, we have a few hundred Linux servers, and with that amount
24 of hardware it is important to keep track of when the hardware support
25 contract expire for each server. We have a machine (and service)
26 register, which until recently did not contain much useful besides the
27 machine room location and contact information for the system owner for
28 each machine. To make it easier for us to track support contract
29 status, I've recently spent time on extending the machine register to
30 include information about when the support contract expire, and to tag
31 machines with expired contracts to make it easy to get a list of such
32 machines. I extended a perl script already being used to import
33 information about machines into the register, to also do some screen
34 scraping off the sites of Dell, HP and IBM (our majority of machines
35 are from these vendors), and automatically check the support status
36 for the relevant machines. This make the support status information
37 easily available and I hope it will make it easier for the computer
38 owner to know when to get new hardware or renew the support contract.
39 The result of this work documented that
27% of the machines in the
40 registry is without a support contract, and made it very easy to find
41 them.
27% might seem like a lot, but I see it more as the case of us
42 using machines a bit longer than the
3 years a normal support contract
43 last, to have test machines and a platform for less important
44 services. After all, the machines without a contract are working fine
45 at the moment and the lack of contract is only a problem if any of
46 them break down. When that happen, we can either fix it using spare
47 parts from other machines or move the service to another old
50 <p>I believe the code for screen scraping the Dell site was originally
51 written by Trond Hasle Amundsen, and later adjusted by me and Morten
52 Werner Forsbring. The HP scraping was written by me after reading a
53 nice article in ;login: about how to use WWW::Mechanize, and the IBM
54 scraping was written by me based on the Dell code. I know the HTML
55 parsing could be done using nice libraries, but did not want to
56 introduce more dependencies. This is the current incarnation:
</p>
64 sub get_support_info {
65 my ($machine, $model, $serial, $productnumber) = @_;
68 if ( $model =~ m/^Dell / ) {
69 # fetch website from Dell support
70 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";
71 my $webpage = get($url);
72 return undef unless ($webpage);
75 my @lines = split(/\n/, $webpage);
76 foreach my $line (@lines) {
77 next unless ($line =~ m/Beskrivelse/);
78 $line =~ s/
<[^
>]+
?>/;/gm;
79 $line =~ s/^.+?;(Beskrivelse;)/$
1/;
81 my @f = split(/\;/, $line);
84 while ($f[
3] eq "DELL") {
85 my ($type, $startstr, $endstr, $days) = @f[
0,
5,
7,
10];
87 my $start = POSIX::strftime("%Y-%m-%d",
88 localtime(str2time($startstr)));
89 my $end = POSIX::strftime("%Y-%m-%d",
90 localtime(str2time($endstr)));
91 $str .= "$type $start -
> $end ";
93 $lastend = $end if ($end gt $lastend);
95 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
96 tag_machine_unsupported($machine)
97 if ($lastend lt $today);
99 } elsif ( $model =~ m/^HP / ) {
100 my $mech = WWW::Mechanize-
>new();
102 'http://www1.itrc.hp.com/service/ewarranty/warrantyInput.do';
105 'BODServiceID' =
> 'NA',
106 'RegisteredPurchaseDate' =
> '',
108 'productNumber' =
> $productnumber,
109 'serialNumber1' =
> $serial,
111 $mech-
>submit_form( form_number =
> 2,
113 # Next step is screen scraping
114 my $content = $mech-
>content();
116 $content =~ s/
<[^
>]+
?>/;/gm;
117 $content =~ s/\s+/ /gm;
118 $content =~ s/;\s*;/;;/gm;
119 $content =~ s/;[\s;]+/;/gm;
121 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
123 while ($content =~ m/;Warranty Type;/) {
124 my ($type, $status, $startstr, $stopstr) = $content =~
125 m/;Warranty Type;([^;]+);.+?;Status;(\w+);Start Date;([^;]+);End Date;([^;]+);/;
126 $content =~ s/^.+?;Warranty Type;//;
127 my $start = POSIX::strftime("%Y-%m-%d",
128 localtime(str2time($startstr)));
129 my $end = POSIX::strftime("%Y-%m-%d",
130 localtime(str2time($stopstr)));
132 $str .= "$type ($status) $start -
> $end ";
134 tag_machine_unsupported($machine)
137 } elsif ( $model =~ m/^IBM / ) {
138 # This code ignore extended support contracts.
139 my ($producttype) = $model =~ m/.*-\[(.{
4}).+\]-/;
140 if ($producttype
&& $serial) {
142 get("http://www-
947.ibm.com/systems/support/supportsite.wss/warranty?action=warranty
&brandind=
5000008&Submit=Submit
&type=$producttype
&serial=$serial");
144 $content =~ s/
<[^
>]+
?>/;/gm;
145 $content =~ s/\s+/ /gm;
146 $content =~ s/;\s*;/;;/gm;
147 $content =~ s/;[\s;]+/;/gm;
149 $content =~ s/^.+?;Warranty status;//;
150 my ($status, $end) = $content =~ m/;Warranty status;([^;]+)\s*;Expiration date;(\S+) ;/;
152 $str .= "($status) -
> $end ";
154 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
155 tag_machine_unsupported($machine)
164 <p>Here are some examples on how to use the function, using fake
165 serial numbers. The information passed in as arguments are fetched
169 print get_support_info("hp.host", "HP ProLiant BL460c G1", "
1234567890"
171 print get_support_info("dell.host", "Dell Inc. PowerEdge
2950", "
1234567");
172 print get_support_info("ibm.host", "IBM eserver xSeries
345 -[
867061X]-",
176 <p>I would recommend this approach for tracking support contracts for
177 everyone with more than a few computers to administer. :)
</p>
179 <p>Update
2009-
03-
06: The IBM page do not include extended support
180 contracts, so it is useless in that case. The original Dell code do
181 not handle extended support contracts either, but has been updated to
185 <div class=
"tags">Tags:
<a href=
"http://people.skolelinux.org/pere/blog/tags/english">english
</a>,
<a href=
"http://people.skolelinux.org/pere/blog/tags/nuug">nuug
</a>.
</div>
203 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2011/01/">January (
16)
</a></li>
205 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2011/02/">February (
6)
</a></li>
207 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2011/03/">March (
6)
</a></li>
209 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2011/04/">April (
7)
</a></li>
211 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2011/05/">May (
3)
</a></li>
213 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2011/06/">June (
2)
</a></li>
215 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2011/07/">July (
7)
</a></li>
217 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2011/08/">August (
6)
</a></li>
219 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2011/09/">September (
2)
</a></li>
226 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2010/01/">January (
2)
</a></li>
228 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2010/02/">February (
1)
</a></li>
230 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2010/03/">March (
3)
</a></li>
232 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2010/04/">April (
3)
</a></li>
234 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2010/05/">May (
9)
</a></li>
236 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2010/06/">June (
14)
</a></li>
238 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2010/07/">July (
12)
</a></li>
240 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2010/08/">August (
13)
</a></li>
242 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2010/09/">September (
7)
</a></li>
244 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2010/10/">October (
9)
</a></li>
246 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2010/11/">November (
13)
</a></li>
248 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2010/12/">December (
12)
</a></li>
255 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2009/01/">January (
8)
</a></li>
257 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2009/02/">February (
8)
</a></li>
259 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2009/03/">March (
12)
</a></li>
261 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2009/04/">April (
10)
</a></li>
263 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2009/05/">May (
9)
</a></li>
265 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2009/06/">June (
3)
</a></li>
267 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2009/07/">July (
4)
</a></li>
269 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2009/08/">August (
3)
</a></li>
271 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2009/09/">September (
1)
</a></li>
273 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2009/10/">October (
2)
</a></li>
275 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2009/11/">November (
3)
</a></li>
277 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2009/12/">December (
3)
</a></li>
284 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2008/11/">November (
5)
</a></li>
286 <li><a href=
"http://people.skolelinux.org/pere/blog/archive/2008/12/">December (
7)
</a></li>
297 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/3d-printer">3d-printer (
13)
</a></li>
299 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/amiga">amiga (
1)
</a></li>
301 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/aros">aros (
1)
</a></li>
303 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/bitcoin">bitcoin (
2)
</a></li>
305 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/bootsystem">bootsystem (
12)
</a></li>
307 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/bsa">bsa (
2)
</a></li>
309 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/debian">debian (
53)
</a></li>
311 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/debian edu">debian edu (
63)
</a></li>
313 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/digistan">digistan (
7)
</a></li>
315 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/english">english (
95)
</a></li>
317 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/fiksgatami">fiksgatami (
12)
</a></li>
319 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/fildeling">fildeling (
12)
</a></li>
321 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/intervju">intervju (
10)
</a></li>
323 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/kart">kart (
15)
</a></li>
325 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/ldap">ldap (
8)
</a></li>
327 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/lenker">lenker (
4)
</a></li>
329 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/ltsp">ltsp (
1)
</a></li>
331 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/multimedia">multimedia (
13)
</a></li>
333 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/norsk">norsk (
136)
</a></li>
335 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/nuug">nuug (
119)
</a></li>
337 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/open311">open311 (
2)
</a></li>
339 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/opphavsrett">opphavsrett (
22)
</a></li>
341 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/personvern">personvern (
45)
</a></li>
343 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/reprap">reprap (
11)
</a></li>
345 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/rfid">rfid (
2)
</a></li>
347 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/robot">robot (
4)
</a></li>
349 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/rss">rss (
1)
</a></li>
351 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/sikkerhet">sikkerhet (
23)
</a></li>
353 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/sitesummary">sitesummary (
3)
</a></li>
355 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/standard">standard (
24)
</a></li>
357 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/stavekontroll">stavekontroll (
1)
</a></li>
359 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/stortinget">stortinget (
2)
</a></li>
361 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/surveillance">surveillance (
9)
</a></li>
363 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/valg">valg (
5)
</a></li>
365 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/video">video (
20)
</a></li>
367 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/vitenskap">vitenskap (
1)
</a></li>
369 <li><a href=
"http://people.skolelinux.org/pere/blog/tags/web">web (
16)
</a></li>
375 <p style=
"text-align: right">
376 Created by
<a href=
"http://steve.org.uk/Software/chronicle">Chronicle v4.4
</a>