Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Displaying Status In Continuous Real Time Mode

by Anonymous Monk
on Jul 24, 2007 at 19:11 UTC ( [id://628557]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello again, I have a C program that currently returns % of job completed to the Perl script and the Perl script pushes this data to the web browser using server push technology. This part is working as required but the boss now wants the C program to also return the time it took to process these requests and the Perl script to display this on the browser using continuous mode (something similar to Windows Task Manager Performance tab when you press CTRL-ALT-DEL). Does anyone know of a Perl package that would allow me to do this? Thanks

Replies are listed 'Best First'.
Re: Displaying Status In Continuous Real Time Mode
by BrowserUk (Patriarch) on Jul 25, 2007 at 06:10 UTC

    You want to display a real-time, scrolling graph of time/percentage complete in a browser window?

    Your cgi script ise getting the numbers to use, directly from the process being monitered, that you are running from within that cgi script using IPC::Open2?

    Since the process is providing the numbers itself, you only get one set number of (pairs of) values, 10, where each value represents 10% completion and the associated value is the time (in seconds?) to complete that percentile?

    So your graph would eventually end up looking something like:

    80 + | 70 + |----- S | | 60 + |-----| E | |----| 50 + | C | |----| 40 + ____| O | |----| 30 + | N | |----| 20 + | D | |----| 10 + |----| S |____| 0-+----+----+----+----+----+----+----+----+----+----+ 0 10 20 30 40 50 60 70 80 90 100 P e r c e n t a g e C o m p l e t e

    You could certainly draw the graph as an image using GD or similar; and use timed refreshes or "server push" (however that works), to update the browser. Or you could probably draw a pretty good representation using an html table and just periodically refresh that.

    Will you find a module pre-written to do this for you? Probably not.

    If there is one, will anyone who knows about it, know what you are looking for from your rather poor description in this thread? Probably not.

    Had I not been involved in your previous, anonymous thread--which I only know was you because I recognise those fairly unique progress messages: +::010::5 +::020::7 that you posted in another reply--I certainly wouldn't have a clue what you are after from your question.

    If you're going to be a regular, get an account. If there is already pertinent information in a previous post, refer to it. These things will make it much easier, and therefore much more likely, for people to help you.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Thanks. This is exactly the graph I am looking for. I am currently using GD to display the final bar graph but am not sure how to use it to display a real-time, scrolling graph of time/percentage complete in a browser window. I will look into using the table option for displaying the graph but will it be able to display one line for read, one for write, and one for update, each line in a different color I hope?
Re: Displaying Status In Continuous Real Time Mode
by mattr (Curate) on Jul 25, 2007 at 09:47 UTC
    Hi. I take it you want a real time scrolling progress chart in a web page. You will need to write a display client in flash or javascript. I don't recommend trying to push an image from the server.

    Look on the javascript sites if you like, this is like a keyword "suggest" autocompleting text input field function. The javascript uses Xmlhttp or XMLRPC etc to ask your perl app every second or two for the latest value and then renders it. Probably the prettiest display would be if you use openlaszlo which renders to flash or dhtml. Or you could use Dojo Toolkit, etc. You are talking about making a new widget of your own (the widget you want doesn't exist, I think) so it is not an instant thing.

    Incidentally I found a nice javascript bar graph site with downloadable code. It should be quicker for you to use the progress bar from this, and hook it up over xmlhttp to your perl program (see the Dojo site under I/O). However as I say this I note that the Dojo site says they have very fast vector graphics, and so it might be interesting to implement a scrolling line chart in Dojo. Maybe someone else here could give you some pointers, i.e. which xmlrpc module to use, etc.

    Opening a CGI every second will get old fast so you probably would want to run the perl app in an HTTP::Daemon or as fastcgi or mod_perl.

      Another nice javascript graph tool is PlotKit. However, I am not sure how active development on this tool is.
Re: Displaying Status In Continuous Real Time Mode
by fmerges (Chaplain) on Jul 24, 2007 at 20:39 UTC

    Hi,

    I encourage you to provide more info about how the C program gets called/executed to getting better feedback

    Basically the thing is that you need to get some data back from the C program, I don't know how you calling it, if it's a daemon that accepts jobs or whatever. If it runs as a daemon you can do it via log files very easy, if you run it for every job, then you can do it also with logs storing the date you started and the one when it finishes.

    Then for displaying purposes you can use any chart/plotting module

    Take also a look to GTop for retrieving info about the running processes

    Regards,

    fmerges at irc.freenode.net
      Actually the C part is written by someone else and it is working correctly. It is returning:
      +::010::5
      +::020::7
      +::030::6
      +::040::10
      +::050::5
      +::060::7
      +::070::6
      +::080::10
      +::090::6
      +::100::10
      where is first column after the +:: is how many % of the job has been completed. The number 5 after that is how much time it took to complete the first 10% of the job. We want to be bacl to display this time in a graphical continuous mode if it is possible. Is there any PERL package for this? Thanks.
Re: Displaying Status In Continuous Real Time Mode
by TGI (Parson) on Jul 25, 2007 at 00:55 UTC

    I am not sure what you mean by "this". Do you want something to produce time series graphs like RRDTool? Or perhaps a different sort of graph?

    I don't really understand what sort of a layout you want, your description doesn't match what I see in the Task Manager.

    Clarifying your request is likely to get you more useful help.


    TGI says moo

      In Windows, when you press CTRL-ALT-DEL, the third (last) tab has a Memory utilization graph and the processor utilization graph. This is something that we are looking for. Thanks.
Re: Displaying Status In Continuous Real Time Mode
by pemungkah (Priest) on Jul 27, 2007 at 22:30 UTC
    We've done something similar with YUI and Javascript (disclaimer: I work at Y! and we eat our own dogfood). Essentially, you send an XmlHttpRequest to a background process, which collects the data and sends it back as a JSON object. The code in the browser then extracts the data from the returned JSON object and uses it to paint a DIV corresponding to the % complete.

    We were even able to return a (relatively-large) logfile in the JSON object as well to get a running window into the status of the run.

    This may not be close enough to what you want to work. If it is, let me know and I'll sanitise the code and post it here somewhere - probably as a separate node so it's easier to point to.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://628557]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-03-29 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found