# Formatting sensu emails

**URL:** <https://discourse.sensu.io/t/formatting-sensu-emails/593>\
**Category:** Sensu Classic (EOL)\
**Created:** [May 9, 2016, 9:00pm UTC](https://discourse.sensu.io/t/formatting-sensu-emails/593 "2016-05-09T21:00:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dimitri\_Makrigiorgos](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@Dimitri\_Makrigiorgos](https://discourse.sensu.io/u/Dimitri_Makrigiorgos)\
**Post date:** [May 9, 2016, 9:00pm UTC](https://discourse.sensu.io/t/formatting-sensu-emails/593/1 "2016-05-09T21:00:24Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Kyle\_Anderson](https://avatars.discourse-cdn.com/v4/letter/k/e5b9ba/32.png) [@Kyle\_Anderson](https://discourse.sensu.io/u/Kyle_Anderson)\
**Post date:** [May 10, 2016, 2:48pm UTC](https://discourse.sensu.io/t/formatting-sensu-emails/593/2 "2016-05-10T14:48:15Z")

</div>

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](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/](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!

---

<div class="post-metadata">

**Author:** ![Dimitri\_Makrigiorgos](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@Dimitri\_Makrigiorgos](https://discourse.sensu.io/u/Dimitri_Makrigiorgos)\
**Post date:** [May 10, 2016, 5:13pm UTC](https://discourse.sensu.io/t/formatting-sensu-emails/593/3 "2016-05-10T17:13:59Z")

</div>

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](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](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/](https://www.udemy.com/sensu-introduction/)
> > 
> > On Mon, May 9, 2016 at 2:00 PM, [dmak...@bu.edu](mailto: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](http://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!

---

<div class="post-metadata">

**Author:** ![Kyle\_Anderson](https://avatars.discourse-cdn.com/v4/letter/k/e5b9ba/32.png) [@Kyle\_Anderson](https://discourse.sensu.io/u/Kyle_Anderson)\
**Post date:** [May 12, 2016, 3:18am UTC](https://discourse.sensu.io/t/formatting-sensu-emails/593/4 "2016-05-12T03:18:07Z")

</div>

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](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](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/](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!
