Sponsored Content
Operating Systems Linux Need advice on coding a daemon Post 302308924 by Corona688 on Monday 20th of April 2009 03:51:00 PM
Old 04-20-2009
Quote:
Originally Posted by Housni
I hope this is the right forum to post this.

I need a little advice on something.

I want to create a daemon to run on a Linux server and this daemon should:
1. capture the `./configure` command so that it knows where a program installed via source would store it's binaries and, most importantly, configuration files.
  • You can't just arbitrarily capture the output of random programs named z. It's not impossible to attach to existing processes but that's almost never done except for debugging purposes.
  • ./configure is usually told where to install things rather than vice versa.
  • ./configure is heavily customizable, meaning, its output can be unpredictably different from package to package. You'd have to write a script of some sort for every kind of program, and then you'd just be rewriting gentoo.
  • Programs store their config files wherever they please, sometimes with no regard to documentation or ./configure settings. I've occasionally had to strace things to figure out just where they wanted files to be!
Quote:
2. somehow capture package manager activity so that it knows where the programs binaries and configuration files are.
Depends on your package manager.
Quote:
3. detect when a service is started or stopped or restarted...basically, detect the change in status of a service. How does Linux know when a service is triggered? Is a /proc file or something like that triggered?
Linux often tracks services through PID files. When a program is run it creates a file contaning its integer PID; when it quits or dies, it deletes this file. Further details depends on what startup manager you're using.
Quote:
Would a daemon coded in Python work here? Also, what are the best options to capture a commands activity? strace? gdb?
strace works, but has a high performance cost. gdb might be cudgeled into working but isn't really suited to it, and would have an even higher performance cost. I think you need to rethink your system here.
Quote:
My aim is to basically make a little program that self documents so that, for example, if an admin decides to install the latest PHP on a web server, compiled from source since the package manager doesn't have the latest version, my program should save that information to a file somewhere.
If you don't want admins installing things or starting/stopping services without supervision, why are they admins? Instead of writing a giant omniscient daemon with its tentacles hacked into every aspect of the system, just restrict them from doing things you don't want in the first place. You can use sudo to grant admin access for only very specific things in very specific ways, so that to install something or stop a service, they have to run your program instead of the system one...

Last edited by Corona688; 04-20-2009 at 04:57 PM..
 

6 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

can I use this coding

I apologise because I had pasted this question in the newbies forum first (because i am a bit of a newbie) but thought it might be better suited in here if i have to sepearate parameters can I use this syntax especially the or part (||) and is this correct if (6 Replies)
Discussion started by: w33man
6 Replies

2. UNIX for Dummies Questions & Answers

pro*c coding

Hi All, I am new to pro*C. I have a select statement as select a.ename,a.sal,a.empno from emp where &n=(select count(distinct(b.sal)) from emp b where a.sal<=b.sal for this query I have to write a pro*C program. So can you please send me the complete code. Then I will foloow the same... (1 Reply)
Discussion started by: user71408
1 Replies

3. Programming

Help for coding this programme

for a floating-point array x whose size is n, find the geometric mean.. GM =n x1.x2.x3...xn (2 Replies)
Discussion started by: allyjaah
2 Replies

4. Shell Programming and Scripting

Coding in Phyton

I have the following Phyton script and want to print something if the option was selected For example if the user uses --npop=12, I want to check if the user has inputted --npop and do if npop selected, print npop Or if the user puts --fdata=npt02.dat I print something like if fdata... (3 Replies)
Discussion started by: kristinu
3 Replies

5. Shell Programming and Scripting

Need help with coding

HI, Can some one guide me how to make changes to the script below so that it can load the history of a program to IT server ? Format of data: YYYYMMDD065959.dsk.log YYYYMMDD235959.dsk.log currently both are loaded together. Need to separate them as above format. Thanks in advance. ... (1 Reply)
Discussion started by: crazydude80
1 Replies

6. Windows & DOS: Issues & Discussions

Need help with coding

HI, Can some one guide me how to make changes to the script below so that it can load the history of a program to IT server ? Format of data: YYYYMMDD065959.dsk.log YYYYMMDD235959.dsk.log currently both are loaded together. Need to separate them as above format. Thanks in advance. ... (2 Replies)
Discussion started by: crazydude80
2 Replies
All times are GMT -4. The time now is 10:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy