Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[COMPLETE] Daemon/script to record how long a program is run
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2  
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
msalerno
Veteran
Veteran


Joined: 17 Dec 2002
Posts: 1338
Location: Sweating in South Florida

PostPosted: Wed Jun 14, 2006 2:18 pm    Post subject: Reply with quote

After reading the initial post, I wanted to see if I could script it as well. I took the inotify approach.

I used: inotify-tools
It's not in portage
http://rohanpm.net/inotify-tools

You could use something like:

inotifywait -m -e delete -e create /proc/

Which "should" print all create & delete events to the STDOUT. The only problem is that it doesn't work on the /proc filesystem. I tested it on a normal directory and it worked perfectly. This is not an issue with the inotify-tools, I believe it has to do specifically with /proc.

I don't think inotify will be a solution.
Back to top
View user's profile Send private message
BlackEdder
Advocate
Advocate


Joined: 26 Apr 2004
Posts: 2588
Location: Dutch enclave in Egham, UK

PostPosted: Wed Jun 14, 2006 2:25 pm    Post subject: Reply with quote

I wonder if we should report a bug for this. The whole everything is just a file is only useful if that is really the case :). On the other hand, maybe they have good reasons for this exception.
Back to top
View user's profile Send private message
msalerno
Veteran
Veteran


Joined: 17 Dec 2002
Posts: 1338
Location: Sweating in South Florida

PostPosted: Wed Jun 14, 2006 3:00 pm    Post subject: Reply with quote

The thing is that the /proc is it's own pseudo filesystem.

Most likely it doesn't work like a standard fs.
Back to top
View user's profile Send private message
guero61
l33t
l33t


Joined: 14 Oct 2002
Posts: 811
Location: Behind you

PostPosted: Wed Jun 14, 2006 4:04 pm    Post subject: Reply with quote

An excerpt from 'sa -a' after allowing accounting overnight; there are actually 77 entries, I just didn't want to post a bunch of noise.
Code:

       3    1491.04re      21.73cp         0avio      1565k   sshd*
       2      73.75re       3.05cp         0avio     20200k   firefox-bin
       1       0.05re       0.05cp         0avio       458k   updatedb
       1    1491.01re       0.03cp         0avio      1802k   sshd
      12     123.90re       0.03cp         0avio      2788k   xterm
       3       0.93re       0.01cp         0avio      1672k   vim
     147    1614.84re       0.01cp         0avio       638k   bash
       9       0.01re       0.01cp         0avio       948k   troff
       1      83.70re       0.01cp         0avio      1088k   ssh
       3       0.00re       0.00cp         0avio       765k   eix
       1       0.08re       0.00cp         0avio       698k   runscript.sh
Back to top
View user's profile Send private message
russianpirate
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1167
Location: Detroit, MI

PostPosted: Thu Jun 15, 2006 1:11 am    Post subject: Reply with quote

ya i got acct tools to work, but sa -a only prints cpu time, not how long the program was in ram
Back to top
View user's profile Send private message
guero61
l33t
l33t


Joined: 14 Oct 2002
Posts: 811
Location: Behind you

PostPosted: Thu Jun 15, 2006 2:22 am    Post subject: Reply with quote

No - the third column shows CPU time, the 2nd column shows 'real' or 'wallclock' time - what you're looking for.
Back to top
View user's profile Send private message
russianpirate
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1167
Location: Detroit, MI

PostPosted: Thu Jun 15, 2006 2:28 am    Post subject: Reply with quote

what is the measurement "re"? seconds or minutes?

ps:
Code:
[andrey@darkstar ~]$ sa -a | grep gaim
       1       1.01re       0.02cp         0avio      5346k   gaim
       2       1.36re       0.00cp         0avio      5689k   gaim*
[andrey@darkstar ~]$ sa -a | grep firefox
       3      28.62re       2.01cp         0avio     23008k   firefox-bin
       3      28.63re       0.00cp         0avio      1455k   firefox
       4       0.02re       0.00cp         0avio     30072k   firefox-bin*
[andrey@darkstar ~]$


how could that be if i ran gaim for a long longer than firefox...
Back to top
View user's profile Send private message
guero61
l33t
l33t


Joined: 14 Oct 2002
Posts: 811
Location: Behind you

PostPosted: Thu Jun 15, 2006 2:35 am    Post subject: Reply with quote

That's where the man page gets a little fuzzy. It looks like seconds to my "experienced" UNIX eye, but specifically the '-j' option states:
Code:

-j, --print-seconds
    Instead of printing total minutes for each category, print seconds per call.


Whereas the beginning of the man page states:
Code:

re
    "real time" in cpu seconds


I honestly haven't messed around with it enough to tell you if that's a red herring or something that's messed up. Or if I've messed up.
Back to top
View user's profile Send private message
russianpirate
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1167
Location: Detroit, MI

PostPosted: Thu Jun 15, 2006 8:13 pm    Post subject: Reply with quote

the -j option prints out weird output, but i timed it and "sa" alone prints out pretty accurate real time.. so im gonna write a script using perl and awk to organize this nicely :)
Back to top
View user's profile Send private message
russianpirate
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1167
Location: Detroit, MI

PostPosted: Fri Jun 16, 2006 6:05 pm    Post subject: Reply with quote

okay finally with the help of my dad, i wrote a very short, useful, and nice looking perl script for this :).. i just dunno what to name it before i publish it.. cmdtime?
Back to top
View user's profile Send private message
guero61
l33t
l33t


Joined: 14 Oct 2002
Posts: 811
Location: Behind you

PostPosted: Sat Jun 17, 2006 12:20 am    Post subject: Reply with quote

Don't know if it would conflict w/anything else, but maybe "runtime". You may want to look a little deeper and see if you can't figure out how to get 'sa' to not consolidate once-run et. al. into those top two lines; that way you could cover all edge cases.
Back to top
View user's profile Send private message
russianpirate
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1167
Location: Detroit, MI

PostPosted: Sat Jun 17, 2006 2:50 am    Post subject: Reply with quote

Okay the program is fine, however I want to write a gui for it.. i installed wxperl, but dunno how to print an output of a program or variable... :-\ If anyone could write this.. i would be very thankful :)
Back to top
View user's profile Send private message
Dlareh
Advocate
Advocate


Joined: 06 Aug 2005
Posts: 2102

PostPosted: Sat Jun 17, 2006 5:58 pm    Post subject: Reply with quote

1) Show your code
2) From what you describe this to be, I do not believe a GUI would be beneficial to anyone but a novice. Don't waste your time, unless you have some particular desire for GUI experience.
_________________
"Mr Thomas Edison has been up on the two previous nights discovering 'a bug' in his phonograph." --Pall Mall Gazette (1889)
Are we THERE yet?
Back to top
View user's profile Send private message
russianpirate
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1167
Location: Detroit, MI

PostPosted: Sun Jun 18, 2006 4:36 pm    Post subject: Reply with quote

okay the project is complete (took me about 15-20 hours total of work :) and some help from my dad).. its called tcrt (total command runtime), it has a very clean and working gui and also the algorithm has been imporved a lot so that user mistakes would not affect the output of the program and also "all programs" option has been added.. it will soon be posted on sf.net and heres a quick screenie :)

http://img91.imageshack.us/img91/9417/tcrtpreview3fd.png
Back to top
View user's profile Send private message
TheRAt
Veteran
Veteran


Joined: 03 Jun 2002
Posts: 1580

PostPosted: Sun Jun 18, 2006 6:34 pm    Post subject: Reply with quote

russianpirate wrote:
okay the project is complete (took me about 15-20 hours total of work :) and some help from my dad).. its called tcrt (total command runtime), it has a very clean and working gui and also the algorithm has been imporved a lot so that user mistakes would not affect the output of the program and also "all programs" option has been added.. it will soon be posted on sf.net and heres a quick screenie :)

http://img91.imageshack.us/img91/9417/tcrtpreview3fd.png

nice
_________________
All reality is the construct of the observer.

Get Firefox and rediscover the web!

BOFH Excuse #295:
The Token fell out of the ring. Call us when you find it.
Back to top
View user's profile Send private message
russianpirate
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1167
Location: Detroit, MI

PostPosted: Sun Jun 18, 2006 7:07 pm    Post subject: Reply with quote

the gui looks even nicer now

im thinkning if i should add a sort function.. cause you can sort it by time or name.. and these arent columns, so it could be a problem..
Back to top
View user's profile Send private message
russianpirate
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1167
Location: Detroit, MI

PostPosted: Sun Jun 18, 2006 10:51 pm    Post subject: Reply with quote

okay.. new name: Total Process Runtime (tprt) .. i think thats a lot better especially since this program uses process accounting, not command accounting ;)

new screenie: http://img514.imageshack.us/img514/1253/tprtfinal4pl.png
Back to top
View user's profile Send private message
russianpirate
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1167
Location: Detroit, MI

PostPosted: Mon Jun 19, 2006 6:26 pm    Post subject: Reply with quote

Okay here's the release on Sourceforge.net :

http://sourceforge.net/projects/tprt
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum