Hi all,
Damian Krzeminski wrote:
http://track.sipfoundry.org/browse/XCF-2348
I was thinking we could get even better though:
- as Scott suggested in his e-mail
(http://thread.gmane.org/gmane.comp.voip.sipx.devel/8351/focus=8661) the
wrapper script should not be started by sipXconfig but by our process
manager. You can probably check what he has done for callresolver-agent
integration (all it requires is a that sipxconfig-mrtg RPM installs a
proecess descriptor in /etc/sipxpbx/process.d there are many examples
there. I think if you do that, the init script might be much simpler (or
not needed at all) since it would not have to do everything that
watchdog is doing already (for example dealing with PID files).
I have a problem doing what Damian described here. I tried following the
examples at /etc/sipxpbx/process.d to create a new process descriptor,
but I can't seem to get it right.
Here's what I've done:
First I tried to run mrtg without a wrapper script, but this didn't seem
to works, since mrtg didn't want to start in a normal environment (it
needs env LANG=C) and if
I provide env LANG=C to the watchdog command, it doesn't work.
Then, I created a real simple wrapper script (attached to this mail,
sipxbridge.sh was my source of inspiration),
and the watchdog starts mrtg successfully, but I get failure e-mails and
errors in sipxsupervisor.log
Mrtg is up and running:
ps aux | grep mrtg
andrei 21079 0.0 0.9 12588 10088 ? Ss 16:51 0:00
/usr/bin/perl -w /usr/bin/mrtg --user andrei --group andrei
/home/andrei/work/git-work/git-BUILD/../git-installed-sipx/etc/sipxpbx/mrtg/mrtg.cfg
--lock-file
/home/andrei/work/git-work/git-BUILD/../git-installed-sipx/etc/sipxpbx/mrtg/mrtg.cfg.l
--confcache-file
/home/andrei/work/git-work/git-BUILD/../git-installed-sipx/etc/sipxpbx/mrtg/mrtg.cfg.ok
--pid-file
/home/andrei/work/git-work/git-BUILD/../git-installed-sipx/var/run/sipxpbx/sipx-mrtg.pid
the pid file is ok:
cat ./var/run/sipxpbx/sipx-mrtg.pid
21079
and ./etc/init.d/sipxpbx status returns:
Checking sipx-mrtg: [ OK ]
I keep getting this in sipxsupervisor.log:
"2008-06-12T14:11:45.997825Z":36:PROCESSMGR:ERR:andrein.itcnetworks.ro::B740DB90:WatchDog:"OsProcessMgr::getAliasState
'Mrtg' DOES NOT HAVE a valid PID"
"2008-06-12T14:11:45.998002Z":37:WATCHDOG:WARNING:andrein.itcnetworks.ro::B740DB90:WatchDog:"Process
Mrtg found in non-running state. (Waiting for it to start)."
"2008-06-12T14:11:50.998267Z":38:WATCHDOG:WARNING:andrein.itcnetworks.ro::B740DB90:WatchDog:"Process
Mrtg found in non-running state (it was in STARTING state for more than
5 seconds)."
"2008-06-12T14:11:50.999495Z":39:WATCHDOG:NOTICE:andrein.itcnetworks.ro::B740DB90:WatchDog:"Process
Mrtg [started]"
and after some time, I get this:
"2008-06-12T12:32:48.946567Z":45:PROCESSMGR:ERR:andrein.itcnetworks.ro:HttpConnection-5:B7237B90:WatchDog:"OsProcessMgr::getProcessByAlias
non-integer pid 'FAILED' for alias 'Mrtg'"
and lost os these:
"2008-06-12T11:52:49.232576Z":81:PROCESSMGR:ERR:andrein.itcnetworks.ro::B7429B90:WatchDog:"OsProcessMgr::getProcessByAlias
non-integer pid 'FAILED' for alias 'Mrtg'"
I'm guessing the second and third is because sipXconfig asks
sipXsupervisor to stop Mrtg (that's the way I made it).
I think that when sipxsupervisor tries to restart mrtg, mrtg does not
start because 2 mrtg processes cannot use the same cfg file, so the
second one does not start.
Anyway, afterwards, when I do ./etc/init.d/sipxpbx stop, i get:
sudo ./etc/init.d/sipxpbx stop
Stopping apache:
Stopping sipXpbx:
[...]
Stopping: sipxcallresolver-agent (Not started)
Stopping: sipxcallresolver
Stopping: sipxconfig
Stopping: sipx-mrtg
[...]
Confirm Stop: sipxcallresolver-agent (Not started) [ OK ]
Confirm Stop: sipxcallresolver [ OK ]
Confirm Stop: sipxconfig [ OK ]
Confirm Stop: sipx-mrtg (Not started) [ OK ]
And it actually stops mrtg. (no more mrtg process)
You can find attached the start-up script and the process.xml file, both
in .in form.
@MRTG_BINARY@ should point to /usr/bin/mrtg
So ... what am I doing wrong? Is there anything else I should do?
Thanks in advance,
Andrei
p.s. there's something else that's strange. After mrtg starts running,
it appears that two processes are starting up:
[EMAIL PROTECTED] git-installed-sipx]$ cat ./var/run/sipxpbx/sipx-mrtg.pid
cat: ./var/run/sipxpbx/sipx-mrtg.pid: No such file or directory
[EMAIL PROTECTED] git-installed-sipx]$ date && ps aux | grep mrtg
Thu Jun 12 17:22:15 EEST 2008
andrei 3270 12.0 0.7 9632 7644 pts/10 R 17:22 0:00
/usr/bin/perl -w /usr/bin/mrtg --user andrei --group andrei
/home/andrei/work/git-work/git-BUILD/../git-installed-sipx/etc/sipxpbx/mrtg/mrtg.cfg
--lock-file
/home/andrei/work/git-work/git-BUILD/../git-installed-sipx/etc/sipxpbx/mrtg/mrtg.cfg.l
--confcache-file
/home/andrei/work/git-work/git-BUILD/../git-installed-sipx/etc/sipxpbx/mrtg/mrtg.cfg.ok
--pid-file
/home/andrei/work/git-work/git-BUILD/../git-installed-sipx/var/run/sipxpbx/sipx-mrtg.pid
andrei 3866 0.0 0.0 4008 728 pts/10 S+ 17:22 0:00 grep mrtg
[EMAIL PROTECTED] git-installed-sipx]$ cat ./var/run/sipxpbx/sipx-mrtg.pid
3998
[EMAIL PROTECTED] git-installed-sipx]$ date && ps aux | grep mrtg
Thu Jun 12 17:22:21 EEST 2008
andrei 3998 0.0 0.9 12588 10088 ? Ss 17:22 0:00
/usr/bin/perl -w /usr/bin/mrtg --user andrei --group andrei
/home/andrei/work/git-work/git-BUILD/../git-installed-sipx/etc/sipxpbx/mrtg/mrtg.cfg
--lock-file
/home/andrei/work/git-work/git-BUILD/../git-installed-sipx/etc/sipxpbx/mrtg/mrtg.cfg.l
--confcache-file
/home/andrei/work/git-work/git-BUILD/../git-installed-sipx/etc/sipxpbx/mrtg/mrtg.cfg.ok
--pid-file
/home/andrei/work/git-work/git-BUILD/../git-installed-sipx/var/run/sipxpbx/sipx-mrtg.pid
andrei 4066 0.0 0.0 4004 716 pts/10 S+ 17:22 0:00 grep mrtg
but this isn't correlated with watchdog restarting mrtg:
[snip]
"2008-06-12T14:22:12.931539Z":17:WATCHDOG:NOTICE:andrein.itcnetworks.ro::B73F2B90:WatchDog:"Process
Mrtg [started]"
"2008-06-12T14:22:26.910878Z":30:PROCESSMGR:ERR:andrein.itcnetworks.ro::B73F2B90:WatchDog:"OsProcessMgr::getAliasState
'Mrtg' DOES NOT HAVE a valid PID"
"2008-06-12T14:22:26.910897Z":31:WATCHDOG:NOTICE:andrein.itcnetworks.ro::B73F2B90:WatchDog:"Process
Mrtg state changed: NEVERRUN --> STARTING"
"2008-06-12T14:22:26.910916Z":32:WATCHDOG:WARNING:andrein.itcnetworks.ro::B73F2B90:WatchDog:"Process
Mrtg found in non-running state. (Waiting for it to start)."
"2008-06-12T14:22:31.911169Z":33:WATCHDOG:WARNING:andrein.itcnetworks.ro::B73F2B90:WatchDog:"Process
Mrtg found in non-running state (it was in STARTING state for more than
5 seconds)."
"2008-06-12T14:22:31.912736Z":34:WATCHDOG:NOTICE:andrein.itcnetworks.ro::B73F2B90:WatchDog:"Process
Mrtg [started]"
[...]
<?xml version="1.0"?>
<watchdog-process enable="true" xmlns="http://www.sipfoundry.org/sipX/schema/xml/watchdogprocess-00-01">
<process_definitions>
<group name="CommServer" >
<process name="Mrtg">
<dependentdelay wait="0" />
<stdout file="/dev/null" />
<stderr file="/dev/null" />
<stdin file="" />
<start control="true">
<execute command="@bindir@/sipx-mrtg"/>
</start>
<stop control="true" />
<restart control="true" />
</process>
</group>
</process_definitions>
<watchdog>
<monitor>
<monitor-process name="Mrtg" restart="enable" max_restarts="3" report="enable" max_reports="3">
<failure_contact method="email">@SIPXPBXUSER@@localhost</failure_contact>
</monitor-process>
</monitor>
</watchdog>
</watchdog-process>
[EMAIL PROTECTED]@
#
# Copyright (C) 2007 Pingtel Corp., certain elements licensed under a
Contributor Agreement.
# Contributors retain copyright to elements licensed under a Contributor
Agreement.
# Licensed to the User under the LGPL license.
Action=RUN
Status=0
Args=""
while [ $# -ne 0 ]
do
case ${1} in
--configtest)
Action=CONFIGTEST
;;
*)
Args="$Args $1"
;;
esac
shift # always consume 1
done
[EMAIL PROTECTED]@
[EMAIL PROTECTED]@
[EMAIL PROTECTED]@
[EMAIL PROTECTED]@
[EMAIL PROTECTED]@
MRTG_CONFIG_FILE="$SIPX_CONFDIR/mrtg/mrtg.cfg"
MRTG_PID_FILE="$SIPX_RUNDIR/sipx-mrtg.pid"
[EMAIL PROTECTED]@
MRTG_COMMAND="env LANG=C LC_ALL=C $MRTG_BIN --user $SIPXPBXUSER --group
$SIPXPBXGROUP $MRTG_CONFIG_FILE --lock-file $MRTG_CONFIG_FILE.l
--confcache-file $MRTG_CONFIG_FILE.ok --pid-file $MRTG_PID_FILE"
case ${Action} in
RUN)
#echo $$ > $MRTG_PID_FILE
exec $MRTG_COMMAND
;;
CONFIGTEST)
Status=0
# check mrtg.cfg?
;;
esac
exit $Status
_______________________________________________
sipx-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-dev
Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev