Add new udafs and RMR support to gsprintconsole_ves
[com/gs-lite.git] / bin / pin_processes.pl
1 #! /usr/bin/perl
2
3 # ------------------------------------------------
4 #   Copyright 2014 AT&T Intellectual Property
5 #   Licensed under the Apache License, Version 2.0 (the "License");
6 #   you may not use this file except in compliance with the License.
7 #   You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #   Unless required by applicable law or agreed to in writing, software
12 #   distributed under the License is distributed on an "AS IS" BASIS,
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #   See the License for the specific language governing permissions and
15 #   limitations under the License.
16 # -------------------------------------------
17
18
19 $infl = "/var/log/gstrace";
20
21 if(scalar(@ARGV)>0){
22         $infl = $ARGV[0];
23 }
24
25 open I,$infl or die "Can't open input log file $infl\n";
26
27 %rts_pids= ();
28 %hfta_pids = ();
29 while($line=<I>){
30         if($line =~ /rts:\[.*\]: Started Logging/){
31                 %rts_pids= ();
32                 %hfta_pids = ();
33         }
34         if($line =~ /hfta_(\d+):\[(\d+)\]: Started Logging/){
35                 $name = "hfta_" . $1;
36                 $hfta_pids{$name} = $2;
37         }
38         if($line =~ /rts:\[(\d+)\]: Init LFTAs for (\w+)/){
39                 $name = "rts " . $2;
40                 $rts_pids{$name} = $1;
41         }
42 }
43
44 #foreach $k (keys(%rts_pids)){
45 #       print "$k, ",$rts_pids{$k},"\n";
46 #}
47 #foreach $k (keys(%hfta_pids)){
48 #       print "$k, ",$hfta_pids{$k},"\n";
49 #}
50                 
51 open C,"pinning_info.csv" or die "Can't open pinning_info.csv\n";
52
53 while($line=<C>){
54         chomp($line);
55         @flds = split /,/,$line;
56         if(exists($rts_pids{$flds[0]})){
57                 $pinning_cmd = "taskset -pc $flds[1] ". $rts_pids{$flds[0]};
58         }
59         if(exists($hfta_pids{$flds[0]})){
60                 $pinning_cmd = "taskset -pc $flds[1] ". $hfta_pids{$flds[0]};
61         }
62         print "Executing $pinning_cmd\n";
63         system($pinning_cmd);
64 }
65