Skip to content

Instantly share code, notes, and snippets.

@RustyNails8
Forked from wuftymerguftyguff/hostAgentStuff.sh
Created April 14, 2023 18:52
Show Gist options
  • Save RustyNails8/8acb8b42872da4ad7448a128a19893f2 to your computer and use it in GitHub Desktop.
Save RustyNails8/8acb8b42872da4ad7448a128a19893f2 to your computer and use it in GitHub Desktop.
Useful SAP HostAgent commands
#GET A LIST OF INSTANCES
#/usr/sap/hostctrl/exe/saphostctrl -function Listinstances -format Script
#GET A LIST of databases
saphostctrl -nr 99 -function Listdatabases
# manage a db with the host agent
# /usr/sap/hostctrl/exe/saphostctrl -nr 99 -function StopDatabase -dbname NPL -dbtype ada -user sapadm passwd
#query a db with the host agent
# /usr/sap/hostctrl/exe/saphostctrl -nr 99 -function GetDatabaseStatus -dbname NPL -dbtype ada -user sapadm passwd
# /usr/sap/hostctrl/exe/saphostctrl -nr 99 -function GetDatabaseStatus -dbname NPL -dbtype ada -host nplhost
#work out if db is up
#/usr/sap/hostctrl/exe/saphostctrl -nr 98 -function GetDatabaseStatus -dbname NPL -dbtype ada -host nplhost -format script | awk '/Database Status: /{print $3}' | grep -q -i Running
#List Databases command
#/usr/sap/hostctrl/exe/saphostctrl -nr 99 -function ListDatabaseSystems -format Script | awk '/Database name: /{print $3,$5}' | sed 's/,//g
#List SAP Instances
#/usr/sap/hostctrl/exe/saphostctrl -nr 99 -function Listinstances -format Script | awk '/Inst Info : /{print $4,$6,$8}' | sed 's/,//g'
#List DB metrics
#/usr/sap/hostctrl/exe/saphostctrl -function ListDatabaseMetrics -dbname NPL -dbtype ada -format script
#Start entire hana system
user
Use rsecssfx file from latest kernel package SAPEXE.SAR to create securestore:
(as root)
export SAPSYSTEMNAME=<SID>
export RSEC_SSFS_DATAPATH=/usr/sap/hostctrl/exe/<SID>/security/rsecssfs/data
export RSEC_SSFS_KEYPATH=/usr/sap/hostctrl/exe/<SID>/security/rsecssfs/key
mkdir -p $RSEC_SSFS_KEYPATH $RSEC_SSFS_DATAPATH
/usr/sap/hostctrl/exe/rsecssfx put DB_CONNECT/SYB/SADB_USER sapsa -plain
/usr/sap/hostctrl/exe/rsecssfx put DB_CONNECT/SYB/SADB_PASSWORD <sapsa_password>
/usr/sap/hostctrl/exe/rsecssfx put DB_CONNECT/SYB/SSODB_USER sapsso -plain
/usr/sap/hostctrl/exe/rsecssfx put DB_CONNECT/SYB/SSODB_PASSWORD <sapsso_password>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment