Published on :
Administration CREATION_INTERNE

Metadata Server Port and Service Extraction

This code is also available in: Deutsch Español Français
Awaiting validation
Attention : This code requires administrator privileges.
The program connects to the SAS© Metadata Server via global options. It then uses metadata interface functions (`metadata_resolve`, `metadata_getnobj`, `metadata_getnasn`, `metadata_getattr`) to traverse the `ServerComponent` object. For each server found, it extracts associated source connections, protocols, and port numbers, storing everything in a `servers` table. A final report is generated. Note: This code is specific to the SAS© 9.x architecture and requires an active metadata server; it is not suitable for the native SAS© Viya 4 architecture without bridging configuration to a SAS© 9 environment.
Data Analysis

Type : CREATION_INTERNE


Data is generated by querying the system metadata repository via specialized SAS functions.

1 Code Block
OPTIONS
Explanation :
Definition of connection variables and configuration of global options to connect to the SAS Metadata Server.
Copied!
1%let metaserve=meta.demo.sas.com;
2%let metaport=8561;
3%let userid=sasadm @saspw;
4%let pass=password;
5 
6options metaserver="&metaserve"
7 metaport=&metaport
8 metauser="&userid"
9 metapass="&pass"
10 metarepository=Foundation
11 metaprotocol=BRIDGE;
2 Code Block
DATA STEP Data
Explanation :
Data Step querying metadata to list 'ServerComponent' objects, extract their attributes (names) and associated connections (ports, protocols) via loops and `metadata_*` functions.
Copied!
1DATA servers;
2 LENGTH type id $ 17 server_uri conn_uri $ 50 server_name conn_name $ 256 conn_prot conn_port $ 5 conn_port_num 3;
3 /* ... labels et initialisation ... */
4 obj="omsobj:ServerComponent? @code_sas_json_prod_multi/get_number_column_names_de.json contains '.'";
5 server_cnt=metadata_resolve(obj,type,id);
6
7 IF server_cnt > 0 THEN DO n=1 to server_cnt;
8 /* Extraction des infos serveur et connexions */
9 rc=metadata_getnobj(obj,n,server_uri);
10 /* ... logique d'extraction des ports ... */
11 IF conn_port_num ne 0 THEN OUTPUT;
12 END;
13 ELSE put "ERROR: No server definitions found in Metadata.";
14RUN;
3 Code Block
PROC SORT
Explanation :
Sorting the resulting table by server name.
Copied!
1PROC SORT DATA=servers;
2 BY server_name;
3RUN;
4 Code Block
PROC REPORT
Explanation :
Generation of a report displaying the list of extracted servers and ports.
Copied!
1 
2PROC REPORT
3DATA=servers;
4title "Port use defined in Metadata Server &metaserve";
5RUN;
6 
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Author: Greg Wootton Date: 15JAN2018


Banner
Expert Advice
Expert
Michael
Responsable de l'infrastructure Viya.
« Extracting ports and protocols directly from the Metadata Server is a vital step for auditing and securing a SAS 9 platform. This script transforms the logical view of your infrastructure into a concrete network traffic matrix, which is indispensable for configuring firewalls or diagnosing connectivity issues between various components like Workspace, Stored Process, and OLAP servers. »