6 # Finding out own path in order to reference own components (including own modules):
10 $ENV{
'EHIVE_ROOT_DIR'} ||= File::Basename::dirname( File::Basename::dirname( Cwd::realpath($0) ) );
11 unshift @INC, $ENV{
'EHIVE_ROOT_DIR'}.
'/modules';
14 use Getopt::Long qw(:config no_auto_abbrev);
29 my ($url, $reg_conf, $reg_type, $reg_alias, $nosqlvc, $source_line, $username, $meadow_type, $help);
32 # connect to the database:
34 'reg_conf|regfile=s' => \$reg_conf,
35 'reg_type=s' => \$reg_type,
36 'reg_alias|regname=s' => \$reg_alias,
37 'nosqlvc' => \$nosqlvc, #
using "nosqlvc" instead of
"sqlvc!" for consistency with scripts where it is a propagated option
39 'username=s' => \$username, # say
"-user all" if the pipeline was
run by several people
40 'source_line=s' => \$source_line,
41 'meadow_type=s' => \$meadow_type,
43 ) or die "Error in command line arguments\n";
46 die
"ERROR: There are invalid arguments on the command-line: ". join(
" ", @ARGV).
"\n";
50 pod2usage({-exitvalue => 0, -verbose => 2});
54 if($url or $reg_alias) {
57 -reg_conf => $reg_conf,
58 -reg_type => $reg_type,
59 -reg_alias => $reg_alias,
60 -no_sql_schema_version_check => $nosqlvc,
62 $hive_dba->dbc->requires_write_access();
64 die
"\nERROR: Connection parameters (url or reg_conf+reg_alias) need to be specified\n";
67 my $queen = $hive_dba->get_Queen;
68 my $meadow_2_pid_wid = $queen->fetch_HASHED_FROM_meadow_type_AND_meadow_name_AND_process_id_TO_worker_id();
75 my $meadow = $valley->available_meadow_hash->{$meadow_type ||
''} || $valley->get_available_meadow_list()->[0];
76 warn
"Taking the resource_usage data from the source ( $source_line ), assuming Meadow ".$meadow->signature.
"\n";
78 if(my $report_entries = $meadow->parse_report_source_line( $source_line ) ) {
79 $queen->store_resource_usage( $report_entries, $meadow_2_pid_wid->{$meadow->type}{$meadow->cached_name} );
83 warn
"Searching for Workers without known resource_usage...\n";
85 my $meadow_2_interval = $queen->interval_workers_with_unknown_usage();
87 foreach my $meadow (@{ $valley->get_available_meadow_list() }) {
89 warn
"\nFinding out the time interval when the pipeline was run on Meadow ".$meadow->signature.
"\n";
91 if(my $our_interval = $meadow_2_interval->{ $meadow->type }{ $meadow->cached_name } ) {
92 if(my $report_entries = $meadow->get_report_entries_for_time_interval( $our_interval->{
'min_submitted'}, $our_interval->{
'max_died'}, $username ) ) {
93 $queen->store_resource_usage( $report_entries, $meadow_2_pid_wid->{$meadow->type}{$meadow->cached_name} );
96 warn
"\tNothing new to store for Meadow ".$meadow->signature.
"\n";
108 load_resource_usage.pl
112 This script obtains resource
usage data
for your pipeline from the Meadow and stores it in the C<worker_resource_usage> table.
113 Your Meadow
class/plugin has to support offline examination of resources in order
for this script to work.
115 Based on the start time of the first Worker and end time of the last Worker (as recorded in the pipeline database),
116 it pulls the relevant data out of your Meadow (runs the C<bacct> script in
case of LSF), parses the report and stores in the C<worker_resource_usage> table.
117 You can join
this table to the C<worker> table USING(meadow_name,process_id) in the usual MySQL way
118 to filter by analysis_id,
do various stats, etc.
120 You can optionally provide an an external filename or command to get the data from it (don
't forget to append a "|" to the end!)
121 and then the data will be taken from your source and parsed from there.
123 =head1 USAGE EXAMPLES
125 # Just run it the usual way: query and store the relevant data into "worker_resource_usage" table:
126 load_resource_usage.pl -url mysql://username:secret@hostname:port/long_mult_test
128 # The same, but assuming another user "someone_else" ran the pipeline:
129 load_resource_usage.pl -url mysql://username:secret@hostname:port/long_mult_test -username someone_else
131 # Assuming the dump file existed. Load the dumped bacct data into "worker_resource_usage" table:
132 load_resource_usage.pl -url mysql://username:secret@hostname:port/long_mult_test -source long_mult.bacct
134 # Provide your own command to fetch and parse the worker_resource_usage data from:
135 load_resource_usage.pl -url mysql://username:secret@hostname:port/long_mult_test -source "bacct -l -C 2012/01/25/13:33,2012/01/25/14:44 |" -meadow_type LSF
145 =item --url <url string>
147 URL defining where eHive database is located
149 =item --username <username>
151 if it wasn't you who ran the pipeline, the name of that user can be provided
153 =item --source <filename>
155 alternative source of worker_resource_usage data. Can be a filename or a pipe-from command.
157 =item --meadow_type <type>
159 only used when -source is given. Tells which meadow type the source filename relates to. Defaults to the first available meadow (LOCAL being considered as the last available)
163 "No SQL Version Check" - set
if you want to force working with a database created by a potentially schema-incompatible API
169 See the NOTICE file distributed with
this work
for additional information
170 regarding copyright ownership.
172 Licensed under the Apache License, Version 2.0 (the
"License"); you may not use
this file except in compliance with the License.
173 You may obtain a copy of the License at
177 Unless required by applicable law or agreed to in writing, software distributed under the License
178 is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179 See the License
for the specific language governing permissions and limitations under the License.
183 Please subscribe to the eHive mailing list: http: