Quote:
Originally Posted by blowtorch
Hey guys,
I'm writing a monitoring program that reads the pattern and the max and min number of instances of a process and then proceeds to parse the currently running processes for the pattern.
Parse the process? Do you mean the cmdline that started the process ?
Quote:
Originally Posted by blowtorch
2. read the process info file to build a list of the process pattern, min number and max number of instances and the rate of scanning for the pattern (in minutes).
3. loop forever and compare the processes in the list to the currently running processes and throw the appropriate alerts (or whatever)
It is point #3 that has me a bit confused. Should I read the /proc into another list, loop for each process pattern in the original list over the proc list? Or should I not read the /proc into a list at all, and just iterate over the list and read the /proc everytime (considering that /proc is in memory, that shouldn't take too much time either).
Keep a tab on the pids, i.e. maintain a list (best would hashtable).
If you iterate through /proc always, you might parse some long running processes again and again.
- For each iteration on the list, you can figure out the process is still running or not. If no ,then remove the entry. If yes, go ahead with your processing. And retain the entry. I dont think you want to raise an alert for the same process again and again.
For the next iteration against /proc, collect the new pids only. The old ones are the ones you processed already.
Quote:
Originally Posted by blowtorch
Currently the OSes that should work are Solaris and Linux as I have easy access to both, I will probably extend this to HP-UX later.
I thought Solaris did not have the /proc file system. Hmm..