Skip to content

Instantly share code, notes, and snippets.

@wuftymerguftyguff
Last active August 20, 2024 00:34
Show Gist options
  • Save wuftymerguftyguff/c37747ae41cd3fd94b2752bf8fd58715 to your computer and use it in GitHub Desktop.
Save wuftymerguftyguff/c37747ae41cd3fd94b2752bf8fd58715 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>
store credentials for a maxdb database
/usr/sap/hostctrl/exe/saphostctrl -dbname DB1 -dbtype ada -function SetDatabaseProperty DBCredentials=SET -dboption User=SUPERDBA -dboption Password=secret
test that the stored credentials are being used
/usr/sap/hostctrl/exe/saphostctrl -dbname <database_name> -dbtype ada -function GetDatabaseStatus
/usr/sap/hostctrl/exe/saphostctrl -dbname DB1 -dbtype ada -function StopDatabase -service
/usr/sap/hostctrl/exe/saphostctrl -dbname DB1 -dbtype ada -function StartDatabase -service
@wuftymerguftyguff
Copy link
Author

an update

@GitGawnDawg
Copy link

Nice one dude
AJ

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