HTCondor::Queue::Parser
my $cparser = HTCondor::Queue::Parser->new(); my @condor_q = read_file( 't/input.txt' ) ; # Text file with condor_q -global or condor_q output my %schedds_map = $cparser->load_schedds_xml(\@condor_q); foreach my $schedd (keys %schedds_map) { # This allows you to have simplified XMLs per schedd, that won't break XML parsers. # Default condor_q -global -l -xml does not outputs an my $simple_xml = $schedds_map{$schedd}{'xml'}; }
https://github.com/samircury/HTCondor--Queue--Parser/issues
Outputs condor queue's jobs different ways : Simpler XML per schedds, JSON
HTCondor's default output looks like :
<c> <a n="MyType"><s>Job</s></a> <a n="TargetType"><s>Machine</s></a> <a n="PeriodicRemove"><b v="f"/></a> <a n="CommittedSlotTime"><i>0</i></a> <a n="Out"><s>_condor_stdout</s></a> </c> # Fake line -- truncated for the example
Converted, simpler XML from this module looks like more :
<?xml version="1.0"?> <classads> <c> <MyType> Job </MyType> <TargetType> Machine </TargetType> <ClusterId> 790960 </ClusterId> <QDate> 1312487190 </QDate> <CompletionDate> 0 </CompletionDate> <Owner> uscmsPool1639 </Owner> <LocalUserCpu> 0.000000000000000E+00 </LocalUserCpu> <LocalSysCpu> 0.000000000000000E+00 </LocalSysCpu> <ExitStatus> 0 </ExitStatus> <NumCkpts_RAW> 0 </NumCkpts_RAW> <NumCkpts> 0 </NumCkpts> <NumRestarts> 0 </NumRestarts> <NumSystemHolds> 0 </NumSystemHolds> <CommittedTime> 0 </CommittedTime> </c> # Fake line -- truncated for the example </classads> # Fake line -- truncated for example
# This will only create the object then you can play with it later (see other methods) my $cparser = Condor::QueueParser->new();
# Here one should load the RAW output from $(condor_q -global -l -xml) it will spit a non-XML format and be converted later. $cparser->load_schedds_xml(\@condor_q); # What it does under the hood, is to get REAL XML for each schedd that the condor_q will present. # $cparser->{'schedds_map'} will be then loaded with a key per schedd, which contains the {'xml'} already
<classads><c> <a n="MyType"><s>Job</s></a>
Afterwards, it will contain what I call "more compatible" XML :
<classads> <c> <MyType> Job </MyType> <TargetType> Machine </TargetType>
This one should get the content of $self->{'schedds_map'}{$schedd}{'xml'} and populate $self->{'schedds_map'}{$schedd}{'href'} with a Perl equivalent multilevel hash, which will be the native format to Perl information, and you can use it in your application
Maybe the most useful way to use it is :
foreach my $schedd (keys %{$cparser->{'schedds_map'}}) { my $json = $cparser->schedd_json($schedd); # do something with $json; }
Find support available at https://github.com/samircury/condor4web or the CPAN's tracking system
Copyright 2012 Samir Cury.
To install HTCondor::Queue::Parser, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTCondor::Queue::Parser
CPAN shell
perl -MCPAN -e shell install HTCondor::Queue::Parser
For more information on module installation, please visit the detailed CPAN module installation guide.