LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-15-2005, 11:04 PM   #1
blufire
Member
 
Registered: Jul 2004
Location: Japan
Distribution: Fedora
Posts: 148

Rep: Reputation: 16
Using the log to monitor the programs used


Is there a way to use some kinds of logs in order to monitor the programs my guest users use the most. I would basically like to monitor my son and see if he spends more time surfing or writing.

I am competent in C and a little in C++ so I would just like a place to start.
 
Old 06-16-2005, 07:08 PM   #2
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
Quote:
I would basically like to monitor my son and see if he spends more time surfing or writing.
Talk to him.

quote from Dr.Phil: If you don't talk with him about stuff that doesn't matter, you can't talk with him about stuff that matters.

Quote:
I would just like a place to start.
My first idea would be to (every n seconds) run ps, grep for his username and sed/awk out the duration of each process, and generate a neat report of the average lifetime of the processes.

But I've come to realise that the idea is flawed: I leave my programs running even when I'm not using them actively (i.e. they don't have focus). Which is why my system leaks memory

So, a place to start is probably to investigate how you can find out which program has focus. I guess that this would be wm-specific--I don't think X has a notion of focus.

The in my mind optimal solution would then be to install a callback hook everytime the user switches focus, get the new time, subtract the old, and add it to the time of the program switched away from.

Alternatively, just poll for current focus every n seconds.

Things to investigate: can he cheat your program with ssh w. x-forwarding and/or embedded/nested x-sessions?

---
In any case, I hope he doesn't give you his consent (everybody deserves privacy), and I hope you don't do this without his consent.
---

hth --Jonas

Last edited by jonaskoelker; 06-16-2005 at 07:14 PM.
 
Old 06-17-2005, 02:10 AM   #3
blufire
Member
 
Registered: Jul 2004
Location: Japan
Distribution: Fedora
Posts: 148

Original Poster
Rep: Reputation: 16
no I will not do this with out his consent. I am trying to set up something basically so I can keep my own logs. Personally as a parent I would like to know if my son is wasting time on a pc and wasting resources. overall i would like to monitor that. I dont want to monitor what ip addresses he is looking at or even what he is watching if he is watching a dvd. I just what to creat a log that would say that the browser was used 95% of the time and therefor I could set up my system to accomdate his needs for the browser. and rework his set up for that.
 
Old 06-17-2005, 02:17 AM   #4
blufire
Member
 
Registered: Jul 2004
Location: Japan
Distribution: Fedora
Posts: 148

Original Poster
Rep: Reputation: 16
And our children are our responsibility and therefore we should monitor what they watch or do or we are failing them as parents. I often get tired of people saying it was TV that got my son on drugs or premarital sex or what ever. If you do not know what your child is into then you are to blame. and we have had those talks and I do talk with my son. This is just to find a way to monitor the system. not the content.
 
Old 06-17-2005, 01:24 PM   #5
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
Quote:
This is just to find a way to monitor the system. not the content.
Take a deeep breath

I see how one can misunderstand my post--I'm not trying to question your abilities as a parent.

--
in any case, did I give you a good place to start?

--Jonas
 
Old 06-17-2005, 06:24 PM   #6
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
Look into BSD style process accounting, which will probably do everything you want to. Unfortunately, you may need to recompile your kernel to activate it.
 
Old 06-17-2005, 09:48 PM   #7
blufire
Member
 
Registered: Jul 2004
Location: Japan
Distribution: Fedora
Posts: 148

Original Poster
Rep: Reputation: 16
Quote:
--
in any case, did I give you a good place to start?

--Jonas


__________________
Yes you did. And I do aprrieciate it very much. I am just trying to figure out what will be the best way to do that. I will also look into the BSD. Though the time subtraction would seem to be the best. Thankyou
 
Old 06-18-2005, 06:36 AM   #8
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
I'd suggest that if your system supports process accounting `out of the box', use that.

But up to you.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic log in and starting programs at boot Spy47 Linux - Newbie 3 11-18-2004 05:17 PM
Programs Automatically Start When I log In To KDE deft Linux - Software 4 04-06-2004 07:54 PM
can't get my programs onto the 2nd monitor sockknitter Fedora 0 02-07-2004 08:09 PM
download monitor/log radnix Linux - Security 4 06-11-2003 08:13 PM
A live log monitor script ? ifm Linux - Software 1 07-19-2002 02:54 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration