]> pere.pagekite.me Git - homepage.git/blob - blog/Checking_server_hardware_support_status_for_Dell__HP_and_IBM_servers.html
Generated.
[homepage.git] / blog / Checking_server_hardware_support_status_for_Dell__HP_and_IBM_servers.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html>
4 <head>
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="http://people.skolelinux.org/pere/blog/style.css">
7 </head>
8 <body>
9
10 <div class="title">
11 <h1>
12 <a href="http://people.skolelinux.org/pere/blog/">Petter Reinholdtsen</a>
13
14 </h1>
15
16 </div>
17
18
19 <div class="entry">
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>
22 <div class="body">
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
48 machine.</p>
49
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>
57
58 <pre>
59 use LWP::Simple;
60 use POSIX;
61 use WWW::Mechanize;
62 use Date::Parse;
63 [...]
64 sub get_support_info {
65 my ($machine, $model, $serial, $productnumber) = @_;
66 my $str;
67
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&amp;cs=nodhs1&amp;l=no&amp;s=dhs&amp;ServiceTag=$serial";
71 my $webpage = get($url);
72 return undef unless ($webpage);
73
74 my $daysleft = -1;
75 my @lines = split(/\n/, $webpage);
76 foreach my $line (@lines) {
77 next unless ($line =~ m/Beskrivelse/);
78 $line =~ s/&lt;[^>]+?>/;/gm;
79 $line =~ s/^.+?;(Beskrivelse;)/$1/;
80
81 my @f = split(/\;/, $line);
82 @f = @f[13 .. $#f];
83 my $lastend = "";
84 while ($f[3] eq "DELL") {
85 my ($type, $startstr, $endstr, $days) = @f[0, 5, 7, 10];
86
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 ";
92 @f = @f[14 .. $#f];
93 $lastend = $end if ($end gt $lastend);
94 }
95 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
96 tag_machine_unsupported($machine)
97 if ($lastend lt $today);
98 }
99 } elsif ( $model =~ m/^HP / ) {
100 my $mech = WWW::Mechanize->new();
101 my $url =
102 'http://www1.itrc.hp.com/service/ewarranty/warrantyInput.do';
103 $mech->get($url);
104 my $fields = {
105 'BODServiceID' => 'NA',
106 'RegisteredPurchaseDate' => '',
107 'country' => 'NO',
108 'productNumber' => $productnumber,
109 'serialNumber1' => $serial,
110 };
111 $mech->submit_form( form_number => 2,
112 fields => $fields );
113 # Next step is screen scraping
114 my $content = $mech->content();
115
116 $content =~ s/&lt;[^>]+?>/;/gm;
117 $content =~ s/\s+/ /gm;
118 $content =~ s/;\s*;/;;/gm;
119 $content =~ s/;[\s;]+/;/gm;
120
121 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
122
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)));
131
132 $str .= "$type ($status) $start -> $end ";
133
134 tag_machine_unsupported($machine)
135 if ($end lt $today);
136 }
137 } elsif ( $model =~ m/^IBM / ) {
138 # This code ignore extended support contracts.
139 my ($producttype) = $model =~ m/.*-\[(.{4}).+\]-/;
140 if ($producttype &amp;&amp; $serial) {
141 my $content =
142 get("http://www-947.ibm.com/systems/support/supportsite.wss/warranty?action=warranty&amp;brandind=5000008&amp;Submit=Submit&amp;type=$producttype&amp;serial=$serial");
143 if ($content) {
144 $content =~ s/&lt;[^>]+?>/;/gm;
145 $content =~ s/\s+/ /gm;
146 $content =~ s/;\s*;/;;/gm;
147 $content =~ s/;[\s;]+/;/gm;
148
149 $content =~ s/^.+?;Warranty status;//;
150 my ($status, $end) = $content =~ m/;Warranty status;([^;]+)\s*;Expiration date;(\S+) ;/;
151
152 $str .= "($status) -> $end ";
153
154 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
155 tag_machine_unsupported($machine)
156 if ($end lt $today);
157 }
158 }
159 }
160 return $str;
161 }
162 </pre>
163
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
166 from dmidecode.</p>
167
168 <pre>
169 print get_support_info("hp.host", "HP ProLiant BL460c G1", "1234567890"
170 "447707-B21");
171 print get_support_info("dell.host", "Dell Inc. PowerEdge 2950", "1234567");
172 print get_support_info("ibm.host", "IBM eserver xSeries 345 -[867061X]-",
173 "1234567");
174 </pre>
175
176 <p>I would recommend this approach for tracking support contracts for
177 everyone with more than a few computers to administer. :)</p>
178
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
182 do so.</p>
183 </div>
184
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>
186
187 </div>
188
189
190
191
192
193
194 <div id="sidebar">
195
196 <h2>Archive</h2>
197 <ul>
198
199 <li>2010
200 <ul>
201
202 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/01/">January (2)</a></li>
203
204 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/02/">February (1)</a></li>
205
206 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/03/">March (3)</a></li>
207
208 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/04/">April (3)</a></li>
209
210 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/05/">May (9)</a></li>
211
212 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/06/">June (14)</a></li>
213
214 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/07/">July (12)</a></li>
215
216 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/08/">August (13)</a></li>
217
218 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/09/">September (7)</a></li>
219
220 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/10/">October (9)</a></li>
221
222 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/11/">November (13)</a></li>
223
224 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/12/">December (5)</a></li>
225
226 </ul></li>
227
228 <li>2009
229 <ul>
230
231 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/01/">January (8)</a></li>
232
233 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/02/">February (8)</a></li>
234
235 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/03/">March (12)</a></li>
236
237 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/04/">April (10)</a></li>
238
239 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/05/">May (9)</a></li>
240
241 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/06/">June (3)</a></li>
242
243 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/07/">July (4)</a></li>
244
245 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/08/">August (3)</a></li>
246
247 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/09/">September (1)</a></li>
248
249 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/10/">October (2)</a></li>
250
251 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/11/">November (3)</a></li>
252
253 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/12/">December (3)</a></li>
254
255 </ul></li>
256
257 <li>2008
258 <ul>
259
260 <li><a href="http://people.skolelinux.org/pere/blog/archive/2008/11/">November (5)</a></li>
261
262 <li><a href="http://people.skolelinux.org/pere/blog/archive/2008/12/">December (7)</a></li>
263
264 </ul></li>
265
266 </ul>
267
268
269
270 <h2>Tags</h2>
271 <ul>
272
273 <li><a href="http://people.skolelinux.org/pere/blog/tags/3d-printer">3d-printer (13)</a></li>
274
275 <li><a href="http://people.skolelinux.org/pere/blog/tags/amiga">amiga (1)</a></li>
276
277 <li><a href="http://people.skolelinux.org/pere/blog/tags/aros">aros (1)</a></li>
278
279 <li><a href="http://people.skolelinux.org/pere/blog/tags/bitcoin">bitcoin (1)</a></li>
280
281 <li><a href="http://people.skolelinux.org/pere/blog/tags/bootsystem">bootsystem (10)</a></li>
282
283 <li><a href="http://people.skolelinux.org/pere/blog/tags/debian">debian (45)</a></li>
284
285 <li><a href="http://people.skolelinux.org/pere/blog/tags/debian edu">debian edu (53)</a></li>
286
287 <li><a href="http://people.skolelinux.org/pere/blog/tags/english">english (76)</a></li>
288
289 <li><a href="http://people.skolelinux.org/pere/blog/tags/fiksgatami">fiksgatami (1)</a></li>
290
291 <li><a href="http://people.skolelinux.org/pere/blog/tags/fildeling">fildeling (11)</a></li>
292
293 <li><a href="http://people.skolelinux.org/pere/blog/tags/kart">kart (5)</a></li>
294
295 <li><a href="http://people.skolelinux.org/pere/blog/tags/ldap">ldap (8)</a></li>
296
297 <li><a href="http://people.skolelinux.org/pere/blog/tags/lenker">lenker (4)</a></li>
298
299 <li><a href="http://people.skolelinux.org/pere/blog/tags/ltsp">ltsp (1)</a></li>
300
301 <li><a href="http://people.skolelinux.org/pere/blog/tags/multimedia">multimedia (11)</a></li>
302
303 <li><a href="http://people.skolelinux.org/pere/blog/tags/norsk">norsk (93)</a></li>
304
305 <li><a href="http://people.skolelinux.org/pere/blog/tags/nuug">nuug (114)</a></li>
306
307 <li><a href="http://people.skolelinux.org/pere/blog/tags/opphavsrett">opphavsrett (18)</a></li>
308
309 <li><a href="http://people.skolelinux.org/pere/blog/tags/personvern">personvern (29)</a></li>
310
311 <li><a href="http://people.skolelinux.org/pere/blog/tags/reprap">reprap (11)</a></li>
312
313 <li><a href="http://people.skolelinux.org/pere/blog/tags/robot">robot (4)</a></li>
314
315 <li><a href="http://people.skolelinux.org/pere/blog/tags/rss">rss (1)</a></li>
316
317 <li><a href="http://people.skolelinux.org/pere/blog/tags/sikkerhet">sikkerhet (21)</a></li>
318
319 <li><a href="http://people.skolelinux.org/pere/blog/tags/sitesummary">sitesummary (3)</a></li>
320
321 <li><a href="http://people.skolelinux.org/pere/blog/tags/standard">standard (16)</a></li>
322
323 <li><a href="http://people.skolelinux.org/pere/blog/tags/stavekontroll">stavekontroll (1)</a></li>
324
325 <li><a href="http://people.skolelinux.org/pere/blog/tags/video">video (16)</a></li>
326
327 <li><a href="http://people.skolelinux.org/pere/blog/tags/vitenskap">vitenskap (1)</a></li>
328
329 <li><a href="http://people.skolelinux.org/pere/blog/tags/web">web (14)</a></li>
330
331 </ul>
332
333 </div>
334 </body>
335 </html>