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...