任何人都知道一种获取服务标签列表信息的方法,戴尔在其网站上是否设有专门的部分?我也会对任何Perl / Python库或* nix shell脚本开放。
现在,我主要希望每个标签都有某种日期。
任何人都知道一种获取服务标签列表信息的方法,戴尔在其网站上是否设有专门的部分?我也会对任何Perl / Python库或* nix shell脚本开放。
现在,我主要希望每个标签都有某种日期。
Answers:
为每个标签下载以下URL(将SVCTAG替换为实际的服务标签):
http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&ServiceTag=SVCTAG
解析结果页以获取您感兴趣的信息,留给读者练习:-)
我知道这是一篇旧文章,但是我花了很多时间在此上,并认为我会帮助遇到此问题的其他任何人。戴尔的新站点全都是javascript,我想不出如何针对它进行编码以查询服务标签数据。一段时间后,我想到了改用他们的移动网站(mobile = no javascript),这对我来说很有效,使用perl / LWP在每个服务标签上提取数据。我是perl黑客,因此其他人可能可以更简洁地编写此代码。下面是原始系统配置。这个想法是,第一个URL“获取”获取带有服务标签的cookie,第二个URL获取获取有关服务标签的所需数据。然后,您可以为要查找的数据解析第二个get的“ $ 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类包含此信息。Google的“ WMI序列号”,您将找到获取此数据的几种示例解决方案。我们在构建时使用脚本来使用序列号和其他前置字符作为工作站主机名来命名该框,这使得使用大量客户端进行故障排除变得更加容易。
戴尔现在可以选择保存您的服务标签。您需要使用它们创建登录名,仅此而已。它还显示哪些服务器保修到期,您可以从中导出。
#!/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 exchange
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
该脚本查询标准localhost,尝试使用dmidecode。您也可以使用SNMP在远程主机上运行它,也可以从NRPE运行它。非常方便。
dmidecode -s system-serial-number
将返回服务标签
您可以使用ssh批量在所有系统上远程运行它。假设他们都在运行Linux
'dmidecode' is not recognized as an internal or external command, operable program or batch file.
上了戴尔笔记本电脑。
我有一个 自动脚本,可以通过轮询Dell支持网站从服务标签列表创建csv文件。
您可以遵循相同的逻辑来提取其他信息并将其转换为csv格式
http://fei-automation.blogspot.hk/2014/09/how-to-check-model-for-list-of-dell-pc.html
注意:这是此答案的编辑转发
戴尔最近改变了他们的网站。
我已经更新了上面的Perl脚本,以允许进行此更改。
我只想将每台机器的出厂日期转储到一个文本文件中,以便仅对其进行解析,但是我确信可以轻松地修改代码以获取所需的任何数据。
===
#!/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 $!;