How to connect to the OBM/OMi embedded PostgreSQL via CLI - Linux

  • KM03718143
  • 28-Sep-2020
  • 12-May-2021


This explains how to connect to the embedded PostgreSQL OMI/OBM DB when running Linux and there is no graphical interface at hand.


When running Linux, how can we run DB queries in the PostgreSQL embedded DB?


On the DPS where the DB is running, execute
# /opt/HP/BSM/pgsql/bin/psql -p 5433 --username=postgres
To connect to an shema to alter the session, it would be 
# \c <schema/DB>
# \c postgres   
# \c event
# \c mgmt
Once connected you can execute your queries. 
Tip: As some queries can output a large text, you can save the output into a file and then check this text file, it keeps the syntax so it is very readable in a text editor. Note that you don't need to add the semicolon at the end of the query but instead the specified. The files will be saved into your working directory Examples:
SELECT * FROM table \g result.txt
SELECT * FROM all_events \g events.txt
To exit:
# /q
CDF notes:
For OBM containerized, get into the OMI pod, switch to the omi user and do the same.
Don't worry if you don't know how to get into the OMi pod, the command is this one, run it on the master and to exit just type the command exit when you are finished.
# kubectl exec -ti omi-0 bash -c omi -n  $(kubectl get ns | grep opsbridge | awk '{print $1}')