[mrtg] Re: Daemons and Forks

Brian E. Seppanen seppy at chartermi.net
Thu Feb 22 15:48:32 MET 2001


I'm running Mrtg with linux and I'm having sort of a similar problem.  But
here's what might help you first.

First of all run everything out of one main config file using the Include
directive for each router device.  Then you only have one pid file to work
with.  We run every five minutes an mrtg check script that writes the
value of the pid to a variable and then does a process listing and looks
specifically for that ID.  If that pid isn't found it restarts mrtg.
With a single config all you need to do is kill the one parent and the
children die as well.  So just look for the parent id.

I do the following for my process listing
ps -eo pid,command --sort ppid | grep -v `cat /home/mrtg/main.pid` | grep -v grep

This puts the parent process ID at the top.

One problem I've run into is that when this script restarts mrtg from cron
it doesn't fork properly.  Even though my config specifies four forks, I
end up with four mrtg processes and no children forking off one parent.
They walk all over each other and nothing gets graphed.   Anyone found a
way around that?  This is killing me in two ways, my weekly backups and my
monitoring script.  Not to mention the slew of thresholds that are
tripped when this happens.  I'm running 2.9.4.

Hope that helps.

On Thu, 22 Feb 2001, Chris Marlow wrote:

>
>
> Well, I'm more of an AIX guy than a Linux guy, but here's what generally
> happens:
>
>      You look at the .pid file, and kill that parent process...
>      Sometimes (Depending on the program running), the children will
> realize their parents are dead, go into mourning, and die themselves.....
>      Sometimes, the children won't see their parents are dead, and stay up
> all night eating cookies and watching TV....
>
> Some suggestions as to what you can do:
>      If you want to kill all MRTG processes that are running, look at the
> process table, and do a search on "path to MRTG here".  Kill those
> processes
>      Conversly, if you want to just kill the childred of a parent, whose
> PID you have, the process table showes the PID for each process.  Using
> that, you can determine which children came from which parent.
>
> Let me know if you need me to get more detailed with the PERL coding
>
> Good luck, happy hunting,
>
> -Chris
>

Brian Seppanen
Charter Communications
Regional Data Center				906-228-4226 ext 23
Marquette, MI					seppy at chartermi.net



--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list