BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Alexsander
Fluorite | Level 6

Hi All,

    I have a stored process, lets say "my_common_stp", which is running in information delivery portal.

We have 300 users, using this stored process. I want to find who are all using this STP. Basically I need to have control over the user's sessions.

Could you please help me to list all the active sessions which use "my_common_stp"?

Thank you.

Regards,

alex


1 ACCEPTED SOLUTION

Accepted Solutions
boemskats
Lapis Lazuli | Level 10

Alex,

To be honest it does look like you're using your stored processes in a slightly unorthodox way. What are the stored processes doing to be running for that long? Have you considered using Sessions?

You seem to have a working solution though, so let me ask you - how are you reactivating your stored processes? Are you sure you're talking about running the stored process for 5 minutes at a time, or are you trying to avoid the session timeout / logoff?

From your reply it seems to me that you're wanting to actually run the stored process every 5 minutes, but the stored process itself doesn't take 5 minutes to execute. This is what I'm hoping, because otherwise you are unnecessarily occupying a STP multibridge session per user each time you do this, and you'll have a limited number of those.

If it is indeed the latter, something you can consider doing (but it is not something I would recommend), is using a HTML meta refresh tag inside the header of the output produced by your master stored process, and setting the refresh frequency to something like 2 minutes. This will give you a row in the audit table for every 2 minutes that a user has that stored process open in a tab in the browser inside the portal or whatever. This is pretty bad practice though, as it produces a lot of unneeded load on the stored process server.

Something else I would suggest if you really need real time tracking is using a javascript tracking cookie such as Google Analytics or something similar, loading the javascript code as part of your STP output and getting the cookie to talk to a collection server outside of SAS, this way tracking usage that way without putting unneeded load on the stored process server. You can then use the audit code to log the &_HTCOOK macro variable holding the cooke info / session ID to your audit table and reconcile your user IDs to your externally collected sessions that way.

We really need to know what do you mean by 'needing control over the users sessions'? Control them as in limit the users, audit them, prevent them using it too much?

Jaap - the initialisation program is literally like an autoexec for each stored process request - I think it's treated as a lev2 include also. It doesn't change any stored process metadata, just the appserver metadata.

EDIT: Just checked, it's a lev1 include not lev2

View solution in original post

9 REPLIES 9
boemskats
Lapis Lazuli | Level 10

Alex,

SAS allows you to execute per-request code before and after the request is made, and the STP webapp macro variables of &_METAPERSON and &_PROGRAM are available to you within that code. Think of it as a per-request autoexec, which you can use to do something like

%IF &_PROGRAM = /myPrograms/my_common_stp %THEN %DO;

proc sql;

   insert into myAuditTable

   "&_METAPERSON";

  quit;

%END;

Remember to think about concurrency and table locking, and either use a database which supports concurrency or a sas/share library. If you allow xcmd then you can also echo this info to a flat file, along with a timestamp and some other bits. Also there's no reason why you can't keep a trail of all programs executed by all users this way.

To implement this approach, in SAS Management Console, go to:

SAS Management Console -> Environment Management -> Server Manager -> [SASApp], then

right click on [SASApp] - Logical Stored Process Server -> Properties -> Options -> Set Server Properties -> Request tab -> Initialisation Program and add the path of your 'audit program' here.


Restart the spawner, and from then on each client request to the STP server will run your audit code first, keeping an audit trail.

Hope that helps.

Nik

Alexsander
Fluorite | Level 6

Hi Nik,

   Thank your for your time and input on this request.

I think half of my problem will be solved by your solution. let me explain my problem in details.

I have a common stored process, which is kind of master stored process for other stored process. We have more than 100 users who are using this common stored process. we have a limitation for stored process that is our all stored process will run only for 5 minutes(5 minutes time out at server level). We want to activate  or refresh the master stored process (common stored process) based one some event or just before 5 minutes time out. so that user no need to log in portal again due to 5 minutes time out.

Basically at any given point of time i need to know which user/process are using this common stored process, so that i can refresh those stored process based on a event or just before 5 minutes from the last active time. Note that I do not want to refresh the other child stored process.

Thanks again for your time and input.

Regards,

Alex

boemskats
Lapis Lazuli | Level 10

Alex,

To be honest it does look like you're using your stored processes in a slightly unorthodox way. What are the stored processes doing to be running for that long? Have you considered using Sessions?

You seem to have a working solution though, so let me ask you - how are you reactivating your stored processes? Are you sure you're talking about running the stored process for 5 minutes at a time, or are you trying to avoid the session timeout / logoff?

From your reply it seems to me that you're wanting to actually run the stored process every 5 minutes, but the stored process itself doesn't take 5 minutes to execute. This is what I'm hoping, because otherwise you are unnecessarily occupying a STP multibridge session per user each time you do this, and you'll have a limited number of those.

If it is indeed the latter, something you can consider doing (but it is not something I would recommend), is using a HTML meta refresh tag inside the header of the output produced by your master stored process, and setting the refresh frequency to something like 2 minutes. This will give you a row in the audit table for every 2 minutes that a user has that stored process open in a tab in the browser inside the portal or whatever. This is pretty bad practice though, as it produces a lot of unneeded load on the stored process server.

Something else I would suggest if you really need real time tracking is using a javascript tracking cookie such as Google Analytics or something similar, loading the javascript code as part of your STP output and getting the cookie to talk to a collection server outside of SAS, this way tracking usage that way without putting unneeded load on the stored process server. You can then use the audit code to log the &_HTCOOK macro variable holding the cooke info / session ID to your audit table and reconcile your user IDs to your externally collected sessions that way.

We really need to know what do you mean by 'needing control over the users sessions'? Control them as in limit the users, audit them, prevent them using it too much?

Jaap - the initialisation program is literally like an autoexec for each stored process request - I think it's treated as a lev2 include also. It doesn't change any stored process metadata, just the appserver metadata.

EDIT: Just checked, it's a lev1 include not lev2

Alexsander
Fluorite | Level 6

Hi Nik.

   Yes. Most of our stored process run more than 30 minutes. we have 100+ different stored process which runs more than 30 minutes. These STPs produce data dump, not reports!. We have server set up with 5 minutes timeout. We cannot ask our admin to increase the time out from 5 minutes to 40 minutes.To address this time out issue we have implemented online "plus" batch solutions.

Online: The master stored process collects all different reports prompts values along with corresponding code to execute. this step is running in stored process sever. There is 5 minute a limit in executing the report stored process server.

Batch: We have common scheduler code which executes the stored process actual code with corresponding report's prompt values. this process runs in works pace server, there is no limit to execute any code in work space server.

As you said we are using HTML tag to refresh the master stored process every one minute and it create lot of load in the back end. now i want to reduce the load by not refreshing the master stored process at every minute.  I want to refresh the master stored process just before the 5 minutes log out time or my data set changes the values. which ever is earlier I want to refresh. so that I can reduce the load at my server.

I am not sure how to identify my active stored process at any given point of time.  I will think about adding your above logic and refreshing it.Please let me know if you have any other solutions for this. Thank you for your time and valuable input on this.

Regards,

Alex

jakarman
Barite | Level 11

or you could use the APM package (Audit and Performance Measurement).

Your question is quit common to audit questions.

---->-- ja karman --<-----
jakarman
Barite | Level 11

I do not get it.
The stored process definition is some metadatadefinition and sas code. Changing that will possible hamper running processes.

Do you want to update the definitions (a change)  without hampering users?

A stored process can be activated by a using a Stored-process service or a workspave service.

A stored process service can be configure it will stop when not used for some time. In a web-environment is often left open.

Do you want to refresh these ones?    You could define multiple appserver contexts for some kind of isolation.

---->-- ja karman --<-----
jakarman
Barite | Level 11

@Nik, yes I know all those kind of options. the usermods_ files on the appserver configuration level.

Nice for having the same ides of doing some configurations at that level.
You can also code that as preprocess code in some tools (DI) always having the issue the logging is created with the credentials of the running process.

That is the same place were the APM tooling is modifying some parts to get it all better audited and monitored

APM is found at: SAS Audit, Performance and Measurement package   some parts are moving into the environment manager with 9.4

Why building something that is already present and available for free?

By the way lev1 or lev2 and the appserver name is all a choice of doing the configuration the same with all ports.

Alexsanders issue is looking to be on batch usage with SP;s he could use a batchserver in appserver for that (adding a new server).

Runnig processes longer as some 1 minute is not good practice in a web-appraoch. There are more time outs involved. I believe the browser will stop after 5 minutes. Firewalls are often having session-time out on 2 hours etc.etc. Long running processes should run as batch process.

Sessions that have been timed out can be found in the objectspawner log (it is a error type   or was it the metdataserver log...)

---->-- ja karman --<-----
boemskats
Lapis Lazuli | Level 10

I still don't 100% understand how your setup works, but have you seen &_action=backround?

39114 - Tips for running a SAS® Stored Process in Background mode using SAS® 9.2

Also, you're wanting to trigger a stored process whenever the control dataset changes?

This aside, something you can do is use the original 'audit code' up top in the intialisation to write to a dataset, with a third column of PID which you get from &sysjobid., which will give you an unique identifier for your multibridge session, and a fourth column with value 'start'. Then you can use the same program as the termination program (same location in metadata config) to tell you when a user has finished running the same program, but put 'stop' in that fourth column. Otherwise it looks like quite a peculiar setup. Hope some of that stuff helps

boemskats
Lapis Lazuli | Level 10

Jaap, my reply wasn't the clearest - I meant it is run as a level 1 rather than a level 2 %include, rather than running on lev1/lev2 config.


Running long stored processes like this, as you say, is indeed bad practice as it depends on the http request timeout, and can even leave threads hanging in the SPWA sometimes.

From memory I think the way it works is the session timeouts & context timeouts come out in the multibridge session log, while the username / session redirection info comes from the spawner logs, and something similar but to do with authentication from metadata. I'm not sure if that's how APM pulls the info out. You should be careful with those if you use cost based load balancing, as sometimes the session timeouts don't subtract the cost from the stp session and you can end up with an unresponsive multibridge session.

I'm quite aware of APM, but to be honest it seems like overkill for this particular case, although it can be worth doing due to its other benefits. It can be quite a handful to configure - especially if it requires Alex to negotiate with his admin, which seems like an issue here. I have used it in the past, but have now developed another commercial monitoring solution. I don't want to use these forums to promote my own products but if you find me on linkedin I'd really like to demo it to you, as I think you'd find it very interesting having read some of your more advanced posts on here.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 3241 views
  • 3 likes
  • 3 in conversation