]> 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 xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
4 <head>
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" />
9 </head>
10 <body>
11 <div class="title">
12 <h1>
13 <a href="http://people.skolelinux.org/pere/blog/">Petter Reinholdtsen</a>
14
15 </h1>
16
17 </div>
18
19
20 <div class="entry">
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
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
188 </div>
189
190
191
192
193 <div id="sidebar">
194
195
196
197 <h2>Archive</h2>
198 <ul>
199
200 <li>2012
201 <ul>
202
203 <li><a href="http://people.skolelinux.org/pere/blog/archive/2012/01/">January (7)</a></li>
204
205 <li><a href="http://people.skolelinux.org/pere/blog/archive/2012/02/">February (5)</a></li>
206
207 </ul></li>
208
209 <li>2011
210 <ul>
211
212 <li><a href="http://people.skolelinux.org/pere/blog/archive/2011/01/">January (16)</a></li>
213
214 <li><a href="http://people.skolelinux.org/pere/blog/archive/2011/02/">February (6)</a></li>
215
216 <li><a href="http://people.skolelinux.org/pere/blog/archive/2011/03/">March (6)</a></li>
217
218 <li><a href="http://people.skolelinux.org/pere/blog/archive/2011/04/">April (7)</a></li>
219
220 <li><a href="http://people.skolelinux.org/pere/blog/archive/2011/05/">May (3)</a></li>
221
222 <li><a href="http://people.skolelinux.org/pere/blog/archive/2011/06/">June (2)</a></li>
223
224 <li><a href="http://people.skolelinux.org/pere/blog/archive/2011/07/">July (7)</a></li>
225
226 <li><a href="http://people.skolelinux.org/pere/blog/archive/2011/08/">August (6)</a></li>
227
228 <li><a href="http://people.skolelinux.org/pere/blog/archive/2011/09/">September (4)</a></li>
229
230 <li><a href="http://people.skolelinux.org/pere/blog/archive/2011/10/">October (2)</a></li>
231
232 <li><a href="http://people.skolelinux.org/pere/blog/archive/2011/11/">November (3)</a></li>
233
234 <li><a href="http://people.skolelinux.org/pere/blog/archive/2011/12/">December (1)</a></li>
235
236 </ul></li>
237
238 <li>2010
239 <ul>
240
241 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/01/">January (2)</a></li>
242
243 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/02/">February (1)</a></li>
244
245 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/03/">March (3)</a></li>
246
247 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/04/">April (3)</a></li>
248
249 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/05/">May (9)</a></li>
250
251 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/06/">June (14)</a></li>
252
253 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/07/">July (12)</a></li>
254
255 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/08/">August (13)</a></li>
256
257 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/09/">September (7)</a></li>
258
259 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/10/">October (9)</a></li>
260
261 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/11/">November (13)</a></li>
262
263 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/12/">December (12)</a></li>
264
265 </ul></li>
266
267 <li>2009
268 <ul>
269
270 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/01/">January (8)</a></li>
271
272 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/02/">February (8)</a></li>
273
274 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/03/">March (12)</a></li>
275
276 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/04/">April (10)</a></li>
277
278 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/05/">May (9)</a></li>
279
280 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/06/">June (3)</a></li>
281
282 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/07/">July (4)</a></li>
283
284 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/08/">August (3)</a></li>
285
286 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/09/">September (1)</a></li>
287
288 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/10/">October (2)</a></li>
289
290 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/11/">November (3)</a></li>
291
292 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/12/">December (3)</a></li>
293
294 </ul></li>
295
296 <li>2008
297 <ul>
298
299 <li><a href="http://people.skolelinux.org/pere/blog/archive/2008/11/">November (5)</a></li>
300
301 <li><a href="http://people.skolelinux.org/pere/blog/archive/2008/12/">December (7)</a></li>
302
303 </ul></li>
304
305 </ul>
306
307
308
309 <h2>Tags</h2>
310 <ul>
311
312 <li><a href="http://people.skolelinux.org/pere/blog/tags/3d-printer">3d-printer (13)</a></li>
313
314 <li><a href="http://people.skolelinux.org/pere/blog/tags/amiga">amiga (1)</a></li>
315
316 <li><a href="http://people.skolelinux.org/pere/blog/tags/aros">aros (1)</a></li>
317
318 <li><a href="http://people.skolelinux.org/pere/blog/tags/bitcoin">bitcoin (2)</a></li>
319
320 <li><a href="http://people.skolelinux.org/pere/blog/tags/bootsystem">bootsystem (12)</a></li>
321
322 <li><a href="http://people.skolelinux.org/pere/blog/tags/bsa">bsa (2)</a></li>
323
324 <li><a href="http://people.skolelinux.org/pere/blog/tags/debian">debian (54)</a></li>
325
326 <li><a href="http://people.skolelinux.org/pere/blog/tags/debian edu">debian edu (75)</a></li>
327
328 <li><a href="http://people.skolelinux.org/pere/blog/tags/digistan">digistan (7)</a></li>
329
330 <li><a href="http://people.skolelinux.org/pere/blog/tags/english">english (107)</a></li>
331
332 <li><a href="http://people.skolelinux.org/pere/blog/tags/fiksgatami">fiksgatami (13)</a></li>
333
334 <li><a href="http://people.skolelinux.org/pere/blog/tags/fildeling">fildeling (12)</a></li>
335
336 <li><a href="http://people.skolelinux.org/pere/blog/tags/intervju">intervju (13)</a></li>
337
338 <li><a href="http://people.skolelinux.org/pere/blog/tags/kart">kart (15)</a></li>
339
340 <li><a href="http://people.skolelinux.org/pere/blog/tags/ldap">ldap (8)</a></li>
341
342 <li><a href="http://people.skolelinux.org/pere/blog/tags/lenker">lenker (4)</a></li>
343
344 <li><a href="http://people.skolelinux.org/pere/blog/tags/ltsp">ltsp (1)</a></li>
345
346 <li><a href="http://people.skolelinux.org/pere/blog/tags/multimedia">multimedia (14)</a></li>
347
348 <li><a href="http://people.skolelinux.org/pere/blog/tags/norsk">norsk (144)</a></li>
349
350 <li><a href="http://people.skolelinux.org/pere/blog/tags/nuug">nuug (119)</a></li>
351
352 <li><a href="http://people.skolelinux.org/pere/blog/tags/open311">open311 (2)</a></li>
353
354 <li><a href="http://people.skolelinux.org/pere/blog/tags/opphavsrett">opphavsrett (24)</a></li>
355
356 <li><a href="http://people.skolelinux.org/pere/blog/tags/personvern">personvern (46)</a></li>
357
358 <li><a href="http://people.skolelinux.org/pere/blog/tags/raid">raid (1)</a></li>
359
360 <li><a href="http://people.skolelinux.org/pere/blog/tags/reprap">reprap (11)</a></li>
361
362 <li><a href="http://people.skolelinux.org/pere/blog/tags/rfid">rfid (2)</a></li>
363
364 <li><a href="http://people.skolelinux.org/pere/blog/tags/robot">robot (4)</a></li>
365
366 <li><a href="http://people.skolelinux.org/pere/blog/tags/rss">rss (1)</a></li>
367
368 <li><a href="http://people.skolelinux.org/pere/blog/tags/sikkerhet">sikkerhet (23)</a></li>
369
370 <li><a href="http://people.skolelinux.org/pere/blog/tags/sitesummary">sitesummary (4)</a></li>
371
372 <li><a href="http://people.skolelinux.org/pere/blog/tags/standard">standard (24)</a></li>
373
374 <li><a href="http://people.skolelinux.org/pere/blog/tags/stavekontroll">stavekontroll (1)</a></li>
375
376 <li><a href="http://people.skolelinux.org/pere/blog/tags/stortinget">stortinget (3)</a></li>
377
378 <li><a href="http://people.skolelinux.org/pere/blog/tags/surveillance">surveillance (9)</a></li>
379
380 <li><a href="http://people.skolelinux.org/pere/blog/tags/valg">valg (6)</a></li>
381
382 <li><a href="http://people.skolelinux.org/pere/blog/tags/video">video (22)</a></li>
383
384 <li><a href="http://people.skolelinux.org/pere/blog/tags/vitenskap">vitenskap (1)</a></li>
385
386 <li><a href="http://people.skolelinux.org/pere/blog/tags/web">web (18)</a></li>
387
388 </ul>
389
390
391 </div>
392 <p style="text-align: right">
393 Created by <a href="http://steve.org.uk/Software/chronicle">Chronicle v4.4</a>
394 </p>
395
396 </body>
397 </html>