email handler keep sending email even after the client service recovered from crash

I use mysql-alive.rb (https://github.com/sensu/sensu-community-plugins/blob/master/plugins/mysql/mysql-alive.rb) for mysql status checking. using mail (mail -s ‘mysql’s down’ email-address < /var/log/mysql/error.log) command as a handler to send email to my post.
Everything goes well when the mysql service runs on the sensu client server. Once I stop the mysql service on the client, my post can keep recieve emails. Sounds it works pretty well, right? :slight_smile:

But !!!

When I restart the mysql service (use sudo service mysql restart), the emails suppose not to be send any more. While, on the contrary, my post still can recieve warning emails after I restart the mysql service.
I’ve checked the sensu-server log, the check results are OK, and there is no events in Uchiwa.

Guys, how could the happen???

You need to use mailer (https://github.com/sensu/sensu-community-plugins/blob/9a326d73b52bf5900444d9a46cb3f6006ae0aae5/handlers/notification/mailer.rb) or any similar class that extends sensu-plugin, instead of the mail command.

···

On Thursday, 5 March 2015 19:53:15 UTC+11, Timothy John wrote:

I use mysql-alive.rb (https://github.com/sensu/sensu-community-plugins/blob/master/plugins/mysql/mysql-alive.rb) for mysql status checking. using mail (mail -s ‘mysql’s down’ email-address < /var/log/mysql/error.log) command as a handler to send email to my post.
Everything goes well when the mysql service runs on the sensu client server. Once I stop the mysql service on the client, my post can keep recieve emails. Sounds it works pretty well, right? :slight_smile:

But !!!

When I restart the mysql service (use sudo service mysql restart), the emails suppose not to be send any more. While, on the contrary, my post still can recieve warning emails after I restart the mysql service.
I’ve checked the sensu-server log, the check results are OK, and there is no events in Uchiwa.

Guys, how could the happen???

Thanks for your reply, Anthony. But I still wondered why does the using of plain mail command would led to such a result?

在 2015年3月5日星期四 UTC+8下午8:04:00,Anthony Kong写道:

···

You need to use mailer (https://github.com/sensu/sensu-community-plugins/blob/9a326d73b52bf5900444d9a46cb3f6006ae0aae5/handlers/notification/mailer.rb) or any similar class that extends sensu-plugin, instead of the mail command.

On Thursday, 5 March 2015 19:53:15 UTC+11, Timothy John wrote:

I use mysql-alive.rb (https://github.com/sensu/sensu-community-plugins/blob/master/plugins/mysql/mysql-alive.rb) for mysql status checking. using mail (mail -s ‘mysql’s down’ email-address < /var/log/mysql/error.log) command as a handler to send email to my post.
Everything goes well when the mysql service runs on the sensu client server. Once I stop the mysql service on the client, my post can keep recieve emails. Sounds it works pretty well, right? :slight_smile:

But !!!

When I restart the mysql service (use sudo service mysql restart), the emails suppose not to be send any more. While, on the contrary, my post still can recieve warning emails after I restart the mysql service.
I’ve checked the sensu-server log, the check results are OK, and there is no events in Uchiwa.

Guys, how could the happen???

Because if you use mail directly, it will simply take the input (via pipe I presume it is how you define your handler) and work on it.

Ruby scripts that extends Sensu plugin, on the other hand, has some smart build into it. For example, it will talk to sensu api and respect parameters like occurrence.

Cheers, Tony

Thanks again! And have a good night!

在 2015年3月6日星期五 UTC+8上午9:51:45,Anthony Kong写道:

···

Because if you use mail directly, it will simply take the input (via pipe I presume it is how you define your handler) and work on it.

Ruby scripts that extends Sensu plugin, on the other hand, has some smart build into it. For example, it will talk to sensu api and respect parameters like occurrence.

Cheers, Tony