Friday, October 15, 2010

ABAP Program for This perl displays a self-refreshing web page displaying the vital parameters of multiply SAP systems

#!/opt/perl5/bin/perl
#
# This perl script displays on a single, self-refreshing web page
# the most important parameters of multiply sap systems. By taking a
# look at this page, most of the problems can be noticed
# immediately. The displayed data:
# system status(up/down)
# user number per app. server
# session number per app. server
# average response time per app. server
# number of active locks
# number of update entries
# number of abap dumps (today)
# number of error messages in the system log (today)
#
# The web page gets refreshed once every three minutes.
# The perl script uses SAP's rfc2abap to submit
# the data collector abap (the source code: pr# 93b is in a
# unix text file) in the different systems. A cpic type user
# has to exist in those systems to run the abap.
# The script was used to monitor 14 SAP systems parallel.
#
print "Content-type:text/html\n\n";
use CGI;
print "";
print "";
#
# Print out the time of the last screen refresh
#
$datum = `date`;
@f = split /\s/, $datum;
print "@f[3] @f[1] @f[2] @f[5]


";
#
# Print a main header
#
print "print "cellspacing=\"0\"";
print "";
print "";
print "
";
print "SYSTEM DEPENDENT DATA
";
print "INSTANCE DEPENDENT DATA
";
#
# Print the column headings
#
@h=("SYSTEM","STATUS","SYSLOG ERRORS TODAY","ABAPDUMPS TODAY","LOCKS","UPDATE EN
TRIES","INSTANCE","USERS","SESSIONS","AVERAGE D. RESPONSE TIME");
print "print "";
for ($x = 0; $x < @h; $x++) {
print "";
}
print "";
#
# List of the systems to be monitored(SID, client, host, system number)
# This portion of the script has to be customized
#
@s = (
["DEV", "090", "host1", "00"],
["PRD", "100", "host2", "01"],
["QAS", "110", "host3", "02"],
["EDU", "120", "host4", "03"]
);
#
# Loop on the SAP systems
#
for $k ( @s ) {
#
# Check, that the sysytem is available
#
$stat = `./sapinfo -3 -h@$k[2] -s@$k[3] -g@$k[2] -xsapgw@$k[3] 2>/dev/null`;
if ($stat =~ /SAP/) {
#
# Get the data from the SAP system
# Customize the username and password
#
$data = `./rfc2abap -d@$k[0] -uusername -ppassword -c@$k[1] -h@$k[2] -s@$k[3]
-g@$k[2] -xsapgw@$k[3] -f zpoplog|grep -v Connected`;
}
else {
#
# When the system is down:
#
$data = "Q AAA - - - - - - - - &";
}
$sid = @$k[0];
@d = split /\s/, $data;
for ($x = 0; $x < @d; $x++) {
if (@d[$x] eq "Q") {
# Begin of table row
print "";
}
elsif (@d[$x] eq "@") {
# Empty cell
print "";
}
# End of table row
elsif (@d[$x] eq "&") {
print "";
}
else {
if ($x eq 2) {
# Set the status cell's color and text
if (@d[1] eq $sid){
$stat = "UP";
$color = "#00FF00";
}
else {
$stat = "DOWN";
$color = "#FF0000";
}
# Print the status cell
print "";
}
if ($x eq 1) {
$string = $sid;
}
else {
$string = @d[$x];
}
# Print a regular cell
print "";
}
}
}
print "
";
print "@h[$x]

";
print "$stat
";
print "$string
";

print "";

No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)

Userexits/BADIs

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

Blog Archive

goodsites