BookmarkSubscribeRSS Feed

How to get the list of LASR servers?

Started ‎09-13-2019 by
Modified ‎09-13-2019 by
Views 4,236

Question

How to get the list of LASR servers?

Answer

I often get a question, how to get the list of the existing LASR servers? Well, there are multiple ways to do that.

 

1. If you are in the Linux console, you can do something like this:

export ports_start=$(cat /proc/sys/net/ipv4/ip_local_port_range | awk '{print $1}')
export ports_end=$(cat /proc/sys/net/ipv4/ip_local_port_range | awk '{print $2}')

for i in $( lsof -i | grep -E 'tkmpi.*LISTEN' | awk '{print $9}' | cut -d':' -f2 ); do
  if [[ $i =~ ^[0-9]+$ ]]; then
    if ((($i < $ports_start)) || (($i > $ports_end))); then
      echo $i
    fi
  fi   
done

You will get a simple list with ports associated with the LASR servers that have been started. Please note that you have to start this script with root privileges in order to get LASR ports from all possible users.

 

Another way is to use tkgridmon utility:

 

export GRIDHOST="LASR_HEAD_NODE_FQDN"
export GRIDINSTALLLOC=/PATH_TO/TKGrid/
export TKPATH=/PATH_TO/TKGrid/lib:/PATH_TO/TKGrid/bin
export GRIDRSHCOMMAND=/PATH_TO/TKGrid/bin/ssh.sh
/PATH_TO/TKGrid/bin/tkgridmon -lasrshow

Depends on the TKGrid version, you will get either the list of the LASR servers or you will be entered to the TKGrid Monitor interface.

 

 

tkgridmon_list.png

 

 

tkgrid_monitor.png

 

2. You can use a SAS program shown below to get a list metadata libraries associated with your LASR servers. Please note that multiple libraries might be associated with a single LASR server.

 

data meta_libraries;
	length uri serveruri conn_uri lib_uri prop_uri domainuri src_uri libname 
		ServerContext AuthDomain port tag hpath opt sqldatasrc orapath host 
		install_loc LASR_Name $256 desc $200 libref engine $8 isDBMS $1;
	keep libname desc libref engine ServerContext AuthDomain port tag hpath opt 
		sqldatasrc orapath host install_loc LASR_Name;
	nobj=.;
	n=1;
	uri='';
	serveruri='';
	conn_uri='';
	lib_uri='';
	prop_uri='';
	domainuri='';
	src_uri='';

	nobj=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'", n, uri);

	if n>0 then
		do n=1 to nobj;
			libname='';
			ServerContext='';
			AuthDomain='';
			desc='';
			libref='';
			engine='';
			LASR_Name='';
			isDBMS='';
			port='';
			tag='';
			hpath='';
			opt='';
			sqldatasrc='';
			orapath='';
			host='';
			install_loc='';
			nobj=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'", n, uri);
			rc=metadata_getattr(uri, "Name", libname);
			rc=metadata_getattr(uri, "Desc", desc);
			rc=metadata_getattr(uri, "Libref", libref);
			rc=metadata_getattr(uri, "Engine", engine);
			rc=metadata_getattr(uri, "IsDBMSLibname", isDBMS);
			rc=metadata_getprop(uri, "Library.LASR.Property.Tag.Name.xmlKey.txt", tag);
			rc=metadata_getprop(uri, "Library.SASHadoop.PAth.Name.xmlKey.txt", hpath);
			rc=metadata_getprop(uri, 
				"Library.SAS.Property.OptionString.Name.xmlKey.txt", opt);

			i=1;
			rc=metadata_getnasn(uri, "DeployedComponents", i, serveruri);

			if rc > 0 then
				rc2=metadata_getattr(serveruri, "Name", ServerContext);
			else
				ServerContext='';

			/* Get LibraryConnection and information within */
			i=1;
			rcc=metadata_getnasn(uri, "LibraryConnection", i, conn_uri);
			j=1;

			if engine="SASIOLA" then
				do;

					if rcc > 0 then
						rc2=metadata_getattr(conn_uri, "Port", port);
					else
						port='';
					rc=metadata_getprop(conn_uri, 
						"Connection.LASR.Property.Server.NAme.xmlKey.txt", host);
					rc3=metadata_getnasn(conn_uri, "Source", j, src_uri);

					if rc3 > 0 then
						rc4=metadata_getattr(src_uri, "Name", LASR_Name);
					else
						LASR_Name='';
				end;

			if engine="SASHDAT" then
				do;
					rc=metadata_getprop(conn_uri, 
						"Connection.Hadoop.NameNode.Property.Server.Name.xmlKey.txt", host);
					rc=metadata_getprop(conn_uri, 
						"Connection.Hadoop.Property.InstallLocation.Name.xmlKey.txt", 
						install_loc);
				end;

			if isDBMS="1" then
				do;

					if rcc > 0 then
						do;
							rc2=metadata_getnasn(conn_uri, "Domain", i, domainuri);

							if rc2 > 0 then
								rc3=metadata_getattr(domainuri, "Name", AuthDomain);
							rc4=metadata_getprop(conn_uri, 
								"Connection.SQL.Property.Datasrc.Name.xmlKey.txt", sqldatasrc);
							rc5=metadata_getprop(conn_uri, 
								"Connection.Oracle.Property.PATH.Name.xmlKey.txt", orapath);
						end;
				end;
			output;
		end;

	else
		put 'There are no libraries defined in this metadata repository.';
run;

proc print data=meta_libraries; where engine="SASIOLA"; run;

3. Also, you can get the list of LASR server registered on the metadata server via SAS LASR Authorization REST API. Here is a simple example using that REST API through a curl command:

 

 

curl -X POST -i -d 'username=USERNAME&password=PASSWORD' http://MIDDLE_TIER_URL/SASLogon/v1/tickets
curl -X POST -d "service=http://MIDDLE_TIER_URL/SASLASRAuthorization/rest/servers" http://MIDDLE_TIER_URL/SASLogon/v1/tickets/TGT-TICKET-FROM-THE-FIST-COMMAND
curl http://MIDDLE_TIER_URL/SASLASRAuthorization/rest/servers?ticket=ST-TICKET-FROM-THE-SECOND-COMMAND

All of these commands depend on each other. You have to get both TGT & ST tickets from the Central Authentication Service and get a JSON file with LASR servers and their statuses. More information about the Central Authentication Service.

 

Version history
Last update:
‎09-13-2019 11:04 AM
Updated by:
Contributors

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags