任何人都知道一种方法来获取一系列服务标签的信息,戴尔是否有一个在他们的网站这一节? 我也可以打开任何Perl / Python库或* nix shell脚本。
现在我主要想要每个标签的某种date。
下载下面的URL(最后用实际的服务标签replaceSVCTAG)为每个标签:
http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&ServiceTag=SVCTAG
parsing您感兴趣的信息的结果页面留给阅读者练习:-)
在“ 我的系统 ”部分添加您的系统在戴尔支持网站。 您最多可以处理100个系统。
当然,您必须拥有一个戴尔网站的帐户。
不幸的是,我不知道一个批处理系统来完成这个工作,即使你当然可以使用curl,snoopy或者其他熟悉的方法来自动执行login,检索列表和parsing结果。
我知道这是一个旧的post,但我已经花了相当多的时间,并认为我会帮助其他任何人遇到这个。 戴尔的新网站是所有的JavaScript,我无法弄清楚如何编码来查询服务标签数据。 过了一段时间,我想使用他们的手机网站(手机=没有JavaScript的),这对我使用perl / LWP拉下每个服务标签的数据。 我是一个perl黑客,所以别人可能会写得更干净一点。 以下拉取原来的系统configuration。 这个想法是,第一个URL“获取”与服务标签拉一个cookie,第二个URL获取有关服务标签的数据。 然后,您可以parsing第二个“$ answer”获取您正在查找的数据。
#!/usr/bin/perl use strict; use LWP::Simple; use LWP::UserAgent; my $inputfile = $ARGV[0]; my ($url,$response,$answer); open (DATA, $inputfile) or die "Can't open $inputfile \n"; foreach my $serviceTag (<DATA>) { chomp $serviceTag; print "\n$serviceTag"; ##### Allow Cookies my $browser = LWP::UserAgent->new; $browser->cookie_jar({}); $browser->cookie_jar( HTTP::Cookies->new( 'file' => 'cookies.lwp', # where to read/write cookies 'autosave' => 0 # do not save it to disk when done )); # declare agent as mozilla, not perl LWP $browser->agent("Mozilla/8.0"); my $urlPartA = "http://m.dell.com/mt/www.dell.com/support/troubleshooting/us/en/19/Servicetag/"; my $urlPartB = "?s=BIZ&un_jtt_redirect"; my $firstURL = join('', $urlPartA,$serviceTag,$urlPartB); #print "\nURL = $firstURL"; $url = URI->new("$firstURL"); $response = $browser->get( $url ); $answer = $response->content; #print "\nAnswer:\n$answer\n\n"; $url = URI->new('http://m.dell.com/mt/www.dell.com/support/troubleshooting/us/en/555/TroubleShooting?name=TroubleShooting_SystemConfigurationTab'); $response = $browser->get( $url ); $answer = $response->content; #print "\nAnswer:\n$answer\n\n"; }
服务标签通常与序列号相似。
WMI Win32_BaseBoard.SerialNumber类包含此信息。 谷歌的“WMI序列号”,你会发现获取这些数据的几个示例解决scheme。 我们在编译时使用脚本来使用序列号和其他附加字符作为我们的工作站主机名命名,这使得大量客户端的故障排除变得更容易。
戴尔现在可以select保存您的服务标签。 你需要创build一个与他们的login,这就是全部。 它还显示哪些服务器的保修即将到期,您可以从中导出。
#!/usr/bin/python # dell_warranty.py v0.1 # Written by Frode Egeland <egeland[at]gmail.com> - Copyright 2009 # Released under the terms of the GNU GPL v3 - see http://www.gnu.org/licenses/gpl-3.0.html # # Version History # 0.1 - 2009-10-12 - Frode Egeland - Initial version. Tested with a simple csv list of service tags only. # import urllib2, csv, re from BeautifulSoup import BeautifulSoup url="http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&ServiceTag=%s" stlist = [] # generate a list of servicetags from a csv csvfile = csv.reader(open('taglist.csv')) for line in csvfile: for entry in line: stlist.append(entry) fixdate = re.compile("(\d{1,2})\/(\d{1,2})\/(\d{4})") print "Service Tag, Warranty Type, Provider, Start Date, End Date, Days Remaining" for currtag in stlist: page = urllib2.urlopen(url % (currtag,)) for line in page.readlines(): if "Parts only Warranty" in line: soup = BeautifulSoup(line) break table = soup.find('table',{'class':"contract_table"}) rows = table.findAll('tr') rows = rows[1:] for row in rows: output = "%s" % (currtag,) cells = row.findAll('td') for cell in cells: if cell.a: # link / formatted text txt = cell.a.string elif cell.b: # bold text txt = cell.b.string elif cell.i: # italic txt = cell.i.string else: #normal text txt = cell.string match = fixdate.search(txt) if match: txt = "%d-%d-%d" % (int(match.group(3)),int(match.group(1)),int(match.group(2))) output = "%s,%s" % (output,txt) output = output.strip() print output
我知道这是一个相当老的线程(我只发现它,因为它是从一个较新的链接),但也许你可以使用这个nagios插件: nagios交换
python check_dell_warranty.py OK: Service Tag: tag Warranty: Next Business Day, Provider: DELL, Start: 2010-02-24, End: 2013-02-25, Days left: 860 Warranty: NBD ProSupport For IT On-Site, Provider: DELL, Start: 2010-02-24, End: 2013-02-25, Days left: 860
脚本查询标准的本地主机,尝试dmidecode。 您也可以使用SNMP在远程主机上运行它,也可以从NRPE运行它。 非常方便。
dmidecode -s system-serial-number
将返回服务标签
您可以使用ssh在批处理中的所有系统上远程运行它。 假设他们当然都在运行Linux
我有一个auto-it脚本,通过轮询Dell支持网站,从服务标签列表中创build一个csv文件。
您可以按照相同的逻辑来提取其他信息,并将其放入csv格式
http://fei-automation.blogspot.hk/2014/09/how-to-check-model-for-list-of-dell-pc.html
注意:这是编辑这个答案的转发
戴尔最近改变了他们的网站。
我已经更新了上面的Perl脚本来允许这个改变。
我只是有兴趣把每台机器的发货date转储到一个文本文件,所以只有parsing出来,但我相信代码可以很容易地修改,以抓取任何你想要的数据。
===
#!/usr/bin/perl use strict; use LWP::Simple; use LWP::UserAgent; use Mojo::DOM; my $inputfile = $ARGV[0]; my ($url,$response,$html); my $outputfile = "result.txt"; open (DATA, $inputfile) or die "Can't open $inputfile \n"; open OUTPUT, ">>".$outputfile or die "Could not open '$outputfile'\n"; foreach my $serviceTag (<DATA>) { chomp $serviceTag; print "\n$serviceTag\n"; print OUTPUT $serviceTag."\t"; ##### Allow Cookies my $browser = LWP::UserAgent->new; $browser->cookie_jar({}); $browser->cookie_jar( HTTP::Cookies->new( 'file' => 'cookies.lwp', # where to read/write cookies 'autosave' => 0 # do not save it to disk when done )); # declare agent as mozilla, not perl LWP $browser->agent("Mozilla/8.0"); # my $urlPartA = "http://www.dell.com/support/home/us/en/19/product-support/servicetag/"; # configuration my $urlPartB = "/configuration"; my $firstURL = join('', $urlPartA,$serviceTag,$urlPartB); #print "\nURL = $firstURL"; $url = URI->new("$firstURL"); $response = $browser->get( $url ); $html = $response->content; #print "\nAnswer:\n$html\n\n"; my @values; my $dom = Mojo::DOM->new; $dom->parse($html); my $skip; for my $dd ($dom->find('div.col-lg-4.col-md-4.col-sm-3.col-xs-6')->each) { push(@values, $dd->text) if $skip++; #print $dd->text, "\n" if $skip++; } print $values[1]."\n"; if ( $values[1] =~ m/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/ ) { # format date better for Excel #print OUTPUT $values[1]."\n"; print OUTPUT "$3-$1-$2\n"; } print $values[1]."\n"; print "$3-$1-$2\n"; } close OUTPUT or die $!;