On Thursday 31 July 2008 10:54 am, Dimitri Yioulos wrote:
> On Thursday 31 July 2008 9:55 am, Pierrick Grasland wrote:
> > Hello,
> >
> > I hope to correctly understand your problem :
> >
> > *executing a script after mysql restart.*
> >
> > So, my first solution is below :
> > >From the manual :
> >
> > ***IF CHANGED [MD5|SHA1] CHECKSUM [[<X>] <Y> CYCLES]
> > THEN action*
> >
> > or
> >
> > ***IF CHANGED TIMESTAMP [[<X>] <Y> CYCLES] THEN action*
> >
> >
> > I think you can adapted this as follow :
> >
> > check file mysqlpidfile path <path of pidfile>
> > if changed sha1 checksum
> > then exec "mysqlreload.sh"
> >
> >
> > Add a simple :
> >
> > check process mysql with pidfile mysqlpidfile
> > start = "..."
> > stop = "..."
> >
> > And I think you have it.
> >
> > (when mysql restart, it will have a new pid, so a different checksum or
> > timestamp
> >
> > I'm not sure of the syntax (can't test), but I think it will work.
> >
> > Regards,
> >
> >
> > --
> > Pierrick Grasland
>
> Pierrick,
>
> Thank you so much!
>
> Not having a lot of experience creating monit directives, I'm not sure
> exactly what to do with the directives you've shown me. To accomplish what
> I want to do, would my directives look like this?:
>
> check process mysqld with pidfile /var/lib/mysql/brockton.pid
> start program = "/etc/rc.d/init.d/mysql start"
> stop program = "/etc/rc.d/init.d/mysql stop"
> if failed host
192.168.100.7 port 3306 type TCP then restart
> if 5 restarts within 5 cycles then timeout
>
> check file /var/lib/mysqld/brockton.pid
> if changed sha1 checksum
> then exec "mysql test1 < /root/restart.sql"
>
> If so, when I try to start monit, I get the follwing error:
>
> Starting monit: /etc/monitrc:216: Error: syntax error 'if'
> [FAILED]
>
> Where am I going wrong?
>
> Dimitri