Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wuftymerguftyguff/2ac17fd60115f4bb0189dd4dce44ff7c to your computer and use it in GitHub Desktop.
Save wuftymerguftyguff/2ac17fd60115f4bb0189dd4dce44ff7c to your computer and use it in GitHub Desktop.
A Set of Bash Scripts to control SAP application instances from VCS
monitorapp.sh
#!/bin/bash
#CONSTANTS
OFFLINE=100
UNKNOWN=99
ONLINE=110
#Command Line Parameters
APPSERVER=$1
INSTNO=$2
SIDADM=$3
PASSWORD=$4
STATUS=$UNKNOWN
#Capture command output
SAPCONTROL=$(sapcontrol -nr $INSTNO -u $SIDADM $PASSWORD -host $APPSERVER -function GetProcessList)
#A count of not GREEN processes
NOTGREEN=$(echo $SAPCONTROL |grep -oP "\b[A-Z]{4,}\b" | grep -v GREEN| wc -l)
#A count of not GRAY processes
NOTGRAY=$(echo $SAPCONTROL |grep -oP "\b[A-Z]{4,}\b" | grep -v GRAY|wc -l)
if [ $NOTGREEN -eq 0 ]
then
STATUS=$ONLINE
fi
if [ $NOTGRAY -eq 0 ]
then
STATUS=$OFFLINE
fi
exit $STATUS
stopapp.sh
#!/bin/bash
APPSERVER=$1
INSTNO=$2
SIDADM=$3
PASSWORD=$4
sapcontrol -host $APPSERVER -nr $INSTNO -user $SIDADM $PASSWORD -function Stop
exit 0
startapp.sh
#!/bin/bash
APPSERVER=$1
INSTNO=$2
SIDADM=$3
PASSWORD=$4
sapcontrol -host $APPSERVER -nr $INSTNO -user $SIDADM $PASSWORD -function Start
exit 0
@lucathekid
Copy link

Hi Jeff I have a question about your script. are you still active on diem profiles?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment