I wonder if it's an escaping problem. It's the kill command that isn't
happy. Have considered creating two scripts:

start-poly.sh
stop-poly.sh
-----------------------------
#!/bin/bash

pidtokill=$(ps aux | grep "[p]ython poll.py" | awk "{print $2}")

if [ "$pidtokill" == "" ]; then
    echo "Failed to find the poll.py pid"
    exit 1
fi

kill $pidtokill
exit 0
-----------------------------

and then using that in your start/stop program? I could see you losing the
\$2. Another option is to try \\$2.

Russ

On Wed, Nov 12, 2014 at 7:18 AM, Roman Kournjaev <[email protected]>
wrote:

>
>
> Hi
> I have upgraded to monit 5.10 yesterday and most of my startup scripts
> that monit was monitoring stopped working.
>
> Thats an example script
> <https://raw.githubusercontent.com/Wondermall/chef-repo/master/site-cookbooks/wondermall/templates/default/main_loop.erb?token=ACkKqldeTOMSfmQGC_SSkG9EUcNwvVo_ks5UaxYAwA%3D%3D>
>  .
>
> So I started to patch things :
>
> check process main_loop
> matching "python poll.py"
>    start program = "/bin/bash -c 'cd /opt/wondermall-scrapers/code;
> /usr/bin/python poll.py &'" with timeout 60 seconds
>    stop program = "/bin/bash -c 'kill $(ps aux | grep "[p]ython poll.py"
> | awk "{print \$2}")'"
> if uptime > 1 hours then restart
>
>
> But the stop command also fails and I am getting the following mail back
> form monit :
>
>
> Monit alert main_loop at Tue, 11 Nov 2014 18:48:37 on
> full-scraper-dev-9d66.c.wondermall-dev.internal,
>
> failed to stop (exit status 123) -- /bin/bash:
> Usage:
>  kill [options] <pid> [...]
>
> Options:
>  <pid> [...]            send signal to every <pid> listed
>  -<signal>, -s, --signal <signal>
>                         specify the <signal> to be sent
>  -l, --list=[<signal>]  list all signal names, or
>
> Dutifully,
> Monit
> --
>
>
> Of course that works when executing in simple bash , someone know what I
> am doing wrong ?
>
>
> Thanks
>
> Roman
>
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
>
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Reply via email to