Quantcast
Channel: THWACK: All Content - Server & Application Monitor
Viewing all articles
Browse latest Browse all 12281

Perl Script assistance

$
0
0


Currently need some assistance with a perl script i am writing.  I will state first thhat this is my first script and i have absolutely no idea what i'm doing here.

 

Back story I have an XML that im trying to get solarwinds to monitor but the only way to output the XML is to put it in a perl script.  ive created the script but solarwinds will not output    " Can't identify dynamic column definitions from script output. Please, check if script output has properly formatted unique identifiers."

 

What this is suppose to do is basiclly use the xml inputted and give me a response/processign time from our website.  ive pasted the entire script below.  any please let me know where im going wrong because im not being told what line my errors are on.

 

#!/usr/bin/perl
use strict;
use warnings;

use LWP::UserAgent;
use HTTP::Headers;
use HTTP::Request;


use POSIX qw(strftime);

my $sd = strftime("%d", localtime(time)) + $ARGV[0];
my $ed = $sd + $ARGV[1];
my $tmstmp = strftime("%Y-%m-%dT%H:%M:%S", localtime(time));
my $startDt = strftime("%Y-%m-$sd", localtime(time));
my $endDt = strftime("%Y-%m-$ed", localtime(time));

<?xml version encoding="UTF-8"?>',
'<OTA_HotelAvailRQ xmlns="http://www.opentravel.org/OTA/2003/03" EchoToken="Naga" TimeStamp="2009-05-02T00:00:00" Target="Production" Version="2.0" SequenceNmbr="1234567890" SummaryOnly="true">',
'               <POS>',
'                                <Source>',
'                                               <RequestorID Type="4" ID="CriticalMass" />',
'                                </Source>',
'                               <Source>',
'                                                <RequestorID Type="1" ID="127.0.0.1" />',
'                               </Source>',
'                </POS>',
'               <AvailRequestSegments>',
'                                <AvailRequestSegment>',
'                                               <StayDateRange Start="2014-01-29" End="2014-01-30" />',
'                                                <RatePlanCandidates>',
'                                                               <RatePlanCandidate RatePlanType="13" />',
'                                                </RatePlanCandidates>',
'                                                <RoomStayCandidates>',
'                                                                <RoomStayCandidate Quantity="1">',
'                                                                                <GuestCounts IsPerRoom="true">',
'                                                                                               <GuestCount AgeQualifyingCode="10" Count="1" />',
'                                                                                                <GuestCount AgeQualifyingCode="8" Count="0" />',
'                                                                                </GuestCounts>',
'                                                                </RoomStayCandidate>',
'                                               </RoomStayCandidates>',
'                                                <HotelSearchCriteria>',
'                                                                <Criterion>',
'                                                                                <HotelRef ChainCode="HY" HotelCode="bosto" />',
'                                                                                <HotelRef ChainCode="HY" HotelCode="bosha" />',
'                                                                                <HotelRef ChainCode="HY" HotelCode="bosrc" />',
'                                                                                <HotelRef ChainCode="HY" HotelCode="boszm" />',
'                                                                                <HotelRef ChainCode="HY" HotelCode="bosxw" />',
'                                                                                <HotelRef ChainCode="HY" HotelCode="bosxb" />',
'                                                                </Criterion>',
'                                                </HotelSearchCriteria>',
'                               </AvailRequestSegment>',
'                </AvailRequestSegments>',
'</OTA_HotelAvailRQ>');
   

my $ua = LWP::UserAgent->new();

my $h = HTTP::Headers->new(
    Content_Length      => length($xmlIn),
    Content_Type        => 'text/xml'
);

#print join (", ",@ARGV);

my $r = HTTP::Request->new('POST', $ARGV[2], $h, $xmlIn);

my $response = $ua->request($r);
if ($response->is_success) {
    #print $response->content;
    #if($response->content =~ m/Success/i) {print join('','\n\n',$response->content,'\n\nOK_RESPONSE\n');}
    #
    # Error Code="448" Type="BizRule">
    my $strVal = uc($response->content);
    if(index($strVal,'SUCCESS') < 0 ){
      my $err = index($strVal,'ERROR CODE');
      if($err > -1){
         $err += 12;
         my $respErr = substr $strVal,$err,5;
         if(index($respErr,'GDS00') > -1 ||
            index($respErr,'GDS01') > -1 ||
            index($respErr,'GDS02') > -1 ||
            index($respErr,'HDR01') > -1 ||
            index($respErr,'HDR06') > -1 ||
            index($respErr,'191') > -1){

            # Email to support
            #  Email to andre.reed@hyatt.com, anna.mui@hyatt.com, larry.rich@hyatt.com
            print join('', '********* Request FAILED: errorcode=',$respErr, '.  If there is no scheduled outage, including GDS nightly restart, and more than 2 of these emails have been sent contact GDS/Booker support.');

         }else{
             #  Email to andre.reed@hyatt.com, anna.mui@hyatt.com, larry.rich@hyatt.com
             #
             print join('','******** SUCCESSw/Error  - email development errorcode: ',$respErr);
            
         }

      }
     
    }elsif(index($strVal,'SUCCESS')> -1){
             #  Email to andre.reed@hyatt.com, anna.mui@hyatt.com, larry.rich@hyatt.com
             #
         print 'Message.1:*********  SUCCESS no action required  **********  ';
         print 'Statistic.1:0';


    }else{
            # Email to support
            #  Email to andre.reed@hyatt.com, anna.mui@hyatt.com, larry.rich@hyatt.com
          print join('', 'Message.1:  ****** Request FAILED UNKnown ERROR', ' Contact GDS/Booker support.');
          print 'Statistic.1:100';

    }

} else {
            # Email to support
            #  Email to andre.reed@hyatt.com, anna.mui@hyatt.com, larry.rich@hyatt.com
     print join('', 'Message.1:********Request FAILED Invalid RESPONSE - ',$response->content, '   Contact GDS/Booker support.  ');
     print 'Statistic.1:100';
    
}


Viewing all articles
Browse latest Browse all 12281

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>