Banging my head to get mail working.

so installed sensu all working fine… only that I cant get alerts :frowning:
what I have:

I’m trying two ways… one with postifx localhost and another with aws “ses” (both tested! from outside sensu)

so I install the gem for

sensu-plugins-mailer

I put a .json config on /etc/sensu/conf.d/

called: plugin_mailer.json

and this is the content(obvialist i removed info)

{
“handlers”: {
“mailer”: {
“type”: “pipe”,
“command”: “/usr/local/bin/handler-mailer.rb”,
“admin_gui”: “http://sensu.mysite.com:3000/”,
“mail_from”: "sensu@mysite.com",
“mail_to”: "team@mysite.com",
“smtp_address”: “email-smtp.us-east-1.amazonaws.com”,
“smtp_port”: “587”,
“smtp_username”: “username aws SES amazon gived me”,
“smtp_password”: “password aws SES amazon gived me”,
“smtp_domain”: “mydomain.com
}
}

I see in the logs that is configure and no errors…

the second option is the same only that instead of adding username/password etc port is 25 smtp is localhost you get the idea

still since I cant see anything on the sensu-server.log only the json runs up like:

“timestamp”:“2016-03-11T04:37:43.008786+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/usr/local/bin/handler-mail
er.rb",“admin_gui”:“http://sensu.misite.com:3000/",“mail_from”:“sensu@site.com”,“mail_to”:“cfernandez@site.com”,“smtp_address”:"
email-smtp.us-east-1.amazonaws.com”,“smtp_port”:“587”,“smtp_username”:“username”,“smtp_password”:“here the pass”,“smtp_domain”:“domain.com”,“name”:“mailer”},“output”:[“only handling every 60 occurrences: my-instance-tcs4/check_disk_usage\n”]}

not much from that in the logs…

anyone can help please?

Thanks!

FYI: I just found this in the log… but not idea how to fix it:
“output”:["/var/lib/gems/1.9.1/gems/sensu-plugins-mailer-0.1.5/bin/handler-mailer.rb:116:in build_ body': undefined method’ for nil:NilClass (NoMethodError)\n","\tfrom /var/lib/gems/1.9.1/gems/sensu-plugins-mailer-0.1.5/bin/handler-mailer.rb:144:i
n handle'\n","\tfrom /var/lib/gems/1.9.1/gems/sensu-plugin-1.2.0/lib/sensu-handler.rb:55:inblock in class:Handler’\n"]}

``

···

El jueves, 10 de marzo de 2016, 20:41:15 (UTC-8), Christian Fernandez escribió:

so installed sensu all working fine… only that I cant get alerts :frowning:
what I have:

I’m trying two ways… one with postifx localhost and another with aws “ses” (both tested! from outside sensu)

so I install the gem for

sensu-plugins-mailer

I put a .json config on /etc/sensu/conf.d/

called: plugin_mailer.json

and this is the content(obvialist i removed info)

{
“handlers”: {
“mailer”: {
“type”: “pipe”,
“command”: “/usr/local/bin/handler-mailer.rb”,
“admin_gui”: “http://sensu.mysite.com:3000/”,
“mail_from”: "sensu@mysite.com",
“mail_to”: "team@mysite.com",
“smtp_address”: “email-smtp.us-east-1.amazonaws.com”,
“smtp_port”: “587”,
“smtp_username”: “username aws SES amazon gived me”,
“smtp_password”: “password aws SES amazon gived me”,
“smtp_domain”: “mydomain.com
}
}

I see in the logs that is configure and no errors…

the second option is the same only that instead of adding username/password etc port is 25 smtp is localhost you get the idea

still since I cant see anything on the sensu-server.log only the json runs up like:

“timestamp”:“2016-03-11T04:37:43.008786+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/usr/local/bin/handler-mail
er.rb",“admin_gui”:“http://sensu.misite.com:3000/",“mail_from”:"sensu@site.com",“mail_to”:"cfernandez@site.com”,“smtp_address”:"
email-smtp.us-east-1.amazonaws.com",“smtp_port”:“587”,“smtp_username”:“username”,“smtp_password”:“here the pass”,“smtp_domain”:“domain.com”,“name”:“mailer”},“output”:[“only handling every 60 occurrences: my-instance-tcs4/check_disk_usage\n”]}

not much from that in the logs…

anyone can help please?

Thanks!

I think I got bitten by this - if your handler is called “mailer”, then your json needs to be mailer.json.

In handler-mailer.rb is this note:

Note: The default mailer config is fetched from the predefined json config file which is “mailer.json” or any other

file defiend using the “json_config” command line option. The mailing list could also be configured on a per client basis

by defining the “mail_to” attribute in the client config file. This will override the default mailing list where the

alerts are being routed to for that particular client.

``

To use a different json, you have to pass it in with a -j

I have a specific config to mail me only - put in mailme.json

I create a handler config mailme_handler.json

{
“handlers”: {
“mail_me”: {
“type”: “pipe”,
“command”: “handler-mailer.rb -j mailme”
}
}

``

and mailme.json:

{
“mailme”: {
“admin_gui”: “http://sensu-server.example.com/:3000/”,
“mail_from”: "sensu@sensu-server.example.com",
“mail_to”: [“me@example.com”],
“smtp_port”: “25”,
“smtp_domain”: “example.com
}
}

``

The critical thing I found, was that the name inside the json file had to match the name of the json file passed to the handler-mailer.rb itself. So, in your case I think it would need to be plugin_mailer.

Cheers,

Joel

···

On Friday, 11 March 2016 04:41:15 UTC, Christian Fernandez wrote:

so installed sensu all working fine… only that I cant get alerts :frowning:
what I have:

I’m trying two ways… one with postifx localhost and another with aws “ses” (both tested! from outside sensu)

so I install the gem for

sensu-plugins-mailer

I put a .json config on /etc/sensu/conf.d/

called: plugin_mailer.json

and this is the content(obvialist i removed info)

{
“handlers”: {
“mailer”: {
“type”: “pipe”,
“command”: “/usr/local/bin/handler-mailer.rb”,
“admin_gui”: “http://sensu.mysite.com:3000/”,
“mail_from”: "se...@mysite.com",
“mail_to”: "te...@mysite.com",
“smtp_address”: “email-smtp.us-east-1.amazonaws.com”,
“smtp_port”: “587”,
“smtp_username”: “username aws SES amazon gived me”,
“smtp_password”: “password aws SES amazon gived me”,
“smtp_domain”: “mydomain.com
}
}

I see in the logs that is configure and no errors…

the second option is the same only that instead of adding username/password etc port is 25 smtp is localhost you get the idea

still since I cant see anything on the sensu-server.log only the json runs up like:

“timestamp”:“2016-03-11T04:37:43.008786+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/usr/local/bin/handler-mail
er.rb",“admin_gui”:“http://sensu.misite.com:3000/",“mail_from”:"se...@site.com",“mail_to”:"cfern...@site.com”,“smtp_address”:"
email-smtp.us-east-1.amazonaws.com",“smtp_port”:“587”,“smtp_username”:“username”,“smtp_password”:“here the pass”,“smtp_domain”:“domain.com”,“name”:“mailer”},“output”:[“only handling every 60 occurrences: my-instance-tcs4/check_disk_usage\n”]}

not much from that in the logs…

anyone can help please?

Thanks!

It looks like you are using the system ruby, and not the native sensu one. Is that intentional?

I recommend using the sensu-install tool to install plugins using the Sensu ruby:

https://sensuapp.org/docs/0.26/reference/plugins.html#installing-sensu-plugins

That way they get a #! that points to it, and not the system ruby.

···

On Thu, Oct 20, 2016 at 1:29 AM, Siddharth Jagtiani jsiddharth@mcruiseon.com wrote:

I have
handler-mailer.rb -j mailme_using_amazonses

in my config.json

and handler-mailer.rb is in my /etc/sensu/plugins folder

When I run on command line, I get errors

ruby /etc/sensu/plugins/handler-mailer.rb -j mailme_using_amazonses

/var/lib/gems/1.9.1/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:230:in `parse_options’: invalid option: -j (OptionParser::InvalidOption)

from /var/lib/gems/1.9.1/gems/sensu-plugin-1.4.3/lib/sensu-handler.rb:18:in `initialize’

from /var/lib/gems/1.9.1/gems/sensu-plugin-1.4.3/lib/sensu-handler.rb:78:in `new’

from /var/lib/gems/1.9.1/gems/sensu-plugin-1.4.3/lib/sensu-handler.rb:78:in `block in class:Handler

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require’: cannot load such file – erubis (LoadError)

from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require’

from /etc/sensu/plugins/handler-mailer.rb:20:in `’

My mailme_using_amazonses has the following

{

“handlers”: {

“mailer-ses”: {

“mail_from”: "from@example.com",

“mail_to”: "to@example.com",

“use_ami_role”: true,

“secret_key”: “MyKey”,

“access_key”: “MyAccess”,

“region”: “us-west-2”

}

}

}

What am I missing here ?

On Friday, March 11, 2016 at 10:11:15 AM UTC+5:30, Christian Fernandez wrote:

so installed sensu all working fine… only that I cant get alerts :frowning:
what I have:

I’m trying two ways… one with postifx localhost and another with aws “ses” (both tested! from outside sensu)

so I install the gem for

sensu-plugins-mailer

I put a .json config on /etc/sensu/conf.d/

called: plugin_mailer.json

and this is the content(obvialist i removed info)

{
“handlers”: {
“mailer”: {
“type”: “pipe”,
“command”: “/usr/local/bin/handler-mailer.rb”,
“admin_gui”: “http://sensu.mysite.com:3000/”,
“mail_from”: "se...@mysite.com",
“mail_to”: "te...@mysite.com",
“smtp_address”: “email-smtp.us-east-1.amazonaws.com”,
“smtp_port”: “587”,
“smtp_username”: “username aws SES amazon gived me”,
“smtp_password”: “password aws SES amazon gived me”,
“smtp_domain”: “mydomain.com
}
}

I see in the logs that is configure and no errors…

the second option is the same only that instead of adding username/password etc port is 25 smtp is localhost you get the idea

still since I cant see anything on the sensu-server.log only the json runs up like:

“timestamp”:“2016-03-11T04:37:43.008786+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/usr/local/bin/handler-mail
er.rb",“admin_gui”:“http://sensu.misite.com:3000/",“mail_from”:"se...@site.com",“mail_to”:"cfern...@site.com”,“smtp_address”:"
email-smtp.us-east-1.amazonaws.com",“smtp_port”:“587”,“smtp_username”:“username”,“smtp_password”:“here the pass”,“smtp_domain”:“domain.com”,“name”:“mailer”},“output”:[“only handling every 60 occurrences: my-instance-tcs4/check_disk_usage\n”]}

not much from that in the logs…

anyone can help please?

Thanks!

Look at the code for your mailer.rb file, I believe one of the later updated ones require you to pass in the mailer with the -j flag:

“command”: "/usr/local/bin/handler-mailer.rb -j ",

···

On Thursday, March 10, 2016 at 11:41:15 PM UTC-5, Christian Fernandez wrote:

so installed sensu all working fine… only that I cant get alerts :frowning:
what I have:

I’m trying two ways… one with postifx localhost and another with aws “ses” (both tested! from outside sensu)

so I install the gem for

sensu-plugins-mailer

I put a .json config on /etc/sensu/conf.d/

called: plugin_mailer.json

and this is the content(obvialist i removed info)

{
“handlers”: {
“mailer”: {
“type”: “pipe”,
“command”: “/usr/local/bin/handler-mailer.rb”,
“admin_gui”: “http://sensu.mysite.com:3000/”,
“mail_from”: "se...@mysite.com",
“mail_to”: "te...@mysite.com",
“smtp_address”: “email-smtp.us-east-1.amazonaws.com”,
“smtp_port”: “587”,
“smtp_username”: “username aws SES amazon gived me”,
“smtp_password”: “password aws SES amazon gived me”,
“smtp_domain”: “mydomain.com
}
}

I see in the logs that is configure and no errors…

the second option is the same only that instead of adding username/password etc port is 25 smtp is localhost you get the idea

still since I cant see anything on the sensu-server.log only the json runs up like:

“timestamp”:“2016-03-11T04:37:43.008786+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/usr/local/bin/handler-mail
er.rb",“admin_gui”:“http://sensu.misite.com:3000/",“mail_from”:"se...@site.com",“mail_to”:"cfern...@site.com”,“smtp_address”:"
email-smtp.us-east-1.amazonaws.com",“smtp_port”:“587”,“smtp_username”:“username”,“smtp_password”:“here the pass”,“smtp_domain”:“domain.com”,“name”:“mailer”},“output”:[“only handling every 60 occurrences: my-instance-tcs4/check_disk_usage\n”]}

not much from that in the logs…

anyone can help please?

Thanks!

Hi
I’ve got it configured like this:

/etc/sensu/conf.d/handlers/handler-mail.json

{
“handlers”: {
“email-me”: {
“type”: “pipe”,
“severities”: [
“warning”,
“critical”,
“unknown”,
“ok”
],
“command”: “handler-mailer.rb -j mailme”
}
}
}

/etc/sensu/conf.d/handlers
cat mailme.json
{
“mailme”: {
“mail_from”: “sensu@server”,
“mail_to”: "me@xxxx.com",
“smtp_port”: “25”,
“smtp_address”: “mail.server.com”,
“smtp_domain”: “server.com
}
}

Example check:

{
“checks”: {
“ES-Heap-Size”: {
“command”: “check-es-heap.rb -h server -w 4194304 -c 5242880”,
“subscribers”: [
“elastic”
],
“interval”: 60,
“auto_resolve”: true,
“type”: “standard”,
“occurrences”: 3,
“refresh”: 60 ,/default value/
“handlers”: [“email-me”]*
}
}
}

That works for me, hope it helps
Regards

···

El viernes, 11 de marzo de 2016, 1:41:15 (UTC-3), Christian Fernandez escribió:

so installed sensu all working fine… only that I cant get alerts :frowning:
what I have:

I’m trying two ways… one with postifx localhost and another with aws “ses” (both tested! from outside sensu)

so I install the gem for

sensu-plugins-mailer

I put a .json config on /etc/sensu/conf.d/

called: plugin_mailer.json

and this is the content(obvialist i removed info)

{
“handlers”: {
“mailer”: {
“type”: “pipe”,
“command”: “/usr/local/bin/handler-mailer.rb”,
“admin_gui”: “http://sensu.mysite.com:3000/”,
“mail_from”: "se...@mysite.com",
“mail_to”: "te...@mysite.com",
“smtp_address”: “email-smtp.us-east-1.amazonaws.com”,
“smtp_port”: “587”,
“smtp_username”: “username aws SES amazon gived me”,
“smtp_password”: “password aws SES amazon gived me”,
“smtp_domain”: “mydomain.com
}
}

I see in the logs that is configure and no errors…

the second option is the same only that instead of adding username/password etc port is 25 smtp is localhost you get the idea

still since I cant see anything on the sensu-server.log only the json runs up like:

“timestamp”:“2016-03-11T04:37:43.008786+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/usr/local/bin/handler-mail
er.rb",“admin_gui”:“http://sensu.misite.com:3000/",“mail_from”:"se...@site.com",“mail_to”:"cfern...@site.com”,“smtp_address”:"
email-smtp.us-east-1.amazonaws.com",“smtp_port”:“587”,“smtp_username”:“username”,“smtp_password”:“here the pass”,“smtp_domain”:“domain.com”,“name”:“mailer”},“output”:[“only handling every 60 occurrences: my-instance-tcs4/check_disk_usage\n”]}

not much from that in the logs…

anyone can help please?

Thanks!

Can someone please help me ?

I try to do the same but no result :frowning:

In doc file I added :

RUN sensu-install -P sensu-plugins-mailer

ADD etc/ /etc/
ADD opt/ /opt/



Than I created file in \etc\sensu\conf.d\mail_settings.json

{
“mail_settings”: {
“mail_from”: “",
“mail_to”: "
",
“smtp_address”: "",
“smtp_port”: 25,
“smtp_domain”: "
******”
}
}

and in the same directory I created the next file handler_my_mailer.json

{
“handlers”: {
“my_mailer”: {
“type”: “pipe”,
“command”: “/opt/sensu/embedded/bin/handler-mailer.rb -j mail_settings”
}
}
}

And after it I add my_mailer as a handler to one check . As I result I wanted to get an email but nothing happened

I’m pretty sure that the mailer top level config needs to be “mailer” and not “mail_settings” in the top level. Also, the json_config command line option is to specify a file which contains the json settings, not the scope of the settings. If you change the file to be \etc\sensu\conf.d\mailer.json, then you can remove the json argument from the command in your handler.

Making both of these changes should allow e-mails to come through. Also, check out your sensu-server logs to see if there are any other issues with the configuration if you’re still not getting e-mails. It could be that the events are being filtered.

···

On Fri, Apr 21, 2017 at 10:50 AM, Tetiana Tetiana tacita2012@gmail.com wrote:

Can someone please help me ?

I try to do the same but no result :frowning:

In doc file I added :

RUN sensu-install -P sensu-plugins-mailer

ADD etc/ /etc/
ADD opt/ /opt/





Than I created file in \etc\sensu\conf.d\mail_settings.json

{
“mail_settings”: {
“mail_from”: “",
“mail_to”: "
",
“smtp_address”: "",
“smtp_port”: 25,
“smtp_domain”: "
******”
}
}

and in the same directory I created the next file handler_my_mailer.json

{
“handlers”: {
“my_mailer”: {
“type”: “pipe”,
“command”: “/opt/sensu/embedded/bin/handler-mailer.rb -j mail_settings”
}
}
}

And after it I add my_mailer as a handler to one check . As I result I wanted to get an email but nothing happened

Steven Viola