Formatting sensu emails


#1

is there a way to format sensu emails to only receive certain parts?

Right now im getting this whole thing:

{“id”:“f5d4897c-1262-4488-b9bd-be0d95ec12fa”,“client”:{“name”:“compute-20.moc.ne.edu”,“address”:“129.10.3.20”,“bind”:“127.0.0.1”,“port”:“3030”,“subscriptions”:[“moc-sensu”],“safe_mode”:false,“keepalive”:{},“version”:“0.20.3”,“timestamp”:1457125387},“check”:{“handlers”:[“default”,“influxdb-cpu”,“idle-email”],“type”:“metric”,“command”:"/etc/sensu/plugins/cpu-pcnt-usage-metrics.rb -t 20",“subscribers”:[“moc-sensu”],“interval”:300,“handler”:“debug”,“name”:“cpu_pcnt_metrics”,“issued”:1457125402,“executed”:1457125403,“duration”:1.049,“output”:“critical\n”,“status”:2,“history”:[“0”,“0”,“0”,“2”,“2”,“2”,“2”,“2”,“0”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”],“total_state_change”:4},“occurrences”:12,“action”:“create”,“timestamp”:1457125403}

When all I really want is the client name, address and the output (critical)

Anyone know how to do this?

Thanks!


#2

It sounds like you are using a naive "mail" handler?

I recommend using the popular sensu-mailer rubygem to server as the
handler instead.

It has a --template option so you can get your erb on.

I can't find docs on installing this specific handler, but it is the
same as any other plugin:
https://sensuapp.org/docs/latest/getting-started-with-checks#check-cron-install-dependencies
Or I cover installing/configuring this handler in chapter 10 of
https://www.udemy.com/sensu-introduction/

···

On Mon, May 9, 2016 at 2:00 PM, <dmak1112@bu.edu> wrote:

is there a way to format sensu emails to only receive certain parts?

Right now im getting this whole thing:

{"id":"f5d4897c-1262-4488-b9bd-be0d95ec12fa","client":{"name":"compute-20.moc.ne.edu","address":"129.10.3.20","bind":"127.0.0.1","port":"3030","subscriptions":["moc-sensu"],"safe_mode":false,"keepalive":{},"version":"0.20.3","timestamp":1457125387},"check":{"handlers":["default","influxdb-cpu","idle-email"],"type":"metric","command":"/etc/sensu/plugins/cpu-pcnt-usage-metrics.rb
-t
20","subscribers":["moc-sensu"],"interval":300,"handler":"debug","name":"cpu_pcnt_metrics","issued":1457125402,"executed":1457125403,"duration":1.049,"output":"critical\n","status":2,"history":["0","0","0","2","2","2","2","2","0","2","2","2","2","2","2","2","2","2","2","2","2"],"total_state_change":4},"occurrences":12,"action":"create","timestamp":1457125403}

When all I really want is the client name, address and the output (critical)

Anyone know how to do this?

Thanks!


#3

Just watched your guide. It’s really helpful! Thank’s a lot.

I was just using mailx -s and now I am trying to use the mailer plugin.

The only question I have is about the stmp address and domain. I’m not too sure about what those mean. Do i have to set up an smtp server or something on my machine? My sensu server is on a VM that runs Rhel as its OS.

···

On Tuesday, May 10, 2016 at 10:48:17 AM UTC-4, Kyle Anderson wrote:

It sounds like you are using a naive “mail” handler?

I recommend using the popular sensu-mailer rubygem to server as the
handler instead.
https://github.com/sensu-plugins/sensu-plugins-mailer/blob/master/bin/handler-mailer.rb

It has a --template option so you can get your erb on.

I can’t find docs on installing this specific handler, but it is the
same as any other plugin:
https://sensuapp.org/docs/latest/getting-started-with-checks#check-cron-install-dependencies

Or I cover installing/configuring this handler in chapter 10 of
https://www.udemy.com/sensu-introduction/

On Mon, May 9, 2016 at 2:00 PM, dmak...@bu.edu wrote:

is there a way to format sensu emails to only receive certain parts?

Right now im getting this whole thing:

{“id”:“f5d4897c-1262-4488-b9bd-be0d95ec12fa”,“client”:{“name”:“compute-20.moc.ne.edu”,“address”:“129.10.3.20”,“bind”:“127.0.0.1”,“port”:“3030”,“subscriptions”:[“moc-sensu”],“safe_mode”:false,“keepalive”:{},“version”:“0.20.3”,“timestamp”:1457125387},“check”:{“handlers”:[“default”,“influxdb-cpu”,“idle-email”],“type”:“metric”,“command”:"/etc/sensu/plugins/cpu-pcnt-usage-metrics.rb
-t
20",“subscribers”:[“moc-sensu”],“interval”:300,“handler”:“debug”,“name”:“cpu_pcnt_metrics”,“issued”:1457125402,“executed”:1457125403,“duration”:1.049,“output”:“critical\n”,“status”:2,“history”:[“0”,“0”,“0”,“2”,“2”,“2”,“2”,“2”,“0”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”],“total_state_change”:4},“occurrences”:12,“action”:“create”,“timestamp”:1457125403}

When all I really want is the client name, address and the output (critical)

Anyone know how to do this?

Thanks!


#4

It is very likely you have an smtp server on localhost already if you
were sending email before.
The domain would be something I would ask you. How about "moc.ne.edu"?

···

On Tue, May 10, 2016 at 10:13 AM, <dmak1112@bu.edu> wrote:

Just watched your guide. It's really helpful! Thank's a lot.

I was just using mailx -s and now I am trying to use the mailer plugin.

The only question I have is about the stmp address and domain. I'm not too
sure about what those mean. Do i have to set up an smtp server or something
on my machine? My sensu server is on a VM that runs Rhel as its OS.

On Tuesday, May 10, 2016 at 10:48:17 AM UTC-4, Kyle Anderson wrote:

It sounds like you are using a naive "mail" handler?

I recommend using the popular sensu-mailer rubygem to server as the
handler instead.

https://github.com/sensu-plugins/sensu-plugins-mailer/blob/master/bin/handler-mailer.rb

It has a --template option so you can get your erb on.

I can't find docs on installing this specific handler, but it is the
same as any other plugin:

https://sensuapp.org/docs/latest/getting-started-with-checks#check-cron-install-dependencies
Or I cover installing/configuring this handler in chapter 10 of
https://www.udemy.com/sensu-introduction/

On Mon, May 9, 2016 at 2:00 PM, <dmak...@bu.edu> wrote:
> is there a way to format sensu emails to only receive certain parts?
>
> Right now im getting this whole thing:
>
>
> {"id":"f5d4897c-1262-4488-b9bd-be0d95ec12fa","client":{"name":"compute-20.moc.ne.edu","address":"129.10.3.20","bind":"127.0.0.1","port":"3030","subscriptions":["moc-sensu"],"safe_mode":false,"keepalive":{},"version":"0.20.3","timestamp":1457125387},"check":{"handlers":["default","influxdb-cpu","idle-email"],"type":"metric","command":"/etc/sensu/plugins/cpu-pcnt-usage-metrics.rb
> -t
>
> 20","subscribers":["moc-sensu"],"interval":300,"handler":"debug","name":"cpu_pcnt_metrics","issued":1457125402,"executed":1457125403,"duration":1.049,"output":"critical\n","status":2,"history":["0","0","0","2","2","2","2","2","0","2","2","2","2","2","2","2","2","2","2","2","2"],"total_state_change":4},"occurrences":12,"action":"create","timestamp":1457125403}
>
>
> When all I really want is the client name, address and the output
> (critical)
>
> Anyone know how to do this?
>
> Thanks!