]> 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="style.css">
7 </head>
8 <body>
9
10 <div class="title">
11 <h1>
12 <a href="">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 <p><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&cs=nodhs1&l=no&s=dhs&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/<[^>]+?>/;/gm;
79 $line =~ m%;(\d{2})/(\d{2})/(\d{4});+(\d{2})/(\d{2})/(\d{4});%g;
80 my $start = "$3-$1-$2";
81 my $end = "$6-$4-$5";
82 $str = "$start -> $end";
83 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
84 tag_machine_unsupported($machine)
85 if ($end lt $today);
86 }
87 } elsif ( $model =~ m/^HP / ) {
88 my $mech = WWW::Mechanize->new();
89 my $url =
90 'http://www1.itrc.hp.com/service/ewarranty/warrantyInput.do';
91 $mech->get($url);
92 my $fields = {
93 'BODServiceID' => 'NA',
94 'RegisteredPurchaseDate' => '',
95 'country' => 'NO',
96 'productNumber' => $productnumber,
97 'serialNumber1' => $serial,
98 };
99 $mech->submit_form( form_number => 2,
100 fields => $fields );
101 # Next step is screen scraping
102 my $content = $mech->content();
103
104 $content =~ s/<[^>]+?>/;/gm;
105 $content =~ s/\s+/ /gm;
106 $content =~ s/;\s*;/;;/gm;
107 $content =~ s/;[\s;]+/;/gm;
108
109 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
110
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)));
119
120 $str .= "$type ($status) $start -> $end ";
121
122 tag_machine_unsupported($machine)
123 if ($end lt $today);
124 }
125 } elsif ( $model =~ m/^IBM / ) {
126 my ($producttype) = $model =~ m/.*-\[(.{4}).+\]-/;
127 if ($producttype && $serial) {
128 my $content =
129 get("http://www-947.ibm.com/systems/support/supportsite.wss/warranty?action=warranty&brandind=5000008&Submit=Submit&type=$producttype&serial=$serial");
130 if ($content) {
131 $content =~ s/<[^>]+?>/;/gm;
132 $content =~ s/\s+/ /gm;
133 $content =~ s/;\s*;/;;/gm;
134 $content =~ s/;[\s;]+/;/gm;
135
136 $content =~ s/^.+?;Warranty status;//;
137 my ($status, $end) = $content =~ m/;Warranty status;([^;]+)\s*;Expiration date;(\S+) ;/;
138
139 $str .= "($status) -> $end ";
140
141 my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
142 tag_machine_unsupported($machine)
143 if ($end lt $today);
144 }
145 }
146 }
147 return $str;
148 }
149 </pre></p>
150
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
153 from dmidecode.</p>
154
155 <p><pre>
156 print get_support_info("hp.host", "HP ProLiant BL460c G1", "1234567890"
157 "447707-B21");
158 print get_support_info("dell.host", "Dell Inc. PowerEdge 2950", "1234567");
159 print get_support_info("ibm.host", "IBM eserver xSeries 345 -[867061X]-",
160 "1234567");
161 </pre></p>
162
163 <p>I would recommend this approach for tracking support contracts for
164 everyone with more than a new computers to administer. :)</p>
165 </div>
166
167 <div class="tags">Tags: <a href="tags/english">english</a>, <a href="tags/nuug">nuug</a>.</div>
168
169 </div>
170
171
172
173
174
175
176 <div id="sidebar">
177
178 <h2>Archive</h2>
179 <ul>
180
181 <li>2009
182 <ul>
183
184 <li><a href="archive/2009/01/">January (8)</a></li>
185
186 <li><a href="archive/2009/02/">February (8)</a></li>
187
188 </ul></li>
189
190 <li>2008
191 <ul>
192
193 <li><a href="archive/2008/11/">November (5)</a></li>
194
195 <li><a href="archive/2008/12/">December (7)</a></li>
196
197 </ul></li>
198
199 </ul>
200
201
202
203 <h2>Tags</h2>
204 <ul>
205
206 <li><a href="tags/3d-printer">3d-printer (7)</a></li>
207
208 <li><a href="tags/amiga">amiga (1)</a></li>
209
210 <li><a href="tags/aros">aros (1)</a></li>
211
212 <li><a href="tags/debian">debian (3)</a></li>
213
214 <li><a href="tags/debian edu">debian edu (4)</a></li>
215
216 <li><a href="tags/english">english (6)</a></li>
217
218 <li><a href="tags/fiksgatami">fiksgatami (1)</a></li>
219
220 <li><a href="tags/ltsp">ltsp (1)</a></li>
221
222 <li><a href="tags/multimedia">multimedia (2)</a></li>
223
224 <li><a href="tags/norsk">norsk (22)</a></li>
225
226 <li><a href="tags/nuug">nuug (20)</a></li>
227
228 <li><a href="tags/personvern">personvern (3)</a></li>
229
230 <li><a href="tags/reprap">reprap (7)</a></li>
231
232 <li><a href="tags/rss">rss (1)</a></li>
233
234 <li><a href="tags/stavekontroll">stavekontroll (1)</a></li>
235
236 <li><a href="tags/video">video (3)</a></li>
237
238 <li><a href="tags/web">web (2)</a></li>
239
240 </ul>
241
242 </div>
243 </body>
244 </html>