Tuesday, February 15, 2011

SAP: How to get a Google Chart onto a Windows SAP GUI screen

A way to get a google chart onto a windows SAPGUI screen

Google chart api allows you to download charts for offline use. Using GuiXT, cURL and dos commands a chart can be shown on a windows SAPGUI screen.

Example below for SAP transaction db02, showing freespace of the database, plus freespace of the actual disk dedicated to the database. *in this example the unix system is checked for freespace of the */sapdata* filesystems. (Obviously all the white space is my attempt at hiding the real data)





The way to get the charts is with GuiXT and cURL

Again as with previous attempts to get google and yahoo static maps onto SAPGUI screen links here and here, then all the following is setup in a similar way.

All the following is found in c:\guixt check out the other links for more of the same.

To note the code below is cut and pasted into blogger and most of it is on one line and I have left a gap between each  line.

1) The GuiXT control script is called RSORA060.e0110.txt and relates to the DB02 transaction on our systems.


Set  V[db]   “&V[_database]"

Pushbutton (toolbar) "&V[_database] update charts"  "/0"

if V[_database=SID]

image (4,83)  "C:\guixt\img\chart&F[TD110-TSFRP].gif"  -NoBuffer  -Transparent  -Plain  exe="c:\guixt\ch_copy.bat &F[TD110-TSFRP]"  start="c:\guixt\ch_copy.bat &F[TD110-TSFRP]"

image (13,83)  "C:\guixt\img\chart&V[_database].gif"  -NoBuffer -Transparent  -Plain   exe="c:\guixt\chdisk_copy.bat ""&V[_database]"""  start="c:\guixt\chdisk_copy.bat ""&V[_database]"""

endif

*Note in the code above SID needs to be changed to the system to be monitored. Each SID may have different scripts to check and create the charts.
To update the charts then the second chart is configured to use the GuiXT command start this enables the DOS BAT files to run. After the scripts complete then the pushbutton should be used to refresh the charts. The date is used in the chart to enable detection of out of date data :)

2) DOS script c:\guixt\ch_copy.bat generates the DB freespace google "GOM" chart. The dos bat file is below.

@ECHO OFF

@del "C:\guixt\img\chart%1.gif"

cd "C:\guixt"

@del ".\img\chart%1.gif"

.\curlbin\curl -s -xPROXY:PORT  http://chart.apis.google.com/chart? -d chs=225x125 -d cht=gom -d chd=t:%1 -d chl=%1 -d chco=FF0000,00FF00 -d chtt=DB+FreeSpace -d chof=gif    -G > .\img\chart%1.gif

exit

In the script above PUTTY command PLINK is used to connect to the unix system with ssh keys exchanged.

3) The second DOS script c:\guixt\ch_copy.bat generates the google chart for the free space in the unix system's sapdata filesystems


@ECHO OFF

cd "C:\guixt"

del ".\img\chart%1.gif"

rem %% required for batch % ok for command line

for /f %%A in ('plink -l USERID HOST "df -k|grep sapdata |awk '{n=n+$2}{s=s+$4} END{print s*100/n}'"') DO ( SET DISK=%%A )

echo %DISK%

.\curlbin\curl -s -xPROXY:PORT  http://chart.apis.google.com/chart? -d chs=225x125 -d cht=gom -d chd=t:%

DISK% -d chl=%DISK% -d chco=FF0000,00FF00 -d chtt=%DATE%+Disk+FreeSpace -d chof=gif  -G >.\img\chart%1.gif

exit
*Note in both of the DOS BAT files then the PROXY:PORT settings need to be adapted to the correct settings.

No comments:

Post a Comment

Google +