Re: Monitor mysql data directory

From: Gabe <holmegab_at_gmail.com>
Date: Sat, 13 Jun 2009 17:43:01 -0400

Well, I found out that I don't have the latest bleeding edge Fedora
kernel! I'll have to talk to my hosting company. If anyone knows how to
patch my kernel for inotify, please IM me...

Lukas Jelinek wrote:
> Hi,
> I tried to use incron for monitoring MySQL database changes and
> encountered these facts:
> 1. If I use a system table (/etc/incron.d/...) or an user table
> (natively under "root" or "mysql") it works as expected. I tested it
> both for MyISAM and InnoDB.
> 2 If I use incrontab -u it causes segfault. But this is a reported bug
> with an existing patch (#0000187). The only problem is that I haven't
> released the appropriate bugfix version yet.
>
> You can try the following solution:
> 1. Create a system table for the event.
> 2. Write a script which drops root privileges first (in other words,
> switches to a regular user such as "mysql") and then does what you want.
>
> Please report whether it succeeds. Thanks.
>
> Lukas
>
>> Hi everyone,
>>
>> I'm trying to set up a system where a php script is fired whenever a
>> mysql table is updated and I'm wondering if anyone has had any luck
>> doing anything similar. (In case you're wondering why: a client needs
>> an api call made to ebay whenever an inventory table is updated. He
>> is trying to do multi-channel sales and doesn't want to adjust stock
>> manually in each channel).
>> I considered using a MySQL UDF but decided against it since the only
>> one that could call an external script is sys_exec, and even the
>> author of that recommends against using it because it's a security
>> hazard.
>> Leaving aside the issue that incrontab is also a security hazard...
>>
>> I want to know if anyone's had any luck setting up incron jobs that
>> monitor the mysql data directory. I set up an incrontab for mysql and
>> inserted
>>
>> /path/to/datadirectory/dbname/tablename.MYD IN_MODIFY /path/to/php
>> /path/to/script.php
>>
>> "Script.php" is a hello world type script that sends me an email, and
>> I checked that it works "on its own".
>>
>>
>> After reading that a backslash needed to be added to escape the space
>> in the command I changed it to:
>>
>>
>> /path/to/datadirectory/dbname/tablename.MYD IN_MODIFY /path/to/php\
>> /path/to/script.php
>>
>> I switched to root, and then I reloaded as the mysql user using
>> incrontab -u mysql -d. I updated the table, still no dice. I checked
>> that the ".MYD" file had in fact been modified. No luck.
>>
>> I'm stumped.
>>
>> Has anyone here played around with this sort of thing and had any
>> success?
>>
>> Thanks in advance,
>>
>> Gabe
>> Salisbury MD
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
>
>
Received on Tue Jun 05 2012 - 22:14:21 CEST

This archive was generated by hypermail 2.2.0 : Tue Jun 05 2012 - 22:14:21 CEST