Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1] 2
  Reply  |  Print  
Author Topic: Checking what's running  (Read 29027 times)
Tim B.
Posts: 67


« on: May 27, 2009, 03:16:16 pm »

Is is possible to check what programs the GDC is running? 

What I want to do is check that when a menu is launched the user isn't already running one.  At them moment I do this using a process log table in the DB, but this doesn't always reflect the real world if a process has been killed of or has crashed.  Ideally I'd like to look through the entire AUI tree, rather than just that of the current application.

.
Four Js
Posts: 115


« Reply #1 on: June 08, 2009, 08:34:40 am »

Today there is no way, unfortunately.
Of course, this is technically doable, we only need to find a way to make it robust and a bit secured: do you expect that an application running on a server A knows that you are running an application from a server B ?

I would expect that an application can get information only from applications being in the same context, or that each application should define who can get information.
The same for AUI Tree.
What if I'm doing:

Code
  1. MAIN
  2. ..
  3. FOR i = 1 TO nb_applications
  4.   DISPLAY CURRENT
  5.   DISPLAY getAPplicationName(i)
  6.   DISPLAY dumpAUI(i)
  7.   SLEEP (1)
  8. END FOR
  9.  
  10. END MAIN
  11.  

Each second you dump all AUI trees from all application, then grep for password / login or any confidential data, and you're likely to see things you should not.
So providing this feature is, again, not too difficult (we're already doing similar stuff for internal QA), but this is not easy to implement a solution which is not too dangerous for security.


And I also expect this feature to work with web applications too - so this is not a GDC specific issue, but concerns all front ends, right ?
Tim B.
Posts: 67


« Reply #2 on: June 08, 2009, 11:05:17 am »

I would need to know the names of the programs the F/E client is running, regardless of which server is handling the process.

The idea it to make sure a user doesn't launch multiple programs (mainly the menu).  My idea was that a call to the GDC could return the names of the programs that were running.  No other information would be required, so full access to the AUI tree isn't required to achieve this and would be very dangerous.
Reuben B.
Four Js
Posts: 1062


« Reply #3 on: June 09, 2009, 01:18:25 am »

Is is possible to check what programs the GDC is running? 

What I want to do is check that when a menu is launched the user isn't already running one.  At them moment I do this using a process log table in the DB, but this doesn't always reflect the real world if a process has been killed of or has crashed.  Ideally I'd like to look through the entire AUI tree, rather than just that of the current application.



Isn't this really a back-end problem?

As you point out a process log table in the DB technique has the flaw that if you set a flag when the program starts and unset it when the program exits, then if the process crashes or is killed then the flag is not unset.

Why don't you do something similar to what 4Js licensing does and checks to see if that process is still in use.  It checks to see if the process as recorded against the license is still in use and if it isn't it knows it can free up that license.  So in your case if user attempts to start the menu, the process log table shows that they are running the menu with process 1234, check what process 1234 is doing, and if it isn't running the menu then delete that entry from your process log table and allow the user to start the menu.

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Tim B.
Posts: 67


« Reply #4 on: June 09, 2009, 10:58:35 am »

I do actually do all this, but it's still not always accurate.  Sometimes the process may be running on the backend even when it's no longer on the F/E.  Also, sometimes an fgl process with the same ID may have subsequently started (we get a lot of process supercession on our system).  So you cannot ever be sure that the checks you make on the back end are accurate in terms of what the user has on their front end, eg has the user got a working and visible process running.
Leo S.
Four Js
Posts: 126


« Reply #5 on: June 09, 2009, 04:31:12 pm »

Hi Tim,
I believe it's a legal request to have certain applications started only once per end user in order to save resources.
So the title of the request for me would be "have a run once flag for 4GL applications".
We will discuss this in the dev team if this is possible to get it into the product.
The main problem is probably how to define what one end user means...

Kind Regards, Leo
Tim B.
Posts: 67


« Reply #6 on: June 09, 2009, 04:57:09 pm »

Sorry I don't quite understand what you mean by 'legal request'.  Something lost int he translation I guess :)

It's not really about forcing applications to only be run once.  We often have and require mutiple screens to be open so that (eg) two different customers can be looked at at the same time.  This is fine, but when the user has 3+ of the same screens open I want to start preventing any more from being opened, hence the need to check with the GDC what's running.  Usually this is because they don't realise they have so many open as they have been obscured.  If left unchecked they could have dozens of screens opened at the same time.

A 'run once only' flag in this instance wouldn't be of any use.  A simple call to the GDC to check the running programs would be enough.
Leo S.
Four Js
Posts: 126


« Reply #7 on: June 09, 2009, 06:03:31 pm »

With 'legal' I meant 'valid' , sorry for the mistake...
>A 'run once only' flag in this instance wouldn't be of any use.  A simple call to the GDC to check the running programs would be enough.
ok, could be theoretically extended to "allow only <n> instances per user" .
However it sounds to me that you want to patronize a bit your end users ,
which other application on your desktop is limited to exactly 3 instances?
>If left unchecked they could have dozens of screens opened at the same time.
Does this hurt because of too much licenses wasted or because the memory consumption at the server side is too high?

Tim B.
Posts: 67


« Reply #8 on: June 09, 2009, 06:17:59 pm »

Change the work 'patronize' to 'control' and you'd be right, but 'patronize' certainly not.

We need to control them because if we don't they'll crash the server, because everyone has dozens of programs over and the server won't be able to cope.  The back-end can only run a finite number of processes before it runs out of resources, so we need to impose reasonable limits on our users.  This sort of app isn't comparable to conventional apps such as Excel or Word.

Licences are irrelevant because each user only use a single licence.

Again, a 'run x times' would be of no use.  An global limit cannot be set.  Some programs we may only want them to run 1 instance of (eg the menu).  Others we may want to allow more.
Leo S.
Four Js
Posts: 126


« Reply #9 on: June 09, 2009, 06:28:26 pm »

If 'patronize' sounds to harsh we take 'control' :-) (I got patronize from the translation)
>Again, a 'run x times' would be of no use.  An global limit cannot be set.  Some programs we may only want them to run 1 instance
of (eg the menu).  Others we may want to allow more.
I didn't mean a global flag.
Application 'A' : run only once.
Application 'B' : allow 4 instances.
Application 'C' : allow 2 instances.

Is this you are after? Or do you want to control the number of processes dynamically , depending on the number of processes at the server side ?
Paul S.
Posts: 45


« Reply #10 on: June 10, 2009, 11:18:16 pm »

Hi Tim,

if your server/backend is a Unix/Linux system you could use something like this:

FUNCTION is_program_running(l_p)
DEFINE   l_p   STRING
DEFINE   a  CHAR(150),
      b  SMALLINT
   IF get_length(l_p) = 0 THEN
       LET l_p = g_program_name.trim()
    END IF
         LET a = "ps -fu",g_userid_full.trim()," | grep " , l_p.trim(), " | awk '{print $9}' ",
                           " | grep app | wc -l >/tmp/tmp.fgl"
         RUN a
         LET b = 0
         IF test_file("/tmp/tmp.fgl") THEN
            LET ch = base.Channel.create()
            CALL ch.setDelimiter("^")
            CALL ch.openFile("/tmp/tmp.fgl" , "r" )
            WHILE ch.read([a])
               LET b = a CLIPPED
            END WHILE
            CALL ch.close()
            LET a = "rm -rf /tmp/tmp.fgl"
            RUN a
            IF b IS NULL THEN
               LET b = 0
            END IF
         END IF
          RETURN b

END FUNCTION

Not great not it may help.

Paul

Reuben B.
Four Js
Posts: 1062


« Reply #11 on: June 11, 2009, 12:44:52 am »

Hi Tim,

if your server/backend is a Unix/Linux system you could use something like this:

FUNCTION is_program_running(l_p)
DEFINE   l_p   STRING
DEFINE   a  CHAR(150),
      b  SMALLINT
   IF get_length(l_p) = 0 THEN
       LET l_p = g_program_name.trim()
    END IF
         LET a = "ps -fu",g_userid_full.trim()," | grep " , l_p.trim(), " | awk '{print $9}' ",
                           " | grep app | wc -l >/tmp/tmp.fgl"
         RUN a
         LET b = 0
         IF test_file("/tmp/tmp.fgl") THEN
            LET ch = base.Channel.create()
            CALL ch.setDelimiter("^")
            CALL ch.openFile("/tmp/tmp.fgl" , "r" )
            WHILE ch.read([a])
               LET b = a CLIPPED
            END WHILE
            CALL ch.close()
            LET a = "rm -rf /tmp/tmp.fgl"
            RUN a
            IF b IS NULL THEN
               LET b = 0
            END IF
         END IF
          RETURN b

END FUNCTION

Not great not it may help.

Paul



Paul,

Have you seen base.Channel.openPipe() ?  It will remove the need for the temporary file you have used in your example, and thus make your code more safe in a multi-user environment (have you considered what happens if two processes try to access /tmp/tmp.fgl at the same time?).

Reuben


Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Paul S.
Posts: 45


« Reply #12 on: June 11, 2009, 09:30:17 am »

Thanks Reuben,

I will change the function to use pipes instead.

Paul
Tim B.
Posts: 67


« Reply #13 on: June 11, 2009, 09:31:36 am »

Sorry for no reply yesterday - we have just gone live with Genero, so was quite busy the last few days.

Paul - we are using Windows, however I have a VBScript which does much the same.  The problem is that what's on the backend doesn't always tie up with what's on the front end, hence my request to query the GDC for info.

Leo - I don't really want to impose hard and fast rules, or maintain a large list of applications and the numbers of times people can run them.  What we have tried is a function in the process initialize function which does some checks and warns users that they are running too many programs (overall) or too many of the same type.  We normally don't like user have more than about 4-5 apps open, because a) they get confused, and b) it uses up too many resources.  There are some exceptions for some people though, so we need to be flexible and dynamic.

All I was thinking about was something like: CALL ui.interface.frontcall("standard","feinfo",[ "applist" ], [ l_applist ] )
.
Four Js
Posts: 115


« Reply #14 on: June 11, 2009, 09:48:04 am »

Tim,

While I understand the need, I'm just a bit concerned with one item: GDC is more or less a browser ; it reads a UI description from the network (HTML / AUI Tree), builds the interface and reacts to end user actions.

Now: would you be happy if, when you connect to www.4js.com, we would be able to know that you're connected at the same time on your bank web site, on amazon and on your favorite band's myspace home page ?
I presume no, and this is what I try to underline.
www.4js.com should only know that you're connected at the same time on the forum and the support page, but nothing else.

For me, your initial request is valid, but I would prefer we offer you something more server centric.
Having this on the server side as for me many advantages:
- works with any front-end (don't care if half of your processes are used for GWC, half for GDC)
- there is no privacy concern
- it shows really the use of your server. If this is done on GDC side, you will know what is running on a specific GDC. If you've 100 different users (or 1 user running 100 GDC using -n option), you'll see that each GDC runs 1 application and this will look ok, while 1 user running 50 applications would be considered as an issue.

I know that GDC can already do lots of things against privacy, but this was done in early days mainly for compatibility reasons (good old rcp deamon from Wtk) and today's trend is to provide more and more safe guards in this area.
Pages: [1] 2
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines