Attention : This code requires administrator privileges.
The DMSRVADM procedure is used to administer the DataFlux Data Management Server. This example illustrates how to obtain a report of ongoing or completed tasks, and then how to use the information from this report (specifically the task identifier 'jobid') to invoke the DMSrvKillJob and DMSrvDeleteLog functions. These functions are essential for releasing resources and maintaining server order by stopping unwanted processes and erasing execution traces.
Data Analysis
Type : CREATION_INTERNE
Examples generate simulated data ('work.joblist') to demonstrate function calls without relying on pre-existing external data, or use simulated CAS sessions for Viya examples.
1 Code Block
PROC DMSRVADM / DATA _NULL_ Data
Explanation : This basic example shows how to use PROC DMSRVADM to generate a task report. Then, a Data Step iterates through this report and simulates calling the DMSrvKillJob and DMSrvDeleteLog functions for each task. Actual calls are commented out; a simple PUT statement is used for illustration.
Copied!
data work.joblist;
length jobid $16. status $10.;
input jobid $ status $;
datalines;
JOB001 RUNNING
JOB002 COMPLETED
JOB003 FAILED
JOB004 RUNNING
;
run;
proc dmsrvadm
out=work.jobReport
host='http://myhost.unx.com' port=50001;
run;
data _null_;
set work.joblist;
put 'Simulating kill and delete for JobID: ' jobid;
/* Dans un environnement réel, ces fonctions seraient appelées. Ici, nous les simulons. */
/* kjrc=dmsrvkilljob (jobid, 'http://myhost.unx.com' , 50001); */
/* dlrc=dmsrvdeletelog (jobid, 'http://myhost.unx.com' , 50001); */
if status = 'RUNNING' then put ' ACTION: Tentative d''arrêt de la tâche ' jobid;
put ' ACTION: Tentative de suppression du journal pour la tâche ' jobid;
run;
1
DATA work.joblist;
2
LENGTH jobid $16. STATUS $10.;
3
INPUT jobid $ STATUS $;
4
DATALINES;
5
JOB001 RUNNING
6
JOB002 COMPLETED
7
JOB003 FAILED
8
JOB004 RUNNING
9
;
10
RUN;
11
12
PROC DMSRVADM
13
out=work.jobReport
14
host='http://myhost.unx.com' port=50001;
15
RUN;
16
17
DATA _null_;
18
SET work.joblist;
19
put 'Simulating kill and delete for JobID: ' jobid;
20
/* Dans un environnement réel, ces fonctions seraient appelées. Ici, nous les simulons. */
IFSTATUS = 'RUNNING'THEN put ' ACTION: Tentative d''arrêt de la tâche ' jobid;
24
put ' ACTION: Tentative de suppression du journal pour la tâche ' jobid;
25
RUN;
2 Code Block
PROC DMSRVADM / DATA _NULL_ Data
Explanation : This example extends the first by adding selection logic. After generating the task report, the Data Step uses an 'if status = 'RUNNING'' condition to target only active tasks. This allows for more controlled cleanup, avoiding action on tasks that are already completed or pending.
Copied!
data work.joblist;
length jobid $16. status $10. description $30.;
input jobid $ status $ description $;
datalines;
JOB001 RUNNING 'Analyse quotidienne'
JOB002 COMPLETED 'Rapport mensuel'
JOB003 FAILED 'Importation de données'
JOB004 RUNNING 'Traitement de nuit'
JOB005 PENDING 'Mise à jour'
;
run;
proc dmsrvadm
out=work.jobReport
host='http://myhost.unx.com' port=50001;
run;
data _null_;
set work.jobReport;
if status = 'RUNNING' then do;
put 'Arrêt et suppression des logs pour la tâche ' jobid ' (Status: ' status ', Description: ' description ')';
/* Ici, dmsrvkilljob et dmsrvdeletelog seraient appelés pour les tâches 'RUNNING' */
/* kjrc=dmsrvkilljob (jobid, 'http://myhost.unx.com' , 50001); */
/* dlrc=dmsrvdeletelog (jobid, 'http://myhost.unx.com' , 50001); */
end;
else do;
put 'Ignoré la tâche ' jobid ' (Status: ' status ')';
end;
run;
1
DATA work.joblist;
2
LENGTH jobid $16. STATUS $10. description $30.;
3
INPUT jobid $ STATUS $ description $;
4
DATALINES;
5
JOB001 RUNNING 'Analyse quotidienne'
6
JOB002 COMPLETED 'Rapport mensuel'
7
JOB003 FAILED 'Importation de données'
8
JOB004 RUNNING 'Traitement de nuit'
9
JOB005 PENDING 'Mise à jour'
10
;
11
RUN;
12
13
PROC DMSRVADM
14
out=work.jobReport
15
host='http://myhost.unx.com' port=50001;
16
RUN;
17
18
DATA _null_;
19
SET work.jobReport;
20
IFSTATUS = 'RUNNING'THENDO;
21
put 'Arrêt et suppression des logs pour la tâche ' jobid ' (Status: 'STATUS', Description: ' description ')';
22
/* Ici, dmsrvkilljob et dmsrvdeletelog seraient appelés pour les tâches 'RUNNING' */
put 'Ignoré la tâche ' jobid ' (Status: 'STATUS')';
28
END;
29
RUN;
3 Code Block
PROC DMSRVADM / DATA _NULL_ Data
Explanation : This example introduces the use of macro variables (%let) to define the Data Management Server host and port. This makes the code more flexible and easier to maintain, as connection information can be changed in a single place. Cleanup is extended to 'RUNNING' and 'FAILED' tasks.
Copied!
/* Définition des macro-variables pour l'hôte et le port */
%let DMS_HOST = http://myhost.unx.com;
%let DMS_PORT = 50001;
data work.joblist;
length jobid $16. status $10. description $30.;
input jobid $ status $ description $;
datalines;
JOB001 RUNNING 'Analyse quotidienne'
JOB002 COMPLETED 'Rapport mensuel'
JOB003 FAILED 'Importation de données'
JOB004 RUNNING 'Traitement de nuit'
JOB005 PENDING 'Mise à jour'
;
run;
proc dmsrvadm
out=work.jobReport
host="&DMS_HOST."
port=&DMS_PORT.;
run;
data _null_;
set work.jobReport;
if status in ('RUNNING', 'FAILED') then do;
put 'Traitement de la tâche ' jobid ' (Status: ' status ') sur &DMS_HOST.:&DMS_PORT.';
/* Utilisation des macro-variables dans les fonctions simulées */
/* kjrc=dmsrvkilljob (jobid, "&DMS_HOST." , &DMS_PORT.); */
/* dlrc=dmsrvdeletelog (jobid, "&DMS_HOST." , &DMS_PORT.); */
end;
run;
%mend;
1
/* Définition des macro-variables pour l'hôte et le port */
2
%let DMS_HOST = http://myhost.unx.com;
3
%let DMS_PORT = 50001;
4
5
DATA work.joblist;
6
LENGTH jobid $16. STATUS $10. description $30.;
7
INPUT jobid $ STATUS $ description $;
8
DATALINES;
9
JOB001 RUNNING 'Analyse quotidienne'
10
JOB002 COMPLETED 'Rapport mensuel'
11
JOB003 FAILED 'Importation de données'
12
JOB004 RUNNING 'Traitement de nuit'
13
JOB005 PENDING 'Mise à jour'
14
;
15
RUN;
16
17
PROC DMSRVADM
18
out=work.jobReport
19
host="&DMS_HOST."
20
port=&DMS_PORT.;
21
RUN;
22
23
DATA _null_;
24
SET work.jobReport;
25
IFSTATUS in ('RUNNING', 'FAILED') THENDO;
26
put 'Traitement de la tâche ' jobid ' (Status: 'STATUS') sur &DMS_HOST.:&DMS_PORT.';
27
/* Utilisation des macro-variables dans les fonctions simulées */
Explanation : This example proposes a scenario where one might want to clean logs not from the DataFlux Data Management Server, but from CAS sessions or services. Since DMSRVADM is not a CAS procedure, the example is conceptual and simulates the creation of CAS log data, then the hypothetical call of a CAS action ('logmanagement.cleanupLogs') that would be responsible for cleaning inactive logs. This demonstrates the approach and logic of resource management in a Viya/CAS environment even if the specific cleanup tools may vary.
Copied!
/* Cet exemple est conceptuel et simule une approche de gestion des journaux */
/* dans un environnement SAS Viya/CAS, bien que DMSrvAdmin soit spécifique à DataFlux. */
/* Il illustre l'idée de nettoyer des ressources via des actions CAS si un service */
/* de nettoyage des journaux CAS était disponible ou pouvait être orchestré. */
/* Connexion à une session CAS (si non déjà connectée) */
/* options casopts=(cascertpath="/opt/sas/viya/config/etc/certs/trustedcerts.pem"); */
/* cas casauto; */
/* Création d'une table simulée de journaux CAS */
data casuser.caslogs;
length logname $50. logsize num status $10.;
input logname $ logsize status $;
datalines;
/cas/logs/session1.log 1024 ACTIVE
/cas/logs/session2.log 2048 INACTIVE
/cas/logs/old/session3.log 512 INACTIVE
/cas/logs/corrupted.log 0 ERROR
;
run;
/* Utilisation de PROC CAS pour appeler une action simulant le nettoyage */
/* Imaginez une action CAS 'logmanagement.cleanupLogs' */
proc casutil;
load data=casuser.caslogs outcaslib="casuser" replace;
run;
proc cas;
/* Simulation d'une action CAS pour nettoyer les journaux inactifs */
/* work.logmanagement.cleanupLogs / details=casuser.caslogs filter='status="INACTIVE"' */
/* output table=casuser.cleanedlogs; */
print 'Simulating CAS log cleanup for INACTIVE logs from casuser.caslogs...';
action table.fetch / table={name='caslogs', caslib='casuser'} sortBy={'logname'};
run;
data _null_;
set casuser.caslogs;
if status = 'INACTIVE' then
put 'ACTION CAS (simulé): Suppression du journal inactif ' logname;
run;
/* Terminer la session CAS si elle a été démarrée ici */
/* cas term; */
1
/* Cet exemple est conceptuel et simule une approche de gestion des journaux */
2
/* dans un environnement SAS Viya/CAS, bien que DMSrvAdmin soit spécifique à DataFlux. */
3
/* Il illustre l'idée de nettoyer des ressources via des actions CAS si un service */
4
/* de nettoyage des journaux CAS était disponible ou pouvait être orchestré. */
5
6
/* Connexion à une session CAS (si non déjà connectée) */
put 'ACTION CAS (simulé): Suppression du journal inactif ' logname;
41
RUN;
42
43
/* Terminer la session CAS si elle a été démarrée ici */
44
/* cas term; */
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.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.