Query the metadata tables. You can use SASHELP.VLIBNAM view. Or with SQL you can reference it directly as DICTIONARY.LIBNAMES.
Here is a link to macro that will return the Engine type, Hostname and schema/database name from that table.
https://github.com/sasutils/macros/blob/master/dblibchk.sas
... View more