Page MenuHomePhabricator
Paste P1820

Sum h_vmem per host
ActivePublic

Authored by scfc on Aug 3 2015, 10:55 PM.
Project Tags
Referenced Files
F356878: Sum h_vmem per host
Aug 3 2015, 10:55 PM
Subscribers
None
#!/usr/bin/perl -w
use strict;
use warnings;
use XML::LibXML;
my $XMLParser = new XML::LibXML () or die ($!);
my $Hosts = $XMLParser->parse_file ('/home/scfc/hosts.xml') or die ($!); # qhost -xml -j -F h_vmem
my $Jobs = $XMLParser->parse_file ('/home/scfc/jobs.xml') or die ($!); # qstat -j \* -xml
foreach my $Host ($Hosts->findnodes (q!/qhost/host[not(@name = 'global')]!)) {
my $h_vmem = 0;
foreach my $Job ($Host->findnodes ('job')) {
my $JobNr = $Job->getAttribute ('name');
foreach my $v ($Jobs->findnodes ("/detailed_job_info/djob_info/element[JB_job_number = $JobNr]/JB_hard_resource_list/qstat_l_requests[CE_name = 'h_vmem']/CE_doubleval")) {
$h_vmem += $v->textContent ();
}
}
printf "%s %f\n", $Host->getAttribute ('name'), $h_vmem / 1024 / 1024 / 1024;
}