divya.mahajan

5 Posts

Introduction 

 

This blog is part of a series on Monitoring XI/PI queues on your iPhone -- Part 1 . In Part 1 of this series, I described the goal of the project. In Part 2, I setup the Perl script to automatically download queue data from SAP every 5 minutes. In Part 3, I created the HTML page with the jQuery chart. In this part, I discuss how to put this up as a website on your PC with Tomcat. Then, I create the iPhone webapplication with iWebKit.

 

You can download the full environment from *PI-monitor project at sourceforge*. Read the Quick Start section in Monitoring XI/PI queues on your iPhone -- Part 1 to setup the environment.

 

*View a live demo*.

h4. Hosting your own website with Tomcat

Apache Tomcat provides a robust and free web server. Since it can be installed by simply unzipping a file, it can be installed without special Administrator privileges. The steps here outline how to get Tomcat started on your PC. these instructions were written for Tomcat 6.0.26 on Windows 32bit.

    Download Tomcat from the Apache site. Choose *Binary Distributions / Core / 32-bit windows zip*.
      1. Extract it to c:apache-tomcat-6.0.26
      2. Modify c:apache-tomcat-6.0.26confserver.xml. Change 8080 to port 10080.
      3. Go to c:apache-tomcat-6.0.26 in and run *startup.bat*. If it doesn't start, check if JAVA_HOME or JRE_HOME is set correctly to a Java 1.6 version.
      4. If it doesn't start because the port 10080 (default Tomcat port) is already used, edit server.xml and select another ununsed port number.

    At this point you have a functioning web server. Now I will copy over the PI-Monitor web files.

    1. Xcopy c:strawberrypi_monitorweb c:apache-tomcat-6.0.26webappsROOTweb

    Next I must modify the download.cmd batch script. I tell the QueueUpload.pl script the location to store the jQuery chart javascript files.

    @echo off
    setlocal
    set PATH=c:strawberryperl in;c:strawberryc in;c: wrfcsdklib;%PATH%
    set TERM=dumb
    date /T >>log.txt
    perl QueueDownload.pl PXP 2>>log.txt
    perl QueueDownload.pl PP4 2>>log.txt
    Rem Set your Amazon S3 account details here.
    Rem If you don't have an Amazon S3 account, delete the next three lines.
    rem set AWS_ACCESS=my_amazon_access_key
    rem set AWS_SECRET=my_amazon_s3_secret_key
    rem set AWS_BUCKET=my_amazon_bucket
    Rem If you need a proxy to connect to the Internet, set it here.
    rem set  HTTP_PROXY=http://user:password@proxyhost:proxyport
    rem set HTTPS_PROXY=http://user:password@proxyhost:proxyport
    *perl QueueUpload.pl PXP QueueMonitoring.sqdb c:/apache-tomcat-6.0.26/webapps/ROOT/web/charts 2>>log.txt
    perl QueueUpload.pl PP4 QueueMonitoring.sqdb c:/apache-tomcat-6.0.26/webapps/ROOT/web/charts2>>log.txt
    *endlocal
    h4. Viewing the website

     

    Run the download.cmd batch file to generate the jQuery script files in Tomcat. If all went well, open http://localhost:10080/web/monitor.html   to view the queue graphs.

    h4. iPhone web application

     

    The iPhone browser is based on the popular WebKit engine. However Apple has modified / extended this to provide iPhone app like user interfaces. So if you code your web page with the correct meta tags and stylesheets - the iPhone will display the page as a iPhone application. Luckily, most of the hard work of figuring this out has been doen and is available in iWebKit . Installing the kit is as simple as downloading it and unzipping it into c:apache-tomcat-6.0.26webappsROOTiwebkit. You can then browse the iWebkit demo application. However the PI_Monitor web subdirecrtory already has the iWebkit files. So the only part left is two create the web application pages.-- index.html -</p><div style="overflow-y: hidden; font-size: 12px; background: url('http://www.sohtanaka.com/web-design/examples/pre-tags/pre_code_bg_ylw.gif') repeat-y left top; margin: 0px; overflow: auto; border-left: #ccc 1px solid; width: 600px; line-height: 20px; border-bottom: #ccc 1px solid; padding: 0px"><div style="padding-right: 0px; padding-left: 30px; padding-bottom: 0px"><pre><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br /><html xmlns="[http://www.w3.org/1999/xhtml | http://www.w3.org/1999/xhtml]"></pre><pre><head><br /><title>OneEAI dashboard</title><br /><meta content="yes" name="apple-mobile-web-app-capable" /><br /><meta content="index,follow" name="robots" /><br /><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><br /><link href="pics/appicon.png" rel="apple-touch-icon" /><br /><meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" /><br /><link href="css/style.css" rel="stylesheet" media="screen" type="text/css" /><br /><script src="javascript/functions.js" type="text/javascript"></script><br /><link href="pics/startup.png" rel="apple-touch-startup-image" /><br /><meta content="OneEAI,status,iTouch,Website" name="keywords" /><br /><meta content="View OneEAI status!" name="description" /><br /></head></pre><pre><body></pre><pre><div id="topbar"><br /> <div id="title">OneEAI status</div><br /><! 

      [http://iwebkit.net | http://iwebkit.net]" class="noeffect">PC Site

    ><br /></div><br /><div id="tributton"><br /> <div class="links"><br />  [PXP | pxp.html]<a href="pp4.html">PP4</a>[EPA | epa.html]<br /> </div><br /></div><br /><div id="content"><br /> <ul class="pageitem"><br />  <li class="textbox"><br />  <span class="header">System Queue Overview</span><p><br />  Queue volumes in monitored XI systems.</p><br />  </li><br />  <li class="menu"><br />   
       !thumbs/plugin.png|alt=PXP|src=thumbs/plugin.png!
       PXP
       

       
       
    <br />  </li><br />  <li class="menu"><br />   
       !thumbs/other.png|alt=PP4|src=thumbs/other.png!
       PP4
       

       
       
    <br />  </li><br />  <li class="menu"><br />   
       !thumbs/accessibility.png|alt=EPA|src=thumbs/accessibility.png!
       EPA  Not available
       

       
       
    <br />  </li><br /> </ul><br /></div><br /><div id="footer"><br /> [Written by Divya Mahajan | #]</div></pre><pre></body></pre><pre></html><br /> </pre></div></div><p>Once I have my iPhone menu page, I create the individual system pages (pxp.html, pp4.html and epa.html). Here is what one looks like. It is very similar to the monitor.html that was created in Part 3.</p><div style="overflow-y: hidden; font-size: 12px; background: url('http://www.sohtanaka.com/web-design/examples/pre-tags/pre_code_bg_ylw.gif') repeat-y left top; margin: 0px; overflow: auto; border-left: #ccc 1px solid; width: 600px; line-height: 20px; border-bottom: #ccc 1px solid; padding: 0px"><div style="padding-right: 0px; padding-left: 30px; padding-bottom: 0px"><pre><p><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"></p><p><html xmlns="http://www.w3.org/1999/xhtml"></p><p><head></p><p><meta http-equiv="refresh" content="250" /> </p><p><meta content="yes" name="apple-mobile-web-app-capable" /></p><p><meta content="index,follow" name="robots" /></p><p><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /></p><p><link href="pics/appicon.png" rel="apple-touch-icon" /></p><p><meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" /></p><p><link href="css/style.css" rel="stylesheet" media="screen" type="text/css" /></p><p><script src="javascript/functions.js" type="text/javascript"></script></p><p><title>OneEAI - PXP queues</title></p><p><meta content="PXP,Queues" name="Keywords" /></p><p><meta content="Queue information" name="description" /></p><p><!
    jQuery stuff ></p><p><style type="text/css"> </p><p>#content { background-color : black; }</p><p>#basicGChart_PXP </p><p></style></p><p><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script></p><p><script type="text/javascript" src="js/jquery.gchart.min.js"></script></p><p><script type="text/javascript" src="charts/pxp-queue.js"></script></p><p><! jQuery stuff -->

     

     



     



     



     

    !images/home.png|alt=home|src=images/home.png!

     



    [PP4 | pp4.html]



     

     

    PXP Queues


     

     



     



     



     



     



     



     

    h4. Create the iPhone application icon.
    Open http://localhost:10080/web/iphone.html in your iPhone Safari browser to view the iPhone enabled rendering of the webpage.
    Select the + (plus) icon at the bottom of the screen.
    Click the "Add to Home Screen" button.
    Enter a short name for the app e.g. PI Monitor.

       

      Now you have an icon on your iPhone home screen. Clicking this icon brings up the iPhone enhanced web application. For screenshots, visit  Monitoring XI/PI queues on your iPhone -- Part 1.

      h4. Conclusion 

      Its has been a long blog series to get here. By combining various free technology components, an iPhone web application was created as a mashup. The ideas here can be extended to many other uses. I'm interested in how you will adapt them to your own uses.

      Note: Later, I may add a short section using Amazon S3 rather than Tomcat in a later blog. Let me know if you are interested.

       

      You can download the full perl environment, perl script and download.cmd from *PI-monitor project at sourceforge*. Read the Quick Start section in Monitoring XI/PI queues on your iPhone -- Part 1 to setup the environment.</p>
      h4. Introduction    This blog is part of a series on Monitoring XI/PI queues on your iPhone  (Monitoring XI/PI queues on your iPhone -- Part 1) . In Part 1 of this series, I described the goal of the project. In Part 2, I setup the Perl script to automatically download queue data from SAP every 5 minutes. In this part, I discuss how to analyze this data and create a bar chart for a iPhone WebApp.   You can download the full environment from {code:html}*PI-monitor project at sourceforge*{code}. Read the Quick Start section in Part 1  (Monitoring XI/PI queues on your iPhone -- Part 1) to setup the environment.   {code:html}*View a live demo*{code}.  h4. The constraints and their consequence on design * The charting / graphing must be Javascript (to run on the iPhone). These constraints led to my design of a seperate Perl script to analyze the queue data and publish the charts as a JQuery javascript which is uploaded to the website. The web application is simply a set of static HTML / javascript files. To generate the bar charts, I decided to use Google Charts as it was adequate for the task.  So in this blog, you combine the following technologies to get a iPhone Webapp. For screenshots, look at Part 1  (Monitoring XI/PI queues on your iPhone -- Part 1).  1. Perl and SQLite to analyze data. 2.  [JQuery | http://jquery.com/] and Google Charts  (http://code.google.com/apis/charttools/) to create bar charts.0.1. [iWebKit | http://iwebkit.net/] - an open source kit for iPhone web applications. 0.2. h4. Analyzing the stored Queue Data   SAP PI/XI relies on queues in the ABAP stack to get messages processed. The blog {code:html}XI Asynchronous Message Processing: Understanding XI Queues -Part I{code} provides a good explanation of how PI uses queues. For my application,I want to see a stacked bar chart of all messages in the PI message queues (SMQ2). There should be a different color for each queue status.  Lets examine the SQLite Queue database. 1. Download SQLite (if you haven't already). 2. Open your database from the command line *sqlite3.exe c:strawberrypi_monitorQueueMonitoring.sqdb*  3. To leave SQLITE, type *.exit* at the command line. 4. Type in the SQL query on the QueueData table in the QueueMonitoring.sqdb. (if you are copying to clipboard, edit this in notepad before trying it in SQLite3). select SnapshotTime,System,Count(QNAME) as Queues,Sum(QDeep) as Total, SUM(CASE WHEN QSTATE="SYSFAIL " THEN QDEEP ELSE 0 END) AS Sysfail , SUM(CASE WHEN QSTATE="RETRY " THEN QDEEP ELSE 0 END) AS Retry , SUM(CASE WHEN QSTATE="RUNNING " THEN QDEEP ELSE 0 END) AS Running , SUM(CASE WHEN QSTATE="READY " THEN QDEEP ELSE 0 END) AS Ready from QueueData group by SnapshotTime,System,QueueDirection having QueueDirection="IN" AND SnapshotTime>datetime('now','-1 days') AND system='PXP' order by snapshottime Desc, system   This summarizes the queue data for the last 24 hours into Snapshot time |SID|queues|messages|sysfailmessages|retrymessages|runningmessages|readymessages 2010-05-08 19:24:00|PXP|2|111|110|0|1|0 2010-05-08 19:19:01|PXP|1|99|99|0|0|0 2010-05-08 19:14:01|PXP|1|91|91|0|0|0 2010-05-08 19:09:01|PXP|1|81|81|0|0|0 2010-05-08 19:04:01|PXP|1|71|71|0|0|0 2010-05-08 18:59:01|PXP|2|62|61|0|1|0 2010-05-08 18:54:01|PXP|1|52|52|0|0|0 2010-05-08 18:49:01|PXP|1|42|42|0|0|0  h3. Graphing the data with Google Charts Now lets take the above data and convert it into a stacked bar chart. I chose a Javascript library (Google Charts) to do this at the client's browser. That way, no server side logic is needed (see constraints).  Google Charts provides a good API - however it is difficult to create the correct string by reading the documentation. So I suggest youu spend some time at their website. There are two flavors of {code:html}Google Charts -- Image Charts and Interactive Charts{code}. For now, I am happy with using the Image Charts API to create a static image. Even the Image Chart API has a rich selection of charts that can be seen in their chart gallery  (http://code.google.com/apis/chart/docs/gallery/chart_gall.html). To get a good feeling of their API, I spent a lot of time in the Live Chart Playground  (http://code.google.com/apis/chart/docs/chart_playground.html), which is a lot more convenient than creating the URLs by hand.  The LiveChart parameters for a stacked bar chart are cht=bvs chs=320 chco=4D89F9,C6D9FD chd=t:10,50,60,80,40     50,60,100,40,20 chds=0,160 *This results in the following Image Chart URL* [http://chart.apis.google.com/chart?cht=bvs&chs=320&chco=4D89F9,C6D9FD&chd=t:10,50,60,80,40|50,60,100,40,20&chds=0,160 | http://chart.apis.google.com/chart?cht=bvs&chs=320&chco=4D89F9,C6D9FD&chd=t:10,50,60,80,40|50,60,100,40,20&chds=0,160]  !http://chart.apis.google.com/chart?cht=bvs&chs=320&chco=4D89F9,C6D9FD&chd=t:10,50,60,80,40|50,60,100,40,20&chds=0,160|height=100|alt=|width=100|src=http://chart.apis.google.com/chart?cht=bvs&chs=320&chco=4D89F9,C6D9FD&chd=t:10,50,60,80,40|50,60,100,40,20&chds=0,160|border=1!  I quickly found that constructing the URL for my data would look very ugly. So I needed something more. h3. JQuery to the rescue  JQuery is a brilliant Javascript library that simplifies scripting for webpages. If you haven't come across JQuery, recommend you take a look at the JQuery web site  (http://www.google.com/search?q=JQuery). JQuery is highly extensible and has a large set of JQuery extensions.  I found a JQuery plug in for Google Charts  (http://plugins.jquery.com/project/jgcharts). With this jQuery, it becomes very easy to create a graph. I can concentrate on what I want - rather than the URL syntax. Here is the final jQuery that I used for the chart.  $(function () { $('#*basicGChart_PP4'*).gchart({type: 'barVert', maxValue: 672.0, title: 'PP4 2010-05-08 16:42:31', titleColor: 'white', titleSize: 14, barWidth: 12, backgroundColor: 'black', legend: 'right', axes: [ $.gchart.axis('left', 0, 672.0, 'white', 'right')],  dataLabels:  (':47',':57',':36',':58',':06',':31',':55',':49',':54',':42'),   series: [  $.gchart.series('Sysfail',  ( 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 ), 'FF8000'),   $.gchart.series('Retry',  ( 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 ), 'F7BE81'),   $.gchart.series('Ready',  ( 350.0,2.0,121.0,20.0,1.0,0.0,0.0,1.0,1.0,0.0 ), '58ACFA'),   $.gchart.series('Running',  ( 322.0,1.0,41.0,35.0,1.0,1.0,2.0,1.0,1.0,1.0 ), '088A08'),   $.gchart.series('Other',  ( 350,2,121,20,1,0,0,1,1,0 ), 'FFFFFF')  ]}); });  The resulting bar chart is show below. The "basicGChart_PP4" is the link from jQuery to HTML. It tells JQuery which DIV to modify in the HTML page.Bar Chart of the data

      Introduction 

      This blog is part of a series on Monitoring XI/PI queues on your iPhone . In Part 1 of this series, I described the goal of the project. In this part, I discuss how to use RFC functions to get queue information. You can download the full perl environment, perl script and download.cmd from PI-monitor project at sourceforge. Read the Quick Start section in Part 1 to setup the environment.

      About Queues and SAP PI

      SAP PI/XI relies on queues in the ABAP stack to get messages processed. The blog XI Asynchronous Message Processing: Understanding XI Queues -Part I provides a good explanation of how PI uses queues. SAP provides RFC functions that provide information about queues in the ABAP stack. These are TRFC_QOUT_OVERVIEW, TRFC_QIN_OVERVIEW and TRFC_QINS_OVERVIEW. PI uses QIN (all message queues) and QINS (messages in parked queues). QOUT is used extensively by BW extractors.

      Program structure

      The Perl program has the following structure

      1. Connect to SAP.
      2. Connect to backend database where we save the results of the RFC call.
      3. Call the SAP RFC function.
      4. Save the results to the database.

      Connect to SAP

      The Perl module sapnwrfc expects all SAP connection information to be stored in an external configuration file (*.yml). The default configuration file is SAP.yml, however you can pass your own filename as a parameter. In the code snippet below, I use the first command line argument as the SAPSID. The code expects SAPSID.yml file to have the configuration.

      --- Perl code ---

      use sapnwrfc;
           use strict;      my $sapsid=@ARGV[0];
           my $sapconfig;
           if (defined($sapsid))
           {
                $sapconfig=$sapsid . ".yml";
           } else {
                $sapconfig="MTP.yml";
                $sapsid="MTP";
           }
           SAPNW::Rfc->load_config($sapconfig);

      --- MTP.YML file --

           ashost: PIServerHost

           sysnr: "10"

           client: "100"

           user: UserID

           passwd: Password

           lcheck: 1

           lang: EN

           trace: 0

           debug: 0

      If you have a gateway router, use "/H/router/H/pihost" for the ashost parameter. Alternatively you can also use a load balanced configuration and connect to mshost.

      Connect to backend database

      Once I get the data from SAP, I would like to save it in a database for analysis at a later time. Fortunately, Strawberry Perl includes SQLite - which is a fast RDBMS supporting SQL. You could also use Microsoft SQL Server or Microsoft Access, but you will need to modify the DSN. I use the builtin DBI module to access the database. This hides the details of the backend from me (which simplifies switching from one database to another).

            my $dbfile = 'QueueMonitoring.sqdb'; 
            my $dsn = "dbi:SQLite:$fbfile";
            my $dbh = DBI->connect($dsn,undef,undef, {RaiseError=>1, AutoCommit=>1});
             # The following creates the table in SQLite if it isn't there.
             # If you are using Microsoft Access, you'll need to do it manually
             # Check and create the database table if it doesn't exist
                my @tablelist = $dbh->tables('%','%','QueueData','TABLE');
                if ($#tablelist<0) {

                     $dbh->do("CREATE TABLE QueueData (ID, System, SnapshotTime, " .
                     " QueueDirection," .
                     " MANDT INTEGER, QNAME, DEST, QDEEP INTEGER, QSTATE, WQNAME, FDateTime, FDATE, " .
                     " FTIME, LDateTime, LDATE, LTIME, FQCOUNT, LQCOUNT, ERRMESS, " .
                     " QLUWCNT, BATCHPLA, FIRSTTID); ");
                }
             my $sth = $dbh->prepare("INSERT INTO QueueData (MANDT,QNAME,DEST,QDEEP,
               QSTATE,WQNAME,FDATE,FTIME,LDATE,LTIME,
               FQCOUNT,LQCOUNT,ERRMESS,QLUWCNT,BATCHPLA,
               FIRSTTID,QueueDirection,SnapshotTime,
               FDateTime,LDateTime,System)
               values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ");
           #If you are using Microsoft Access, replace the first two lines with
           my $dbfile = 'QueueMonitoring.accdb';
           my $dsn = 'dbi:ODBC:driver=Microsoft Access Driver (*.mdb, *.accdb);dbq='
                           . $dbfile; 
       

      Call the SAP RFC function

      This is the easiest part of the program, thanks to the magic of the SAPNWRFC Perl module.

      # Inbound queues
        $rd = $conn->function_lookup("TRFC_QIN_OVERVIEW");
        $rc = $rd->create_function_call;
        $rc->invoke;

      The returned data can be access through $rc. That is shown in the next section.

      Save the results to the database

      Finally, after calling SAP, I need to save the data. These functions return a table with a single row for each queue. I would highly recommend looking at the data. It has a lot of good information (e.g. which appserver is processing the queue, what is the timestamp of the message being processed, etc.)

      # call a subroutine to save the RFC data.
        saveQueueData($rc,$sth,'IN',$snapshottime,$sapsid);
      # The actual subroutine is defined below
      sub saveQueueData($$$$$)
      {
        my ($rc,$sth,$direction,$snapshottime,$system) = @_;
        foreach my $row (@{$rc->QVIEW}) {
           #warn Dumper($row); #uncomment this if you want to see the RFC data
           #print STDERR $row->{LINE}."\n";
           $sth->execute($row->{MANDT}, $row->{QNAME}, $row->{DEST}, $row->{QDEEP},
                         $row->{QSTATE}, $row->{WQNAME}, $row->{FDATE}, $row->{FTIME},
                         $row->{LDATE}, $row->{LTIME}, $row->{FQCOUNT}, $row->{LQCOUNT},
                         $row->{ERRMESS}, $row->{QLUWCNT}, $row->{BATCHPLA}, $row->{FIRSTTID},
                         $direction, $snapshottime,
                         getsapdate($row->{FDATE},$row->{FTIME}),
                         getsapdate($row->{LDATE},$row->{LTIME}),$system
                         );
        }
      }

      $rc->QVIEW is the returned table. ${$rc->QVIEW}[0] returns the first row. Once you have a row of the table, access individual structure members as $row->QSTATE. For this application, the fields that are interesting are QSTATE (queue status) and QDEEP.

      A note about PI timestamp fields - these are double numbers with 7 digits after the decimal point. The format is YYYYMMDDHHMMSS.sssssss . This format must be converted to an ISO date. The getsapdate function does this conversion. $snapshottime is a timestamp to indicate when the data was queried from SAP.

      The last line $sth->execute will run the INSERT statement prepared earlier.

      While debugging, you can use warn Dumper($row) to display each row.

      Finishing the script

      The above steps showed the basic steps needed to call an RFC function and save the results to a database. To complete the script, I've added more error checking and sending messages to the Windows Eventlog. The full script is available at the PI-Monitor project on Sourceforge.

      Scheduling it to run every 5 minutes (on Windows)

      Once you have this script running, run it periodically (e.g. every 5 minutes) to start collecting data in your database. First, some assumptions made

      1. Perl was installed to C:\strawberry
      2. The QueueDownload.pl script is at c:\strawberry\pi_monitor
      3. You have created your *.yml files.

      First, a small wrapper shell script to setup the correct Perl environment and running the QueueDownload.pl script. This one queries two SAP systems (PXP and PP4 which are SAP PI systems).

      --- download.cmd ---

      @echo off
      set PATH=c:\strawberry\perl\bin;c:\strawberry\c\bin;c:\nwrfcsdk\lib;%PATH%
      set TERM=dumb
      date /T >>log.txt
      perl QueueDownload.pl PXP 2>>log.txt
      perl QueueDownload.pl PP4 2>>log.txt

      Verify that the script is running. Next, schedule a repeating task to run automatically every 5 minutes. Use the schtasks command line on Windows XP and higher.

       schtasks /create /sc minute /mo 5 /tn "Download SAP Queues" /tr c:\strawberry\pi_monitor\download.cmd

      Conclusion and next steps

      With this, you have completed the first part of collecting queue data from your SAP PI system. The next part will show how the data can be analyzed and shown in a graph.

      You can download the full perl environment, perl script and download.cmd from PI-monitor project at sourceforge. Read the Quick Start section in Part 1 to setup the environment.

      A quick way to check the health of your SAP PI system is to see the status of its queues. If messages get stuck in queues, you either have a slow system or an error situation. Queues can be monitored in SAP with the SMQ2 transaction.

      The problem with this approach is that it requires you to logon to SAP and execute SMQ2 transaction. SMQ2 doesn't neatly summarize the status for a quick glance. I wanted a simpler graph that shows me this information, and I wanted this to be accessible from my iPhone. This article series describes the steps I took to create it.

      h3. Overview 

      Part 1 - Introduction to the iPhone monitor (this blog)
      [Part 2 | Monitoring XI/PI queues on your iPhone -- Part 2 - Retrieving Queue Information from SAP PI with Perl] - Retrieving Queue information from SAP PI with Perl.

      [Part 3 | Monitoring XI/PI queues on your iPhone -- Part 3 - Create charts] - Creating a web page with a bar chart using Google Charts.(*view a demo*)
      [Part 4 | Monitoring XI/PI queues on your iPhone -- Part 4 - iPhone webapp] - Package the website as an ITouch application

      h3. Screenshots

       

      It always helps to see what the end result would be like. So here are some screenshots from the iPhone and *view a demo* of the website.

       !http://farm5.static.flickr.com/4023/4584782826_725c1a5850_o.jpg|height=480|alt=iPhone Menu|align=top|width=320|src=http://farm5.static.flickr.com/4023/4584782826_725c1a5850_o.jpg|border=1! !http://farm5.static.flickr.com/4034/4584155039_d0c9e37b02_o.jpg|height=480|alt=Queue graph|align=top|width=320|src=http://farm5.static.flickr.com/4034/4584155039_d0c9e37b02_o.jpg|border=0!

       

      h4. Tools
      • SQLite command line shell.
      • iWebKit to package the website as an iPhone application.
      • Apache Tomcat or IIS to test your website locally.
      • Amazon S3 to host the website. (You could use something else).
      h4. Preparing your environment

       

      We need a working Perl environment with all the modules. The instructions for this setup is in a seperate blog - Using Perl for SAP RFC - Part 1 - Installing PerlAlternatively see the next section on a QuickStart.

       

      You can download the SQLite command line shell to examine the SQLite database .

       

      To install Apache Tomcat, you'll need Java 1.5 or higher . Download Tomcat from the Apache site. If you are not permitted to install software, download the ZIP file and unzip it to c:     omcat. The blog assumes you have tomcat installed in c:     omcat.</p>h4. Quick Start
      The entire Perl environment, perl scripts etc. can be downloaded from the PI_monitor project on Sourceforge.
      1. Download the *perl_with_sapnwrfc.zip *file and extract it to C:strawberry.
      Download the pi_monitor.zip file and extract to c:strawberrypi_monitor
      Copy c:strawberrypi_monitorMTP.yml to your Edit c:strawberrypi_monitordownload.cmd. Change PXP/PP4 to your server schtasks /create /sc minute /mo 5 /tn "Download SAP Queues" /tr c:strawberrypi_monitordownload.cmd

         

        This will start collecting data to c:strawberrypi_monitorQueueMonitoring.sqdb (SQLite database). The next steps are needed to adjust the HTML pages to show data of your <sapsids> instead of PXP,EPA and PP4.</p><ol><li>(webpage changes) -Modify c:strawberrypi_monitorwebmonitor.html. Replace EPA/PP4/PXP with the <sapsid> of your servers.</li><li>(iphone webapp changes)* Modify c:strawberrypi_monitorwebindex.html. Replace EPA/PP4/PXP with the The next part (Monitoring XI/PI queues on your iPhone -- Part 2 - Retrieving Queue Information from SAP PI with Perl) discusses how to collect queue data from SAP using Perl and RFC functions.

         

         

         

         

        Perl is a good scripting tools because of its availability across platforms and its vast CPAN library of modules. I wanted a program to query SAP using RFC calls. Microsoft Net requires the WCF LOB Adapter for SAP - which I did not have. So next choice was to look up the Sap::Rfc module for Perl. I was pleasantly surprised to see the NetWeaver RFC gives the Next generation Ruby and Perl Connectors that replaces SAP::Rfc. This new module uses the latest RFC Netweaver SDK and is much easier to use than its predecessor.

        However compiling the module on Strawberry Perl was not easy. So I decided to document my experience in this blog.

         

        *If you want to skip these steps, you can download my Perl compilation from the **PI-Monitor site at sourceforge.*

        h3. Installing Perl

         

        [Download and install Strawberry Perl | http://strawberryperl.com/releases.html] to C:strawberry. I prefer to use the portable zip file since you can just unzip it to C:strawberry without any side-effects.

        h3. Installing the Netweaver RFC SDK

         

        Download the SAP NW RFC SDK. OSS Notes: 1025361  and 1056696 .

        First:   http://service.sap.com/swdc
        Then:   Download -> Support Packages and Patches -> Entry by Application Group ->
        Finally:  On the page "Support Package and Patches", choose "Additional Components" -> SAP NW RFC SDK" -> SAP NW RFC SDK 7.10.
          1. Select your operating system and download the SAR file. (In my case it was NWRFC_2-20002217.SAR).
          2. You need SAPCAR to uncompress this file. To get SAPCAR (Download->Support Packages and Patches -> Entry by Application Group. Then choose "Additional Components" -> SAPCAR -> SAPCAR 7.10)
          3. At the command line, uncompress the SAR file
        SAPCAR_3-20002090.exe -xvf NWRFC_2-20002217.SARRead notes on compiling NWRFC for Perl

        Perl needs a connection to CPAN network to install the modules.  Before you can install modules, you need to setup your proxy settings. If you don't need a proxy, ignore the first HTTP_PROXY command.

        set HTTP_PROXY=http://proxyuser:proxypass@proxyhost:proxyport<br />set PATH=C: wrfcsdklib;C:strawberryc in;C:strawberryperl in;%path%<br />cpan<br />cpan>  install sapnwrfc<br />No libsapnwrfc installation found, usually in C:/Program Files/SAP/FrontEnd/SAPg
        ui/nwrfcsdk
        Which libsapnwrfc build path do you want to link against?*  C:/nwrfcsdk</li><li><br />If you get an error "undefined reference to 'RFC...." - you'll need to manually modify the Makefile.<br />c:strawberryCPAN uildsapnwrfc-libSAPNWMakefile<br />Find the lines
        LDLOADLIBS = and prefix c: wrfcsdklibsapnwrfc.lib c: wrfcsdkliblibsapucum.lib <br />From the command line prompt
        cd c:strawberryCPAN uildsapnwrfc-
        dmake
        dmake install*
          h3. Optionally
          • Optionally cpan install Net::Amazon::S3  -- if you want to upload files to Amazon S3.

           

          Filter Blog

          By date: