]> 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>2011
200 <ul>
201
202 <li><a href="http://people.skolelinux.org/pere/blog/archive/2011/01/">January (6)</a></li>
203
204 </ul></li>
205
206 <li>2010
207 <ul>
208
209 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/01/">January (2)</a></li>
210
211 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/02/">February (1)</a></li>
212
213 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/03/">March (3)</a></li>
214
215 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/04/">April (3)</a></li>
216
217 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/05/">May (9)</a></li>
218
219 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/06/">June (14)</a></li>
220
221 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/07/">July (12)</a></li>
222
223 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/08/">August (13)</a></li>
224
225 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/09/">September (7)</a></li>
226
227 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/10/">October (9)</a></li>
228
229 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/11/">November (13)</a></li>
230
231 <li><a href="http://people.skolelinux.org/pere/blog/archive/2010/12/">December (12)</a></li>
232
233 </ul></li>
234
235 <li>2009
236 <ul>
237
238 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/01/">January (8)</a></li>
239
240 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/02/">February (8)</a></li>
241
242 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/03/">March (12)</a></li>
243
244 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/04/">April (10)</a></li>
245
246 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/05/">May (9)</a></li>
247
248 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/06/">June (3)</a></li>
249
250 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/07/">July (4)</a></li>
251
252 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/08/">August (3)</a></li>
253
254 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/09/">September (1)</a></li>
255
256 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/10/">October (2)</a></li>
257
258 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/11/">November (3)</a></li>
259
260 <li><a href="http://people.skolelinux.org/pere/blog/archive/2009/12/">December (3)</a></li>
261
262 </ul></li>
263
264 <li>2008
265 <ul>
266
267 <li><a href="http://people.skolelinux.org/pere/blog/archive/2008/11/">November (5)</a></li>
268
269 <li><a href="http://people.skolelinux.org/pere/blog/archive/2008/12/">December (7)</a></li>
270
271 </ul></li>
272
273 </ul>
274
275
276
277 <h2>Tags</h2>
278 <ul>
279
280 <li><a href="http://people.skolelinux.org/pere/blog/tags/3d-printer">3d-printer (13)</a></li>
281
282 <li><a href="http://people.skolelinux.org/pere/blog/tags/amiga">amiga (1)</a></li>
283
284 <li><a href="http://people.skolelinux.org/pere/blog/tags/aros">aros (1)</a></li>
285
286 <li><a href="http://people.skolelinux.org/pere/blog/tags/bitcoin">bitcoin (2)</a></li>
287
288 <li><a href="http://people.skolelinux.org/pere/blog/tags/bootsystem">bootsystem (10)</a></li>
289
290 <li><a href="http://people.skolelinux.org/pere/blog/tags/debian">debian (46)</a></li>
291
292 <li><a href="http://people.skolelinux.org/pere/blog/tags/debian edu">debian edu (55)</a></li>
293
294 <li><a href="http://people.skolelinux.org/pere/blog/tags/english">english (82)</a></li>
295
296 <li><a href="http://people.skolelinux.org/pere/blog/tags/fiksgatami">fiksgatami (1)</a></li>
297
298 <li><a href="http://people.skolelinux.org/pere/blog/tags/fildeling">fildeling (11)</a></li>
299
300 <li><a href="http://people.skolelinux.org/pere/blog/tags/intervju">intervju (1)</a></li>
301
302 <li><a href="http://people.skolelinux.org/pere/blog/tags/kart">kart (5)</a></li>
303
304 <li><a href="http://people.skolelinux.org/pere/blog/tags/ldap">ldap (8)</a></li>
305
306 <li><a href="http://people.skolelinux.org/pere/blog/tags/lenker">lenker (4)</a></li>
307
308 <li><a href="http://people.skolelinux.org/pere/blog/tags/ltsp">ltsp (1)</a></li>
309
310 <li><a href="http://people.skolelinux.org/pere/blog/tags/multimedia">multimedia (11)</a></li>
311
312 <li><a href="http://people.skolelinux.org/pere/blog/tags/norsk">norsk (100)</a></li>
313
314 <li><a href="http://people.skolelinux.org/pere/blog/tags/nuug">nuug (115)</a></li>
315
316 <li><a href="http://people.skolelinux.org/pere/blog/tags/opphavsrett">opphavsrett (18)</a></li>
317
318 <li><a href="http://people.skolelinux.org/pere/blog/tags/personvern">personvern (33)</a></li>
319
320 <li><a href="http://people.skolelinux.org/pere/blog/tags/reprap">reprap (11)</a></li>
321
322 <li><a href="http://people.skolelinux.org/pere/blog/tags/robot">robot (4)</a></li>
323
324 <li><a href="http://people.skolelinux.org/pere/blog/tags/rss">rss (1)</a></li>
325
326 <li><a href="http://people.skolelinux.org/pere/blog/tags/sikkerhet">sikkerhet (22)</a></li>
327
328 <li><a href="http://people.skolelinux.org/pere/blog/tags/sitesummary">sitesummary (3)</a></li>
329
330 <li><a href="http://people.skolelinux.org/pere/blog/tags/standard">standard (21)</a></li>
331
332 <li><a href="http://people.skolelinux.org/pere/blog/tags/stavekontroll">stavekontroll (1)</a></li>
333
334 <li><a href="http://people.skolelinux.org/pere/blog/tags/surveillance">surveillance (7)</a></li>
335
336 <li><a href="http://people.skolelinux.org/pere/blog/tags/video">video (17)</a></li>
337
338 <li><a href="http://people.skolelinux.org/pere/blog/tags/vitenskap">vitenskap (1)</a></li>
339
340 <li><a href="http://people.skolelinux.org/pere/blog/tags/web">web (14)</a></li>
341
342 </ul>
343
344 </div>
345 </body>
346 </html>