1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5 <title>Petter Reinholdtsen: Checking server hardware support status for Dell, HP and IBM servers
</title>
6 <link rel=
"stylesheet" type=
"text/css" media=
"screen" href=
"style.css">
12 <a href=
"">Petter Reinholdtsen
</a>
20 <div class=
"title">Checking server hardware support status for Dell, HP and IBM servers
</div>
21 <div class=
"date">2009-
02-
28 23:
50</div>
23 <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 =~ m%;(\d{
2})/(\d{
2})/(\d{
4});+(\d{
2})/(\d{
2})/(\d{
4});%g;
80 my $start = "$
3-$
1-$
2";
82 $str = "$start -
> $end";
83 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
84 tag_machine_unsupported($machine)
87 } elsif ( $model =~ m/^HP / ) {
88 my $mech = WWW::Mechanize-
>new();
90 'http://www1.itrc.hp.com/service/ewarranty/warrantyInput.do';
93 'BODServiceID' =
> 'NA',
94 'RegisteredPurchaseDate' =
> '',
96 'productNumber' =
> $productnumber,
97 'serialNumber1' =
> $serial,
99 $mech-
>submit_form( form_number =
> 2,
101 # Next step is screen scraping
102 my $content = $mech-
>content();
104 $content =~ s/<[^
>]+
?>/;/gm;
105 $content =~ s/\s+/ /gm;
106 $content =~ s/;\s*;/;;/gm;
107 $content =~ s/;[\s;]+/;/gm;
109 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
111 while ($content =~ m/;Warranty Type;/) {
112 my ($type, $status, $startstr, $stopstr) = $content =~
113 m/;Warranty Type;([^;]+);.+?;Status;(\w+);Start Date;([^;]+);End Date;([^;]+);/;
114 $content =~ s/^.+?;Warranty Type;//;
115 my $start = POSIX::strftime("%Y-%m-%d",
116 localtime(str2time($startstr)));
117 my $end = POSIX::strftime("%Y-%m-%d",
118 localtime(str2time($stopstr)));
120 $str .= "$type ($status) $start -
> $end ";
122 tag_machine_unsupported($machine)
125 } elsif ( $model =~ m/^IBM / ) {
126 my ($producttype) = $model =~ m/.*-\[(.{
4}).+\]-/;
127 if ($producttype && $serial) {
129 get("http://www-
947.ibm.com/systems/support/supportsite.wss/warranty?action=warranty&brandind=
5000008&Submit=Submit&type=$producttype&serial=$serial");
131 $content =~ s/<[^
>]+
?>/;/gm;
132 $content =~ s/\s+/ /gm;
133 $content =~ s/;\s*;/;;/gm;
134 $content =~ s/;[\s;]+/;/gm;
136 $content =~ s/^.+?;Warranty status;//;
137 my ($status, $end) = $content =~ m/;Warranty status;([^;]+)\s*;Expiration date;(\S+) ;/;
139 $str .= "($status) -
> $end ";
141 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
142 tag_machine_unsupported($machine)
151 <p>Here are some examples on how to use the function, using fake
152 serial numbers. The information passed in as arguments are fetched
156 print get_support_info("hp.host", "HP ProLiant BL460c G1", "
1234567890"
158 print get_support_info("dell.host", "Dell Inc. PowerEdge
2950", "
1234567");
159 print get_support_info("ibm.host", "IBM eserver xSeries
345 -[
867061X]-",
163 <p>I would recommend this approach for tracking support contracts for
164 everyone with more than a new computers to administer. :)
</p>
167 <div class=
"tags">Tags:
<a href=
"tags/english">english
</a>,
<a href=
"tags/nuug">nuug
</a>.
</div>
184 <li><a href=
"archive/2009/01/">January (
8)
</a></li>
186 <li><a href=
"archive/2009/02/">February (
8)
</a></li>
193 <li><a href=
"archive/2008/11/">November (
5)
</a></li>
195 <li><a href=
"archive/2008/12/">December (
7)
</a></li>
206 <li><a href=
"tags/3d-printer">3d-printer (
7)
</a></li>
208 <li><a href=
"tags/amiga">amiga (
1)
</a></li>
210 <li><a href=
"tags/aros">aros (
1)
</a></li>
212 <li><a href=
"tags/debian">debian (
3)
</a></li>
214 <li><a href=
"tags/debian edu">debian edu (
4)
</a></li>
216 <li><a href=
"tags/english">english (
6)
</a></li>
218 <li><a href=
"tags/fiksgatami">fiksgatami (
1)
</a></li>
220 <li><a href=
"tags/ltsp">ltsp (
1)
</a></li>
222 <li><a href=
"tags/multimedia">multimedia (
2)
</a></li>
224 <li><a href=
"tags/norsk">norsk (
22)
</a></li>
226 <li><a href=
"tags/nuug">nuug (
20)
</a></li>
228 <li><a href=
"tags/personvern">personvern (
3)
</a></li>
230 <li><a href=
"tags/reprap">reprap (
7)
</a></li>
232 <li><a href=
"tags/rss">rss (
1)
</a></li>
234 <li><a href=
"tags/stavekontroll">stavekontroll (
1)
</a></li>
236 <li><a href=
"tags/video">video (
3)
</a></li>
238 <li><a href=
"tags/web">web (
2)
</a></li>