Perl script appending date - perl
Am running this perl script ever day on my server and am getting the below output for the script. I am trying to modify the script to also include the current hour as part of the output. How can I go about doing this?
This is my current script:
#!/usr/bin/perl
#Prism Performance log Parser
use strict;
my $cbal_total;
my $cbal_count =0;
my $stck_total = 0;
my $stck_count =0;
my $chg_total = 0;
my $chg_count =0;
my $rmac_total = 0;
my $rmac_count =0;
my $rmd_total = 0;
my $rmd_count =0;
my $cbalT;
my $stckT;
my $rmacT;
my $rmdT;
my $chgT;
my $total;
my $count;
my $cbal;
my $stck;
my $hour;
my $chg;
my $rmac;
my $rmd;
my $lesThresh=0;
my $gtThresh=0;
my $stck_lesThresh=0;
my $stck_gtThresh=0;
my $rmd_lesThresh=0;
my $rmd_gtThresh=0;
my $chg_lesThresh=0;
my $chg_gtThresh=0;
my $rmac_lesThresh=0;
my $rmac_gtThresh=0;
my %CheckBal;
my %SubTypeCheck;
my %charging;
my %remoteAct;
my %remoteDct;
my $chgkey;
my $cbalkey;
my $stckkey;
my $rmackey;
my $rmdkey;
my #value;
my $ct;
my $component;
my $component2;
while (my $line =<>) {
chomp;
s/\r//g;
my #f = split(/\|/, $line);
my $i;
$hour = substr($f[0],11,2);
for ($i==0;$i<=100; $i++) {
if (($f[$i]=~m/CBAL/) && ($f[$i]!~m/CBAL,100/)) {
$component="CBAL";
$cbal=$f[$i];
$cbalkey="$hour,$component";
if (!exists($CheckBal{$cbalkey})) {
$cbal_count=0;
$cbal_total=0;
$lesThresh=0;
$gtThresh=0;
}
$cbalT = substr($cbal,index($cbal,",T=")+3,index($cbal,"\n"));
if ($cbalT <= 300) {
$lesThresh++;
}else{
$gtThresh++
}
$cbal_total +=$cbalT;
$cbal_count ++;
#$CheckBal{$cbalkey} =($cbal_total).",".($cbal_count).",".($lesThresh).",".$gtThresh.",".($cbal_total/$cbal_count);
$CheckBal{$cbalkey} =($cbal_count).",".($cbal_total).",".($cbal_total/$cbal_count).",".($lesThresh).",".$gtThresh;
}elsif($f[$i]=~m/STCK/){
$component="STCK";
$stck=$f[$i];
$stckkey="$hour,$component";
if (!exists($SubTypeCheck{$stckkey})) {
$stck_count=0;
$stck_total=0;
$stck_lesThresh=0;
$stck_gtThresh=0
}
$stckT = substr($stck,index($stck,",T=")+3,index($stck,"\n"));
if ($stckT <= 300) {
$stck_lesThresh++;
}else{
$stck_gtThresh++
}
$stck_total +=$stckT;
$stck_count ++;
# $SubTypeCheck{$stckkey} =($stck_total).",".($stck_count).",".($stck_lesThresh).",".$stck_gtThresh.",".($stck_total/$stck_count);
$SubTypeCheck{$stckkey} =($stck_count).",".($stck_total).",".($stck_total/$stck_count).",".($stck_lesThresh).",".$stck_gtThresh;
}elsif($f[$i]=~m/CHG/){
$component="CHG";
$chg=$f[$i];
$chgkey="$hour,$component";
if (!exists($charging{$chgkey})) {
$chg_count=0;
$chg_total=0;
$chg_lesThresh=0;
$chg_gtThresh=0
}
$chgT = substr($chg,index($chg,",T=")+3,index($chg,"\n"));
if ($chgT <= 300) {
$chg_lesThresh++;
}else{
$chg_gtThresh++
}
$chg_total +=$chgT;
$chg_count ++;
# $charging{$chgkey} =($chg_total).",".($chg_count).",".($chg_lesThresh).",".$chg_gtThresh.",".($chg_total/$chg_count);
$charging{$chgkey} =($chg_count).",".($chg_total).",".($chg_total/$chg_count).",".($chg_lesThresh).",".$chg_gtThresh;
}elsif(($f[$i]=~m/RMAC/) && ($f[$i]!~m/RMAC,96/)){
$component="RMAC";
$rmac=$f[$i];
$rmackey="$hour,$component";
if (!exists($remoteAct{$rmackey})) {
$rmac_count=0;
$rmac_total=0;
$rmac_lesThresh=0;
$rmac_gtThresh=0
}
$rmacT = substr($rmac,index($rmac,",T=")+3,index($rmac,"\n"));
if ($rmacT <= 300) {
$rmac_lesThresh++;
}else{
$rmac_gtThresh++
}
$rmac_total +=$rmacT;
$rmac_count ++;
# $remoteAct{$rmackey} =($rmac_total).",".($rmac_count).",".($rmac_lesThresh).",".$rmac_gtThresh.",".($rmac_total/$rmac_count);
$remoteAct{$rmackey} =($rmac_count).",".($rmac_total).",".($rmac_total/$rmac_count).",".($rmac_lesThresh).",".$rmac_gtThresh;
}elsif(($f[$i]=~m/RMD/) && ($f[$i]!~m/RMD,96/)){
$component="RMD";
$rmd=$f[$i];
$rmdkey="$hour,$component";
if (!exists($remoteDct{$rmdkey})) {
$rmd_count=0;
$rmd_total=0;
$rmd_lesThresh=0;
$rmd_gtThresh=0
}
$rmdT = substr($rmd,index($rmd,",T=")+3,index($rmd,"\n"));
if ($rmdT <= 300) {
$rmd_lesThresh++;
}else{
$rmd_gtThresh++
}
$rmd_total +=$rmdT;
$rmd_count ++;
# $remoteDct{$rmdkey} =($rmd_total).",".($rmd_count).",".($rmd_lesThresh).",".$rmd_gtThresh.",".($rmd_total/$rmd_count);
$remoteDct{$rmdkey} =($rmd_count).",".($rmd_total).",".($rmd_total/$rmd_count).",".($rmd_lesThresh).",".$rmd_gtThresh;
}
}
}
print "Balance Check\n";
print "Hour,Task,Total Transactions,Total Processing Time/ms,Average TPS/ms,<300 ms,>300 ms\n";
unless(%CheckBal){
print "No record found for STCK\n";
}
foreach (sort keys %CheckBal){
print $_.",".$CheckBal{$_}."\n";
}
Current Output:
Balance Check
Hour,Task,Total Transactions,Total Processing Time/ms,Average TPS/ms,<300 ms,>300 ms
06,CBAL,17987,13131831,730.073441930283,4295,13692
07,CBAL,17911,13579801,758.182178549495,3970,13941
08,CBAL,228,98643,432.644736842105,100,128
Desired Output:
Balance Check
date,Hour,Task,Total Transactions,Total Processing Time/ms,Average TPS/ms,<300 ms,>300 ms
20140528,06,CBAL,17987,13131831,730.073441930283,4295,13692
20140528,07,CBAL,17911,13579801,758.182178549495,3970,13941
20140528,08,CBAL,228,98643,432.644736842105,100,128
To get the current hour, use Time::Piece
use strict;
use warnings;
use Time::Piece;
print localtime->strftime("%H"), "\n";
How to insert that functionality into your script is an exercise for you.
Related
Parsing a config file with nested braces
I put this script together to get what is inside the member's brackets. This is not JSON - is it just a bracketed config file. I am trying to think of a better way to do it. This shop is very limited on the modules that they use, which is kind of why I had to use the on-off tags. If this could really done by a module, then I suppose I could get a requisition to add a new module. Be that as it may, is there a way to just get what is inside the member { ... } like using a while loop instead of tagging each bracket with an on or off tag. #!/sbcimp/dyn/data/EVT/GSD/scripts/perl/bin/perl use strict; use warnings; my %penny_hash = (); my $penny_file = "penny_config.cfg"; open(FOOO, "<$penny_file") or die "Can't open $penny_file for reading: $!"; foreach my $line (<FOOO>) { chomp($line); if ($line =~ /^\s*TickSize\s+=\s+\{/) { $ticksize_flag = 1; } elsif (($ticksize_flag == 1) && ($line =~ /^\s*penny.*\s+=\s+\{/)) { $penny_flag = 1; } elsif (($penny_flag == 1) && ($line =~ /^\s*members\s+=\s+\{/)) { $member_flag = 1; } elsif (($member_flag == 1) && ($line =~ /\}/)) { $member_flag = 0; } elsif (($member_flag == 1) && ($line =~ /\s*(\S+)\s*$/)) { print $line ; print "\n"; } } This is the config file # Tick Size # tr -d \ | sort -u TickSizePostOpen = 1.00 TickSize = { penny1 = { TickSize = 0.00 members = { IWM QQQ SPY SPY_TEST } } penny = { TickSize = </0.000/0.00/0.00 members = { A AA AAL AAPL ABT ABT_SPIN ZNGA } } notpenny = { TickSize = </9/9.99/9.99 } } BIPP.QuoterOx = { Cup1and2 = { BIPP.QuoterOx = BIPP-ox-1 members = { Cup_1 Cup_2 } } TRAP.PxByGroup = 1 TRAP.Px = { group1 = { TRAP.Px = OPTxxxxxx members = { px.TRAP.1 } } group2 = { TRAP.Px = OPTxxxxxx members = { px.TRAP.2 } } TRAP.QuoterOx = { Cup0 = { TRAP.QuoterOx = QESxxxxx members = { Cup_0 Cup_99 } } Cup1and4and10 = { TRAP.QuoterOx = ise-ox-1-4-10-dti members = { Cup_1 Cup_4 Cup_10 } } Cup56 = { TRAP.AuctionOx = ise-ox-56-ecl members = { Cup_56 } } } TRAP.RotateQuote = { rotatenames = { TRAP.RotateQuote = 1 members = { AAPL ADY AEIS AFAM AGP ALNY ZINC } } } Underlying = { Cup0 = { Underlying = MHR members = { Cup_0 } } g1 = { Underlying = CEL members = { Cup_1 } } } BIPP.Px = { group1 = { BIPP.Px = BOXPXMHR1 members = { px.BIPP.1 } } group2 = { BIPP.Px = BOXPXMHR2 members = { px.BIPP.2 } } } TWIG.Px = { AB = { TWIG.Px = TWIGPXMHR1 members = { A B } } CD = { TWIG.Px = TWIGPXMHR2 members = { C D } } NOPQR = { TWIG.Px = TWIGPXMHR6 members = { N O P Q R } } STUV = { TWIG.Px = TWIGPXMHR7 members = { S T U V } } WXYZ = { TWIG.Px = TWIGPXMHR8 members = { W X Y Z } } } There are the results that I get: IWM QQQ SPY SPY_TEST A AA AAL AAPL ABT ZNGA ZNGA Bin_1 Bin_2 px.xisx.1 px.xisx.2 Bin_0 Bin_99 Bin_56 AAPL ADY AEIS AFAM AGP ALNY ZINC Bin_0 Bin_1 px.xbox.1 px.xbox.2 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
What you have written just strips the comments and field names from the original file. There is no need to go to such lengths to do that. This program produces the same output use strict; use warnings; use autodie; open my $fh, '<', 'penny_config.cfg'; while (<$fh>) { next unless /\S/; print unless /[#{}=]/; }
Someone already comment that you should look at Config::General or YAML. You should look at Config::General and YAML. YAML is JSON compatible, but offers more features than JSON. Since your data already looks a little bit like JSON, converting it to JSON would allow you to use existing JSON or YAML tools for interpreting it. Config::General is modelled after the Apache Configuration File Format and has a better feature set than YAML. Once you become familiar enough with Config::General it would be just as easy to migrate your data to it as JSON. For one of my projects I wrote a configuration DSL in on top of Config::General. Config::General supports Comments, HereDocs, and multiple values for an item. YAML and JSON are widely implemented in languages other than Perl. Config::General is Perl only. If you can get modules installed I recommend that regardless of which you decide to use that you request installation of Config::General, YAML::XS, JSON, and or whichever alternate JSON modules you like. If that is a problem there are a number of solutions for installing Perl Modules either in your home directory or in your application.
perl date time quandry
I am trying to use perl date/time and also get file date info. I started with this routine: sub getTime { #arrayDate = localtime(time); ($strSec,$strMin,$strHr,$strDate,$strMo,$strYr,$strDOW,$strDOY,$strDST) = localtime(time); $strYr += 1900; $strMo += 1; if (length($strMo) < 2) { $strMo = "0" . $strMo } if (length($strDate) < 2) { $strDate = "0" . $strDate } if (length($strHr) < 2) { $strHr = "0" . $strHr } if (length($strMin) < 2) { $strMin = "0" . $strMin } if (length($strSec) < 2) { $strSec = "0" . $strSec } $strDateTime = "$strYr$strMo$strDate $strHr:$strMin:$strSec"; } Which worked fine. Then I needed to get file date info using $file1date = ctime(stat($flatFile1)->mtime);. Here is where the confusion begins. If I add use File::stat and use Time::localtime to get the file date to work, the first routine stops working and gives me this as output: 1900010 0:0:Time::tm=ARRAY(0x9a7b98) So in order to get both to work I had to change the date routine to this: sub getTime { $strMon = localtime->mon(); $strMday = localtime->mday(); $strYear = localtime->year(); $strHour = localtime->hour(); $strMin = localtime->min(); $strSec = localtime->sec(); $strYear += 1900; $strMon += 1; if (length($strMon) < 2) { $strMon = "0" . $strMon } if (length($strMday) < 2) { $strMday = "0" . $strMday } if (length($strHour) < 2) { $strHour = "0" . $strHour } if (length($strMin) < 2) { $strMin = "0" . $strMin } if (length($strSec) < 2) { $strSec = "0" . $strSec } $strDateTime = "$strYear$strMon$strMday $strHour:$strMin:$strSec"; } ... which I'm sure is not efficient. What's the right way to do this?
I'd like to advise you to use Time::Piece. The above core module alters the behavior of localtime to return an object of type Time::Piece that has a strftime function. The following are your two goals performed with this module: use strict; use warnings; use Time::Piece; use File::stat; print "Current time: " . localtime->strftime("%Y%m%d %H:%M:%S") . "\n"; print "Script created: " . localtime(stat($0)->ctime)->strftime("%Y%m%d %H:%M:%S") . "\n"; Outputs: Current time: 20140624 19:18:17 Script created: 20140624 15:54:36
I wouldn't say that there's anything wrong with the second method. My only suggestion would be to use sprintf to format $strDateTime instead of a block of if statements: sub getTime { $strDateTime = sprintf("%04d%02d%02d %02d:%02d:%02d", localtime->year() + 1900, localtime->mon() + 1, localtime->mday(), localtime->hour(), localtime->min(), localtime->sec()); } For reference: the field %04d means a decimal (d) field of length 4, padded with 0. Using fixed-length, padded decimal fields is a quick and easy way to format numbers. You can see the whole guide on sprintf in the documentation.
How to cluster based on ssdeep?
Hi I am trying to find the groups out of files based on ssdeep. I have generated ssdeep of files and kept it in csv file. I am parsing the file in perl script as follows: foreach( #all_lines ) { chomp; my $line = $_; my #split_array = split(/,/, $line); my $md5 = $split_array[1]; my $ssdeep = $split_array[4]; my $blk_size = (split(/:/, $ssdeep))[0]; if( $blk_size ne "") { my $cluster_id = check_In_Cluster($ssdeep); print WFp "$cluster_id,$md5,$ssdeep\n"; } } This also checks whether the ssdeep is present in previously clustered group and if not creates new group. Code for chec_In_Cluster my $ssdeep = shift; my $cmp_result; if( $cluster_cnt > 0 ) { $cmp_result = ssdeep_compare( $MRU_ssdeep, $ssdeep ); if( $cmp_result > 85 ) { return $MRU_cnt; } } my $d = int($cluster_cnt/4); my $thr1 = threads->create(\&check, 0, $d, $ssdeep); my $thr2 = threads->create(\&check, $d, 2*$d, $ssdeep); my $thr3 = threads->create(\&check, 2*$d, 3*$d, $ssdeep); my $thr4 = threads->create(\&check, 3*$d, $cluster_cnt, $ssdeep); my ($ret1, $ret2, $ret3, $ret4); $ret1 = $thr1->join(); $ret2 = $thr2->join(); $ret3 = $thr3->join(); $ret4 = $thr4->join(); if($ret1 != -1) { $MRU_ssdeep = $ssdeep; $MRU_cnt = $ret1; return $MRU_cnt; } elsif($ret2 != -1) { $MRU_ssdeep = $ssdeep; $MRU_cnt = $ret2; return $MRU_cnt; } elsif($ret3 != -1) { $MRU_ssdeep = $ssdeep; $MRU_cnt = $ret3; return $MRU_cnt; } elsif($ret4 != -1) { $MRU_ssdeep = $ssdeep; $MRU_cnt = $ret4; return $MRU_cnt; } else { $cluster_base[$cluster_cnt] = $ssdeep; $MRU_ssdeep = $ssdeep; $MRU_cnt = $cluster_cnt; $cluster_cnt++; return $MRU_cnt; } and the code for chech: sub check($$$) { my $from = shift; my $to = shift; my $ssdeep = shift; for( my $icnt = $from; $icnt < $to; $icnt++ ) { my $cmp_result = ssdeep_compare( $cluster_base[$icnt], $ssdeep ); if( $cmp_result > 85 ) { return $icnt; } } return -1; } But this process takes very much time( for 20-30MB csv file it takes 8-9Hours). I have also tried using multithreading while checking in Cluster but not much help i got from this. Since their is no need of csv parser like Text::CSV (because of less operation on csv) i didn't used it. can anybody please solve my issue? Is it possible to use hadoop or some other frameworks for grouping based on ssdeep?
There is a hint from Optimizing ssDeep for use at scale (2015-11-27). Depends on your purpose, loop and match SSDEEP in different chunk size will create a N x (N-1) hash comparison. Unless you need to find partial contents, otherwise, avoid it. It is possible to breakdown of the hash index in step 1 as suggested in the article. This is a better way for partial contents match with different chunk size. It is possible to reduce SSDEEP hash by grouping similar hash by generate a "distance cousin" hash.
socks 5 proxy on Perl
I am new in Perl and trying to understand this cod in Link : http://codepaste.ru/1374/but I have some problem in understanding this part of code: while($client || $target) { my $rin = ""; vec($rin, fileno($client), 1) = 1 if $client; vec($rin, fileno($target), 1) = 1 if $target; my($rout, $eout); select($rout = $rin, undef, $eout = $rin, 120); if (!$rout && !$eout) { return; } my $cbuffer = ""; my $tbuffer = ""; if ($client && (vec($eout, fileno($client), 1) || vec($rout, fileno($client), 1))) { my $result = sysread($client, $tbuffer, 1024); if (!defined($result) || !$result) { return; } } if ($target && (vec($eout, fileno($target), 1) || vec($rout, fileno($target), 1))) { my $result = sysread($target, $cbuffer, 1024); if (!defined($result) || !$result) { return; } } if ($fh && $tbuffer) { print $fh $tbuffer; } while (my $len = length($tbuffer)) { my $res = syswrite($target, $tbuffer, $len); if ($res > 0) { $tbuffer = substr($tbuffer, $res); } else { return; } } while (my $len = length($cbuffer)) { my $res = syswrite($client, $cbuffer, $len); if ($res > 0) { $cbuffer = substr($cbuffer, $res); } else { return; } } } can any body explain to me exactly whats happen in these lines: vec($rin, fileno($client), 1) = 1 if $client; vec($rin, fileno($target), 1) = 1 if $target; and select($rout = $rin, undef, $eout = $rin, 120);
Basically, the select operator is used to find which of your file descriptors are ready (readable, writable or there's an error condition). It will wait until one of the file descriptors is ready, or timeout. select RBITS, WBITS, EBITS, TIMEOUT RBITS is a bit mask, usually stored as a string, representing a set of file descriptors that select will wait for readability. Each bit of RBITS represent a file descriptor, and the offset of the file descriptor in this bit mask should the file descriptor number in system. Thus, you could use vec to generate this bit mask. vec EXPR, OFFSET, BITS The vec function provides storage of lists of unsigned integers. EXPR is a bit string, OFFSET is the offset of bit in EXPR, and BITS specifies the width of each element you're reading from / writing to EXPR. So these 2 lines: vec($rin, fileno($client), 1) = 1; vec($rin, fileno($target), 1) = 1; They made up a bit mask string $rin with setting the bit whose offset equals the file descriptor number of $client, as well as the one of $target. Put it into select operator: select($rout = $rin, undef, $eout = $rin, 120); Then select will monitor the readability of the two file handlers ($client and $target), if one of them is ready, select will return. Or it will return after 120s if no one is ready. WBITS, EBITS use the same methodology. So you could infer that the above select line will also return when the two file handler have any exceptions.
Does any one have a working script of LoadRunner Automation API?
Currently I am writing Perl script that creates LoadRunner scenario, execute the test, collect the result, recover the environment and repeat the cycle again with different scenario variables. I don't have a problem creating new scenario, adding generator, adding 2 groups + script + the run-time settings. But I am having a problem with: Setting scenario schedule from "Scenario" to "Group". Setting schedule per group This the snippet of the code: use strict; use v5.10; use Win32::OLE; use Win32::OLE::Enum; use Win32::OLE::Variant; use Data::Dumper; use Win32::OLE::Const 'LoadRunner Automation Library'; use constant False => Variant(VT_BOOL,''); use constant True => Variant(VT_BOOL,1); my $lrEngine = Win32::OLE->new('wlrun.LrEngine') or die "oops\n"; my $lrScenario = $lrEngine->Scenario(); my $rc = $lrScenario->new(0, 1); # do not save previous, Regular vusers based scenario if ($rc != 0) { print "Win32::OLE::LastError: ".Win32::OLE::LastError()."\n"; print "lrScenario->new(0, 1):rc: $rc\n"; } # snip-snipped - add generator # snip-snipped - add #groups definition foreach my $group (#groups) { print "scriptName: $group->{scriptName}\n"; my $scriptLocation = $group->{scriptLocation}; my $scriptName = Variant(VT_BSTR|VT_BYREF, $group->{scriptName}); { # add $group->{scriptName} script $rc = $lrScenario->Scripts->Add($scriptLocation, $scriptName); if ($rc != 0) { print "Win32::OLE::LastError: ".Win32::OLE::LastError()."\n"; print "lrScenario->Scripts->Add($scriptLocation, $scriptName):rc: $rc\n"; } } ############################################################################# my $groupName = Variant(VT_BSTR|VT_BYREF, $group->{groupName}); { # add $group->{groupName} group $rc = $lrScenario->Groups->Add($groupName); if ($rc != 0) { print "Win32::OLE::LastError: ".Win32::OLE::LastError()."\n"; print "lrScenario->Groups->Add:rc: $rc\n"; } $rc = $lrScenario->Groups->Item($groupName)->AddVusers($scriptName, $hostname, 3); if ($rc != 0) { print "Win32::OLE::LastError: ".Win32::OLE::LastError()."\n"; print "lrScenario->Groups->Item($groupName)->AddVusers:rc: $rc\n"; } } ############################################################################# # snip-snipped - change group script run time setting } my $scheduleName = Variant(VT_BSTR|VT_BYREF, 'Schedule123'); my $lrManualScheduleData = $lrScenario->ManualScheduler->AddSchedule($scheduleName, lrGroupSchedule); # Scenario schedule mode if (!$lrManualScheduleData) { say "Win32::OLE::LastError: ".Win32::OLE::LastError(); say "lrScenario->ManualScheduler->AddSchedule:rc: $rc"; } $rc = $lrScenario->ManualScheduler->SetCurrentSchedule($scheduleName); if ($rc != 0) { say "Win32::OLE::LastError: ".Win32::OLE::LastError(); say "lrScenario->ManualScheduler->SetCurrentSchedule:rc: $rc"; } print "\$lrScenario->ManualScheduler->SetScheduleMode($scheduleName, lrGroupSchedule):"; $lrScenario->ManualScheduler->SetScheduleMode($scheduleName, lrGroupSchedule); #LrManualScheduleMode -> lrGroupSchedule = 1, lrScenarioSchedule = 0 say "Win32::OLE::LastError: ".Win32::OLE::LastError(); $lrManualScheduleData->{'InitAllBeforeRun'} = 'True'; $lrManualScheduleData->{'DurationMode'} = 1; $lrManualScheduleData->{'Duration'} = 60 * 60; $lrManualScheduleData->{'RampupBatchSize'} = 1; $lrManualScheduleData->{'RampupMode'} = lrRampupByGroupBatches; $lrManualScheduleData->{'RampupTimeInterval'} = 5; $lrManualScheduleData->{'RampdownBatchSize'} = 1; $lrManualScheduleData->{'RampdownMode'} = lrRampupByGroupBatches; $lrManualScheduleData->{'RampdownTimeInterval'} = 5; $rc = $lrScenario->ManualScheduler->{'ScenarioStartTimeMode'} = 0; # Start scenario without delay #test say "$scheduleName: ".$lrScenario->ManualScheduler->Schedule($scheduleName)->{'Duration'}; # returns 300
I have the same problem. Setting those properties and then calling either setschedulemode or setcurrentschedule doesn't seem to work. The only workaround I have found is to use the setscheduledata method passing in xml. You will need to get the current xml for the scheduledata and then change the xml, passing in the modified xml to the setscheduledata method. Hopefully this helps lrManualScheduleData data = engine.Scenario.ManualScheduler.get_Schedule("Schedule 1"); String scheduleXML,errStr; int returncode = data.getScheduleData(out scheduleXML, out errStr); // Manipulate the XML to set whatever schedule you want data.SetScheduleData(scheduleXML, out errStr);