[root@yyjk GET_ESB_TRANS_INFO]#cat Rexfile
use Rex -feature => ['1.0'];
use Rex::Misc::ShellBlock;
use Encode;
use Net::OpenSSH;
user "root";
private_key "/root/.ssh/id_rsa";
public_key "/root/.ssh/id_rsa.pub";
key_auth;
parallelism(20);
#parallelism 'max';
task "get_esb_trans_info","20.5.101.31",sub {
my $parameters = shift;
my $parameter1_value=$parameters->{parameter1};
my $output=run "sh /home/oracle/esb/get_esb_trans_info.sh $parameter1_value";
say $output;
};
[root@yyjk GET_ESB_TRANS_INFO]#cat rex_get_esb_trans_info.sh
. ~/.bash_profile
cd /root/rex/GET_ESB_TRANS_INFO
/usr/local/perl/bin/rex get_esb_trans_info --parameter1=$1
[root@yyjk GET_ESB_TRANS_INFO]#
You have mail in /var/spool/mail/root
[root@yyjk GET_ESB_TRANS_INFO]#cat /home/oracle/esb/get_esb_trans_info.sh
. ~/.bash_profile
cd /home/oracle/esb
perl get_esb_trans_info.pl $1
[root@yyjk GET_ESB_TRANS_INFO]#cat /home/oracle/esb/get_esb_trans_info.pl
use DBI;
use HTTP::Date qw(time2iso str2time time2iso time2isoz);
use Net::SMTP;
use Encode;
use JSON;
my $dbName = 'ESBDB';
my $dbUser = 'esbdata';
my $dbUserPass = 'esbdata';
my $dbh = DBI->connect("dbi:Oracle:$dbName", $dbUser, $dbUserPass) or die "can't connect to database ";
my $systag=$ARGV[0];
my $sql=qq{select * from (select /*+ parallel(t,8)*/ to_char(t.trans_date, 'yyyy-mm-dd HH24:MI:SS') as 交易日期,
t.esbserviceflowno as 全局流水号,
t.serviceid as 服务场景码,
s.description as 服务场景码描述,
t.logicchannel as 消费方,
t.logicsystem as 服务方,
t.respcode as 返回码,
t.respmsg as 返回信息,
p.developer,
p.operator,
p.department
from esb2_trans_log t
left join serviceinfo s
on t.serviceid = s.serviceid
left join tlcb_esb_yyzz p
on t.logicsystem=p.name
left join servicesystem ss
on t.logicsystem=ss.name
where t.trans_date >= trunc(sysdate)
and t.trans_date<=TRUNC(sysdate+1)
and (t.respmsg like '%Read timed out%' or t.respmsg like '%网络连接失败%' or t.respmsg like '%异常%' or
t.respmsg like '%超时%' or t.respmsg like '%数据库操作%' or t.respmsg like '%ORA%')
and t.esbserviceflowno is not null
and t.respcode <> '000000'
and (t.logicsystem <> 'AAAA' or t.respmsg <> 'TGT已超时')
AND (t.logicsystem <> 'ELINK' or t.respcode <> '3040')
AND (t.logicsystem <> 'IBPS' or t.respcode <> '600011')
AND (t.logicsystem <> 'CNAPS' or t.respcode <> 'AHVB001')
AND (t.logicsystem <> 'CNAPS' or t.respcode <> 'UPC002')
AND (t.logicsystem <> 'CNAPS' or t.respcode <> 'UPC002')
AND (t.logicsystem <> 'ELINK' or t.respcode <> 'Y999')
and (t.logicsystem <> 'ELINK' or t.respcode <> '600011')
and (t.logicsystem <> 'CIPS' or t.respcode <> '500101092209')
and (t.logicsystem <> 'CCFS' or t.respcode <> '500101092209')
and (t.logicsystem <> 'ELINK' or t.respcode <> '0201')
and (t.logicsystem <> 'ICCS' or t.respcode <> '0002')
and t.flowstepid in ('4', 'E')
and ss.description='$systag'
order by t.trans_date desc )
where rownum<11};
print $sql."
";
my @esb=();
my $sth = $dbh->prepare($sql);
$sth->execute();
while (@arr1=$sth->fetchrow_array){
my %h1=();
my $trans_date=$arr1[0];
my $esbserviceflowno=$arr1[1];
my $serviceid=$arr1[2];
my $description=$arr1[3];
my $logicchannel=$arr1[4];
my $logicsystem=$arr1[5];
my $respcode=$arr1[6];
my $respmsg=$arr1[7];
my $developer=$arr1[8];
my $operator=$arr1[9];
my $department=$arr1[10];
$h1{'trans_date'}=$trans_date;
$h1{'esbserviceflowno'}=$esbserviceflowno;
$h1{'serviceid'}=$serviceid;
$h1{'description'}=$description;
$h1{'logicchannel'}=$logicchannel;
$h1{'logicsystem'}=$logicsystem;
$h1{'respcode'}=$respcode;
$h1{'respmsg'}=$respmsg;
$h1{'developer'}=$developer;
$h1{'operator'}=$operator;
$h1{'department'}=$department;
push @esb,\%h1;
};
$sth->finish;
$dbh->disconnect;
print encode_json(@esb);