# emails not sending with both mailer.rb and polymailer.rb

**URL:** <https://discourse.sensu.io/t/emails-not-sending-with-both-mailer-rb-and-polymailer-rb/451>\
**Category:** Sensu Classic (EOL)\
**Created:** [June 20, 2015, 5:17am UTC](https://discourse.sensu.io/t/emails-not-sending-with-both-mailer-rb-and-polymailer-rb/451 "2015-06-20T05:17:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Tsai](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@Robert\_Tsai](https://discourse.sensu.io/u/Robert_Tsai)\
**Post date:** [June 20, 2015, 5:17am UTC](https://discourse.sensu.io/t/emails-not-sending-with-both-mailer-rb-and-polymailer-rb/451/1 "2015-06-20T05:17:37Z")

</div>

HI I can’t get either ponymailer nor mailer to send an email out. I have sendmail installed and was able to send an email with mail -s. Below is what I have confgured for ponymailer. Any guideline is welcome.  
Thanks,  
Robert

/opt/sensu/embedded/bin/gem list

\*\*\* LOCAL GEMS \*\*\*

amq-protocol (1.9.2)  
amqp (1.5.0)  
async\_sinatra (1.2.0)  
bigdecimal (1.2.0)  
childprocess (0.5.3)  
daemons (1.2.2)  
em-redis-unified (1.0.0)  
em-worker (0.0.2)  
eventmachine (1.0.3)  
ffi (1.9.8)  
io-console (0.4.2)  
ipaddress (0.8.0)  
json (1.7.7)  
mail (2.5.4)  
mime-types (2.6.1, 1.25.1)  
minitest (4.3.2)  
mixlib-cli (1.5.0)  
mixlib-config (2.2.1)  
mixlib-log (1.6.0)  
mixlib-shellout (2.1.0)  
multi\_json (1.11.0)  
ohai (6.16.0)  
polyglot (0.3.5)  
pony (1.11)  
psych (2.0.0)  
rack (1.6.1)  
rack-protection (1.5.3)  
rake (0.9.6)  
rdoc (4.0.0)  
sensu (0.19.2)  
sensu-em (2.5.2)  
sensu-extension (1.1.2)  
sensu-extensions (1.2.0)  
sensu-logger (1.0.0)  
sensu-plugin (1.1.0)  
sensu-settings (1.9.0)  
sensu-spawn (1.2.0)  
sensu-transport (3.0.0)  
sinatra (1.4.6)  
systemu (2.6.5, 2.5.2)  
test-unit (2.0.0.0)  
thin (1.6.3)  
tilt (2.0.1)  
treetop (1.4.15)  
uuidtools (2.1.5)  
yajl-ruby (1.2.1)

cat /etc/sensu/handlers/ponymailer.rb  
#!/usr/bin/env ruby

> **···**
>
> # 
> 
> # Sensu Handler: ponymailer
> 
> # 
> 
> # This handler formats alerts as mails and sends them off to a pre-defined recipient.
> 
> # 
> 
> # Copyright 2012 Panagiotis Papadomitsos [pj@ezgr.net](mailto:pj@ezgr.net)
> 
> # 
> 
> # Released under the same terms as Sensu (the MIT license); see LICENSE
> 
> # for details.
> 
> require ‘rubygems’ if RUBY\_VERSION \< ‘1.9.0’  
> require ‘sensu-handler’  
> require ‘timeout’  
> require ‘pony’  
> require ‘date’
> 
> class PonyMailer \< Sensu::Handler  
> STATUSES = {  
> 0 =\> ‘OK’,  
> 1 =\> ‘WARNING’,  
> 2 =\> ‘CRITICAL’  
> }
> 
> def short\_name  
> @event[‘client’][‘name’] + ‘/’ + @event[‘check’][‘name’]  
> end
> 
> def action\_to\_string  
> @event[‘action’].eql?(‘resolve’) ? ‘RESOLVED’ : ‘ALERT’  
> end
> 
> def handle  
> if settings[‘ponymailer’][‘only\_send\_on\_change’]  
> last\_status = @event[‘check’][‘history’][-2].to\_i  
> if last\_status == @event[‘check’][‘status’]  
> return  
> end  
> end
> 
> ```
> mail_options = {
> subject: "Sensu Monitoring Alert: #{action_to_string} :: #{short_name}",
> from: "#{settings['ponymailer']['fromname']} <#{settings['ponymailer']['from']}>",
> via: :smtp,
> via_options: {
> address: settings['ponymailer']['hostname'],
> port: settings['ponymailer']['port'],
> enable_starttls_auto: settings['ponymailer']['tls']
> },
> charset: 'utf-8',
> sender: settings['ponymailer']['from']
> }
> mail_options.merge!(via_options: {
> address: settings['ponymailer']['hostname'],
> port: settings['ponymailer']['port'],
> enable_starttls_auto: settings['ponymailer']['tls'],
> user_name: settings['ponymailer']['username'],
> password: settings['ponymailer']['password'],
> authentication: :plain
> }) if settings['ponymailer']['authenticate']
> 
> mail_options[:body] = %(Sensu has detected a failed check. Event analysis follows:
> 
> ```
> 
> # Event Timestamp: #{Time.at(@event[‘check’][‘issued’].to\_i)} Check That Failed: #{@event[‘check’][‘name’]} Check Command: #{@event[‘check’][‘command’]} Check Flapping: #{@event[‘check’][‘flapping’]} Check Occurrences: #{@event[‘occurrences’]} Check History: #{@event[‘check’][‘history’].map { |h| STATUSES[h.to\_i] }.join(’ =\> ‘)} Node Name: #{@event[‘client’][‘name’]} Node IP Address: #{@event[‘client’][‘address’]} Node LPOL: #{Time.at(@event[‘client’][‘timestamp’].to\_i)} Node Subscriptions: #{@event[‘client’][‘subscriptions’].join(’, ')}
> 
> # === Check Output ===
> 
> #{@event[‘check’][‘output’]}  
> )  
> Pony.options = mail\_options
> 
> ```
> # #YELLOW
> unless settings['ponymailer']['recipients'].empty? # rubocop:disable GuardClause
> settings['ponymailer']['recipients'].each do |to|
> begin
> Timeout.timeout 10 do
> Pony.mail(to: to)
> puts 'mail -- sent alert for ' + short_name + ' to ' + to
> end
> rescue Timeout::Error
> puts 'mail -- timed out while attempting to ' + @event['action'] + ' an incident -- ' + short_name
> end
> end
> end
> 
> ```
> 
> end  
> end
> 
> /etc/sensu/conf.d/ponymailer.json  
> {  
> “ponymailer”: {  
> “authenticate”:true,  
> “only\_send\_on\_change”:false,  
> “username”:"xxx@gmail.com",  
> “tls”:true,  
> “port”:“587”,  
> “fromname”:“Operations”,  
> “hostname”:“[smtp.gmail.com](http://smtp.gmail.com)”,  
> “password”:“xxxx”,  
> “from”:"ops@xxxx.net",  
> “recipients”:[  
> "xxxx@gmail.com"  
> ]  
> }  
> }
> 
> /etc/sensu/conf.d/handler\_ponymailer.json  
> {  
> “handlers”: {  
> “ponymailer”: {  
> “type”: “pipe”,  
> “command”: “/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/ponymailer.rb”  
> }  
> }  
> }
> 
> {“timestamp”:“2015-06-20T04:57:00.233492+0000”,“level”:“debug”,“message”:“received result”,“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:"/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800",“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2}}}  
> {“timestamp”:“2015-06-20T04:57:00.233610+0000”,“level”:“debug”,“message”:“processing result”,“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:"/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800",“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2}}}  
> {“timestamp”:“2015-06-20T04:57:00.234173+0000”,“level”:“debug”,“message”:“storing check result”,“check”:{“handlers”:[“ponymailer”],“command”:"/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800",“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2}}  
> {“timestamp”:“2015-06-20T04:57:00.235571+0000”,“level”:“info”,“message”:“processing event”,“event”:{“id”:“b67033bb-9a78-4fd6-a98b-3a525f7bf552”,“client”:{“name”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“address”:“localhost”,“subscriptions”:[“common”],“version”:“0.19.2”,“timestamp”:1434776206},“check”:{“handlers”:[“ponymailer”],“command”:"/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800",“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2,“history”:[“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”],“total\_state\_change”:0},“occurrences”:723,“action”:“create”}}  
> {“timestamp”:“2015-06-20T04:57:00.235927+0000”,“level”:“debug”,“message”:“handling event”,“event\_data”:"{“id”:“b67033bb-9a78-4fd6-a98b-3a525f7bf552”,“client”:{“name”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“address”:“localhost”,“subscriptions”:[“common”],“version”:“0.19.2”,“timestamp”:1434776206},“check”:{“handlers”:[“ponymailer”],“command”:"/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800",“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2,“history”:[“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”],“total\_state\_change”:0},“occurrences”:723,“action”:“create”}",“handler”:{“type”:“pipe”,“command”:"/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”}}  
> {“timestamp”:“2015-06-20T04:57:00.805423+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”},“output”:[“only handling every 180 occurrences: [pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)”]}

---

<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:** [June 20, 2015, 5:53pm UTC](https://discourse.sensu.io/t/emails-not-sending-with-both-mailer-rb-and-polymailer-rb/451/2 "2015-06-20T17:53:26Z")

</div>

Can you find events in the log where there was output from the  
ponymailer command? Or any handler?  
The one posted was filtered.

Try grepping for "handler output" and then grep out "only handling  
every" to see the relevant log lines.

> **···**
>
> On Fri, Jun 19, 2015 at 10:17 PM, Robert Tsai \<rtsai@rivermeadow.com\> wrote:
> 
> > HI I can't get either ponymailer nor mailer to send an email out. I have  
> > sendmail installed and was able to send an email with mail -s. Below is  
> > what I have confgured for ponymailer. Any guideline is welcome.  
> > Thanks,  
> > Robert
> > 
> > /opt/sensu/embedded/bin/gem list
> > 
> > \*\*\* LOCAL GEMS \*\*\*
> > 
> > amq-protocol (1.9.2)  
> > amqp (1.5.0)  
> > async\_sinatra (1.2.0)  
> > bigdecimal (1.2.0)  
> > childprocess (0.5.3)  
> > daemons (1.2.2)  
> > em-redis-unified (1.0.0)  
> > em-worker (0.0.2)  
> > eventmachine (1.0.3)  
> > ffi (1.9.8)  
> > io-console (0.4.2)  
> > ipaddress (0.8.0)  
> > json (1.7.7)  
> > mail (2.5.4)  
> > mime-types (2.6.1, 1.25.1)  
> > minitest (4.3.2)  
> > mixlib-cli (1.5.0)  
> > mixlib-config (2.2.1)  
> > mixlib-log (1.6.0)  
> > mixlib-shellout (2.1.0)  
> > multi\_json (1.11.0)  
> > ohai (6.16.0)  
> > polyglot (0.3.5)  
> > pony (1.11)  
> > psych (2.0.0)  
> > rack (1.6.1)  
> > rack-protection (1.5.3)  
> > rake (0.9.6)  
> > rdoc (4.0.0)  
> > sensu (0.19.2)  
> > sensu-em (2.5.2)  
> > sensu-extension (1.1.2)  
> > sensu-extensions (1.2.0)  
> > sensu-logger (1.0.0)  
> > sensu-plugin (1.1.0)  
> > sensu-settings (1.9.0)  
> > sensu-spawn (1.2.0)  
> > sensu-transport (3.0.0)  
> > sinatra (1.4.6)  
> > systemu (2.6.5, 2.5.2)  
> > test-unit (2.0.0.0)  
> > thin (1.6.3)  
> > tilt (2.0.1)  
> > treetop (1.4.15)  
> > uuidtools (2.1.5)  
> > yajl-ruby (1.2.1)
> > 
> > cat /etc/sensu/handlers/ponymailer.rb  
> > #!/usr/bin/env ruby  
> > #  
> > # Sensu Handler: ponymailer  
> > #  
> > # This handler formats alerts as mails and sends them off to a pre-defined  
> > recipient.  
> > #  
> > # Copyright 2012 Panagiotis Papadomitsos \<pj@ezgr.net\>  
> > #  
> > # Released under the same terms as Sensu (the MIT license); see LICENSE  
> > # for details.
> > 
> > require 'rubygems' if RUBY\_VERSION \< '1.9.0'  
> > require 'sensu-handler'  
> > require 'timeout'  
> > require 'pony'  
> > require 'date'
> > 
> > class PonyMailer \< Sensu::Handler  
> > &nbsp;&nbsp;STATUSES = {  
> > &nbsp;&nbsp;&nbsp;&nbsp;0 =\> 'OK',  
> > &nbsp;&nbsp;&nbsp;&nbsp;1 =\> 'WARNING',  
> > &nbsp;&nbsp;&nbsp;&nbsp;2 =\> 'CRITICAL'  
> > &nbsp;&nbsp;}
> > 
> > &nbsp;&nbsp;def short\_name  
> > &nbsp;&nbsp;&nbsp;&nbsp;@event['client']['name'] + '/' + @event['check']['name']  
> > &nbsp;&nbsp;end
> > 
> > &nbsp;&nbsp;def action\_to\_string  
> > &nbsp;&nbsp;&nbsp;&nbsp;@event['action'].eql?('resolve') ? 'RESOLVED' : 'ALERT'  
> > &nbsp;&nbsp;end
> > 
> > &nbsp;&nbsp;def handle  
> > &nbsp;&nbsp;&nbsp;&nbsp;if settings['ponymailer']['only\_send\_on\_change']  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;last\_status = @event['check']['history'][-2].to\_i  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if last\_status == @event['check']['status']  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;&nbsp;&nbsp;end
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;mail\_options = {  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;subject: "Sensu Monitoring Alert: #{action\_to\_string} ::  
> > #{short\_name}",  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from: "#{settings['ponymailer']['fromname']}  
> > \<#{settings['ponymailer']['from']}\>",  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;via: :smtp,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;via\_options: {  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;address: settings['ponymailer']['hostname'],  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;port: settings['ponymailer']['port'],  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enable\_starttls\_auto: settings['ponymailer']['tls']  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;charset: 'utf-8',  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sender: settings['ponymailer']['from']  
> > &nbsp;&nbsp;&nbsp;&nbsp;}  
> > &nbsp;&nbsp;&nbsp;&nbsp;mail\_options.merge!(via\_options: {  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;address: settings['ponymailer']['hostname'],  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;port: settings['ponymailer']['port'],  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enable\_starttls\_auto:  
> > settings['ponymailer']['tls'],  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user\_name: settings['ponymailer']['username'],  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password: settings['ponymailer']['password'],  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;authentication: :plain  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}) if settings['ponymailer']['authenticate']
> > 
> > # &nbsp;&nbsp;&nbsp;&nbsp;mail\_options[:body] = %(Sensu has detected a failed check. Event analysis follows: Event Timestamp: #{Time.at(@event['check']['issued'].to\_i)} Check That Failed: #{@event['check']['name']} Check Command: #{@event['check']['command']} Check Flapping: #{@event['check']['flapping']} Check Occurrences: #{@event['occurrences']} Check History: #{@event['check']['history'].map { |h| STATUSES[h.to\_i] }.join(' =\> ')} Node Name: #{@event['client']['name']} Node IP Address: #{@event['client']['address']} Node LPOL: #{Time.at(@event['client']['timestamp'].to\_i)} Node Subscriptions: #{@event['client']['subscriptions'].join(', ')}
> > 
> > # === Check Output ===
> > 
> > #{@event['check']['output']}  
> > )  
> > &nbsp;&nbsp;&nbsp;&nbsp;Pony.options = mail\_options
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;# #YELLOW  
> > &nbsp;&nbsp;&nbsp;&nbsp;unless settings['ponymailer']['recipients'].empty? # rubocop:disable  
> > GuardClause  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;settings['ponymailer']['recipients'].each do |to|  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Timeout.timeout 10 do  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pony.mail(to: to)  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts 'mail -- sent alert for ' + short\_name + ' to ' + to  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rescue Timeout::Error  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts 'mail -- timed out while attempting to ' + @event['action'] + '  
> > an incident -- ' + short\_name  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;end  
> > end
> > 
> > /etc/sensu/conf.d/ponymailer.json  
> > {  
> > &nbsp;&nbsp;&nbsp;&nbsp;"ponymailer": {  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"authenticate":true,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"only\_send\_on\_change":false,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"username":"xxx@gmail.com",  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"tls":true,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"port":"587",  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"fromname":"Operations",  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"hostname":"smtp.gmail.com",  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"password":"xxxx",  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"from":"ops@xxxx.net",  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"recipients":[  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"xxxx@gmail.com"  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]  
> > &nbsp;&nbsp;&nbsp;&nbsp;}  
> > }
> > 
> > /etc/sensu/conf.d/handler\_ponymailer.json  
> > {  
> > &nbsp;&nbsp;&nbsp;&nbsp;"handlers": {  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ponymailer": {  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"type": "pipe",  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"command": "/opt/sensu/embedded/bin/ruby  
> > /etc/sensu/handlers/ponymailer.rb"  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
> > &nbsp;&nbsp;&nbsp;&nbsp;}  
> > }
> > 
> > {"timestamp":"2015-06-20T04:57:00.233492+0000","level":"debug","message":"received  
> > result","result":{"client":"pdx01.infra.domain.net","check":{"name":"memory","issued":1434776220,"command":"/etc/sensu/plugins/check-mem.sh  
> > -w 303800 -c  
> > 303800","handlers":["ponymailer"],"interval":10,"subscribers":["common"],"executed":1434776220,"duration":0.006,"output":"MEM  
> > CRITICAL - free system memory: 672 MB\n","status":2}}}  
> > {"timestamp":"2015-06-20T04:57:00.233610+0000","level":"debug","message":"processing  
> > result","result":{"client":"pdx01.infra.domain.net","check":{"name":"memory","issued":1434776220,"command":"/etc/sensu/plugins/check-mem.sh  
> > -w 303800 -c  
> > 303800","handlers":["ponymailer"],"interval":10,"subscribers":["common"],"executed":1434776220,"duration":0.006,"output":"MEM  
> > CRITICAL - free system memory: 672 MB\n","status":2}}}  
> > {"timestamp":"2015-06-20T04:57:00.234173+0000","level":"debug","message":"storing  
> > check  
> > result","check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh  
> > -w 303800 -c  
> > 303800","interval":10,"subscribers":["common"],"name":"memory","issued":1434776220,"executed":1434776220,"duration":0.006,"output":"MEM  
> > CRITICAL - free system memory: 672 MB\n","status":2}}  
> > {"timestamp":"2015-06-20T04:57:00.235571+0000","level":"info","message":"processing  
> > event","event":{"id":"b67033bb-9a78-4fd6-a98b-3a525f7bf552","client":{"name":"pdx01.infra.domain.net","address":"localhost","subscriptions":["common"],"version":"0.19.2","timestamp":1434776206},"check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh  
> > -w 303800 -c  
> > 303800","interval":10,"subscribers":["common"],"name":"memory","issued":1434776220,"executed":1434776220,"duration":0.006,"output":"MEM  
> > CRITICAL - free system memory: 672  
> > MB\n","status":2,"history":["2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total\_state\_change":0},"occurrences":723,"action":"create"}}  
> > {"timestamp":"2015-06-20T04:57:00.235927+0000","level":"debug","message":"handling  
> > event","event\_data":"{\"id\":\"b67033bb-9a78-4fd6-a98b-3a525f7bf552\",\"client\":{\"name\":\"pdx01.infra.domain.net\",\"address\":\"localhost\",\"subscriptions\":[\"common\"],\"version\":\"0.19.2\",\"timestamp\":1434776206},\"check\":{\"handlers\":[\"ponymailer\"],\"command\":\"/etc/sensu/plugins/check-mem.sh  
> > -w 303800 -c  
> > 303800\",\"interval\":10,\"subscribers\":[\"common\"],\"name\":\"memory\",\"issued\":1434776220,\"executed\":1434776220,\"duration\":0.006,\"output\":\"MEM  
> > CRITICAL - free system memory: 672  
> > MB\\n\",\"status\":2,\"history\":[\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\"],\"total\_state\_change\":0},\"occurrences\":723,\"action\":\"create\"}","handler":{"type":"pipe","command":"/opt/sensu/embedded/bin/ruby  
> > /etc/sensu/handlers/ponymailer.rb","name":"ponymailer"}}  
> > {"timestamp":"2015-06-20T04:57:00.805423+0000","level":"info","message":"handler  
> > output","handler":{"type":"pipe","command":"/opt/sensu/embedded/bin/ruby  
> > /etc/sensu/handlers/ponymailer.rb","name":"ponymailer"},"output":["only  
> > handling every 180 occurrences: pdx01.infra.domain.net/memory\n"]}

---

<div class="post-metadata">

**Author:** ![Robert\_Tsai](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@Robert\_Tsai](https://discourse.sensu.io/u/Robert_Tsai)\
**Post date:** [June 20, 2015, 8:26pm UTC](https://discourse.sensu.io/t/emails-not-sending-with-both-mailer-rb-and-polymailer-rb/451/3 "2015-06-20T20:26:18Z")

</div>

Hey Kyle,

Thanks for helping out! Below is the grepped output but I’m only seeing info messages for the handler messages. In my /etc/default/sensu, I have LOG\_LEVEL=debug. I have restarted the sensu-server service. Is there another place I need to change the log level? Thanks again!!

-Rob

/ponymailer.rb",“name”:“ponymailer”},“output”:[“only handling every 180 occurrences: [pdx01.infra.domain.net](http://pdx01.infra.domain.net/)/memory\n”]}

{“timestamp”:“2015-06-20T20:11:30.814117+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:“/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/ponymailer.rb”,“name”:“ponymailer”},“output”:[“only handling every 180 occurrences:[pdx01.infra.domain.net](http://pdx01.infra.domain.net/)/memory\n”]}

{“timestamp”:“2015-06-20T20:11:40.807064+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:“/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/ponymailer.rb”,“name”:“ponymailer”},“output”:[“only handling every 180 occurrences: [pdx01.infra.domain.net](http://pdx01.infra.domain.net/)/memory\n”]}

{“timestamp”:“2015-06-20T20:14:30.838181+0000”,“level”:“info”,“message”:“handler output”,“handler”:

> **···**
>
> On Sat, Jun 20, 2015 at 10:53 AM, Kyle Anderson [kyle@xkyle.com](mailto:kyle@xkyle.com) wrote:
> 
> > Can you find events in the log where there was output from the
> > 
> > ponymailer command? Or any handler?
> > 
> > The one posted was filtered.
> > 
> > Try grepping for “handler output” and then grep out "only handling
> > 
> > every" to see the relevant log lines.
> > 
> > On Fri, Jun 19, 2015 at 10:17 PM, Robert Tsai [rtsai@rivermeadow.com](mailto:rtsai@rivermeadow.com) wrote:
> > 
> > > HI I can’t get either ponymailer nor mailer to send an email out. I have
> > 
> > > sendmail installed and was able to send an email with mail -s. Below is
> > 
> > > what I have confgured for ponymailer. Any guideline is welcome.
> > 
> > > Thanks,
> > 
> > > Robert
> > 
> > > 
> > 
> > > /opt/sensu/embedded/bin/gem list
> > 
> > > 
> > 
> > > \*\*\* LOCAL GEMS \*\*\*
> > 
> > > 
> > 
> > > amq-protocol (1.9.2)
> > 
> > > amqp (1.5.0)
> > 
> > > async\_sinatra (1.2.0)
> > 
> > > bigdecimal (1.2.0)
> > 
> > > childprocess (0.5.3)
> > 
> > > daemons (1.2.2)
> > 
> > > em-redis-unified (1.0.0)
> > 
> > > em-worker (0.0.2)
> > 
> > > eventmachine (1.0.3)
> > 
> > > ffi (1.9.8)
> > 
> > > io-console (0.4.2)
> > 
> > > ipaddress (0.8.0)
> > 
> > > json (1.7.7)
> > 
> > > mail (2.5.4)
> > 
> > > mime-types (2.6.1, 1.25.1)
> > 
> > > minitest (4.3.2)
> > 
> > > mixlib-cli (1.5.0)
> > 
> > > mixlib-config (2.2.1)
> > 
> > > mixlib-log (1.6.0)
> > 
> > > mixlib-shellout (2.1.0)
> > 
> > > multi\_json (1.11.0)
> > 
> > > ohai (6.16.0)
> > 
> > > polyglot (0.3.5)
> > 
> > > pony (1.11)
> > 
> > > psych (2.0.0)
> > 
> > > rack (1.6.1)
> > 
> > > rack-protection (1.5.3)
> > 
> > > rake (0.9.6)
> > 
> > > rdoc (4.0.0)
> > 
> > > sensu (0.19.2)
> > 
> > > sensu-em (2.5.2)
> > 
> > > sensu-extension (1.1.2)
> > 
> > > sensu-extensions (1.2.0)
> > 
> > > sensu-logger (1.0.0)
> > 
> > > sensu-plugin (1.1.0)
> > 
> > > sensu-settings (1.9.0)
> > 
> > > sensu-spawn (1.2.0)
> > 
> > > sensu-transport (3.0.0)
> > 
> > > sinatra (1.4.6)
> > 
> > > systemu (2.6.5, 2.5.2)
> > 
> > > test-unit (2.0.0.0)
> > 
> > > thin (1.6.3)
> > 
> > > tilt (2.0.1)
> > 
> > > treetop (1.4.15)
> > 
> > > uuidtools (2.1.5)
> > 
> > > yajl-ruby (1.2.1)
> > 
> > > 
> > 
> > > 
> > 
> > > cat /etc/sensu/handlers/ponymailer.rb
> > 
> > > #!/usr/bin/env ruby
> > 
> > > #
> > 
> > > # Sensu Handler: ponymailer
> > 
> > > #
> > 
> > > # This handler formats alerts as mails and sends them off to a pre-defined
> > 
> > > recipient.
> > 
> > > #
> > 
> > > # Copyright 2012 Panagiotis Papadomitsos [pj@ezgr.net](mailto:pj@ezgr.net)
> > 
> > > #
> > 
> > > # Released under the same terms as Sensu (the MIT license); see LICENSE
> > 
> > > # for details.
> > 
> > > 
> > 
> > > require ‘rubygems’ if RUBY\_VERSION \< ‘1.9.0’
> > 
> > > require ‘sensu-handler’
> > 
> > > require ‘timeout’
> > 
> > > require ‘pony’
> > 
> > > require ‘date’
> > 
> > > 
> > 
> > > class PonyMailer \< Sensu::Handler
> > 
> > > STATUSES = {
> > 
> > > ```
> > > 0 => 'OK',
> > > 
> > > ```
> > 
> > > ```
> > > 1 => 'WARNING',
> > > 
> > > ```
> > 
> > > ```
> > > 2 => 'CRITICAL'
> > > 
> > > ```
> > 
> > > }
> > 
> > > 
> > 
> > > def short\_name
> > 
> > > ```
> > > @event['client']['name'] + '/' + @event['check']['name']
> > > 
> > > ```
> > 
> > > end
> > 
> > > 
> > 
> > > def action\_to\_string
> > 
> > > ```
> > > @event['action'].eql?('resolve') ? 'RESOLVED' : 'ALERT'
> > > 
> > > ```
> > 
> > > end
> > 
> > > 
> > 
> > > def handle
> > 
> > > ```
> > > if settings['ponymailer']['only_send_on_change']
> > > 
> > > ```
> > 
> > > ```
> > > last_status = @event['check']['history'][-2].to_i
> > > 
> > > ```
> > 
> > > ```
> > > if last_status == @event['check']['status']
> > > 
> > > ```
> > 
> > > ```
> > > return
> > > 
> > > ```
> > 
> > > ```
> > > end
> > > 
> > > ```
> > 
> > > ```
> > > end
> > > 
> > > ```
> > 
> > > 
> > 
> > > ```
> > > mail_options = {
> > > 
> > > ```
> > 
> > > ```
> > > subject: "Sensu Monitoring Alert: #{action_to_string} ::
> > > 
> > > ```
> > 
> > > #{short\_name}",
> > 
> > > ```
> > > from: "#{settings['ponymailer']['fromname']}
> > > 
> > > ```
> > 
> > > \<#{settings[‘ponymailer’][‘from’]}\>",
> > 
> > > ```
> > > via: :smtp,
> > > 
> > > ```
> > 
> > > ```
> > > via_options: {
> > > 
> > > ```
> > 
> > > ```
> > > address: settings['ponymailer']['hostname'],
> > > 
> > > ```
> > 
> > > ```
> > > port: settings['ponymailer']['port'],
> > > 
> > > ```
> > 
> > > ```
> > > enable_starttls_auto: settings['ponymailer']['tls']
> > > 
> > > ```
> > 
> > > ```
> > > },
> > > 
> > > ```
> > 
> > > ```
> > > charset: 'utf-8',
> > > 
> > > ```
> > 
> > > ```
> > > sender: settings['ponymailer']['from']
> > > 
> > > ```
> > 
> > > ```
> > > }
> > > 
> > > ```
> > 
> > > ```
> > > mail_options.merge!(via_options: {
> > > 
> > > ```
> > 
> > > ```
> > > address: settings['ponymailer']['hostname'],
> > > 
> > > ```
> > 
> > > ```
> > > port: settings['ponymailer']['port'],
> > > 
> > > ```
> > 
> > > ```
> > > enable_starttls_auto:
> > > 
> > > ```
> > 
> > > settings[‘ponymailer’][‘tls’],
> > 
> > > ```
> > > user_name: settings['ponymailer']['username'],
> > > 
> > > ```
> > 
> > > ```
> > > password: settings['ponymailer']['password'],
> > > 
> > > ```
> > 
> > > ```
> > > authentication: :plain
> > > 
> > > ```
> > 
> > > ```
> > > }) if settings['ponymailer']['authenticate']
> > > 
> > > ```
> > 
> > > 
> > 
> > > ```
> > > mail_options[:body] = %(Sensu has detected a failed check. Event
> > > 
> > > ```
> > 
> > > analysis follows:
> > 
> > > Event Timestamp: #{Time.at(@event[‘check’][‘issued’].to\_i)}
> > 
> > > Check That Failed: #{@event[‘check’][‘name’]}
> > 
> > > Check Command: #{@event[‘check’][‘command’]}
> > 
> > > Check Flapping: #{@event[‘check’][‘flapping’]}
> > 
> > > Check Occurrences: #{@event[‘occurrences’]}
> > 
> > > Check History: #{@event[‘check’][‘history’].map { |h| STATUSES[h.to\_i]
> > 
> > > }.join(’ =\> ')}
> > 
> > > Node Name: #{@event[‘client’][‘name’]}
> > 
> > > Node IP Address: #{@event[‘client’][‘address’]}
> > 
> > > Node LPOL: #{Time.at(@event[‘client’][‘timestamp’].to\_i)}
> > 
> > > Node Subscriptions: #{@event[‘client’][‘subscriptions’].join(', ')}
> > 
> > > ====================
> > 
> > > === Check Output ===
> > 
> > > ====================
> > 
> > > #{@event[‘check’][‘output’]}
> > 
> > > )
> > 
> > > ```
> > > Pony.options = mail_options
> > > 
> > > ```
> > 
> > > 
> > 
> > > ```
> > > # #YELLOW
> > > 
> > > ```
> > 
> > > ```
> > > unless settings['ponymailer']['recipients'].empty? # rubocop:disable
> > > 
> > > ```
> > 
> > > GuardClause
> > 
> > > ```
> > > settings['ponymailer']['recipients'].each do |to|
> > > 
> > > ```
> > 
> > > ```
> > > begin
> > > 
> > > ```
> > 
> > > ```
> > > Timeout.timeout 10 do
> > > 
> > > ```
> > 
> > > ```
> > > Pony.mail(to: to)
> > > 
> > > ```
> > 
> > > ```
> > > puts 'mail -- sent alert for ' + short_name + ' to ' + to
> > > 
> > > ```
> > 
> > > ```
> > > end
> > > 
> > > ```
> > 
> > > ```
> > > rescue Timeout::Error
> > > 
> > > ```
> > 
> > > ```
> > > puts 'mail -- timed out while attempting to ' + @event['action'] + '
> > > 
> > > ```
> > 
> > > an incident – ’ + short\_name
> > 
> > > ```
> > > end
> > > 
> > > ```
> > 
> > > ```
> > > end
> > > 
> > > ```
> > 
> > > ```
> > > end
> > > 
> > > ```
> > 
> > > end
> > 
> > > end
> > 
> > > 
> > 
> > > 
> > 
> > > 
> > 
> > > /etc/sensu/conf.d/ponymailer.json
> > 
> > > {
> > 
> > > ```
> > > "ponymailer": {
> > > 
> > > ```
> > 
> > > ```
> > > "authenticate":true,
> > > 
> > > ```
> > 
> > > ```
> > > "only_send_on_change":false,
> > > 
> > > ```
> > 
> > > ```
> > > "username":"xxx@gmail.com",
> > > 
> > > ```
> > 
> > > ```
> > > "tls":true,
> > > 
> > > ```
> > 
> > > ```
> > > "port":"587",
> > > 
> > > ```
> > 
> > > ```
> > > "fromname":"Operations",
> > > 
> > > ```
> > 
> > > ```
> > > "hostname":"[smtp.gmail.com](http://smtp.gmail.com)",
> > > 
> > > ```
> > 
> > > ```
> > > "password":"xxxx",
> > > 
> > > ```
> > 
> > > ```
> > > "from":"ops@xxxx.net",
> > > 
> > > ```
> > 
> > > ```
> > > "recipients":[
> > > 
> > > ```
> > 
> > > ```
> > > "xxxx@gmail.com"
> > > 
> > > ```
> > 
> > > ```
> > > ]
> > > 
> > > ```
> > 
> > > ```
> > > }
> > > 
> > > ```
> > 
> > > }
> > 
> > > 
> > 
> > > 
> > 
> > > /etc/sensu/conf.d/handler\_ponymailer.json
> > 
> > > {
> > 
> > > ```
> > > "handlers": {
> > > 
> > > ```
> > 
> > > ```
> > > "ponymailer": {
> > > 
> > > ```
> > 
> > > ```
> > > "type": "pipe",
> > > 
> > > ```
> > 
> > > ```
> > > "command": "/opt/sensu/embedded/bin/ruby
> > > 
> > > ```
> > 
> > > /etc/sensu/handlers/ponymailer.rb"
> > 
> > > ```
> > > }
> > > 
> > > ```
> > 
> > > ```
> > > }
> > > 
> > > ```
> > 
> > > }
> > 
> > > 
> > 
> > > 
> > 
> > > 
> > 
> > > 
> > 
> > > {“timestamp”:“2015-06-20T04:57:00.233492+0000”,“level”:“debug”,“message”:"received
> > 
> > > result",“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > -w 303800 -c
> > 
> > > 303800",“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > CRITICAL - free system memory: 672 MB\n",“status”:2}}}
> > 
> > > {“timestamp”:“2015-06-20T04:57:00.233610+0000”,“level”:“debug”,“message”:"processing
> > 
> > > result",“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > -w 303800 -c
> > 
> > > 303800",“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > CRITICAL - free system memory: 672 MB\n",“status”:2}}}
> > 
> > > {“timestamp”:“2015-06-20T04:57:00.234173+0000”,“level”:“debug”,“message”:"storing
> > 
> > > check
> > 
> > > result",“check”:{“handlers”:[“ponymailer”],“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > -w 303800 -c
> > 
> > > 303800",“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > CRITICAL - free system memory: 672 MB\n",“status”:2}}
> > 
> > > {“timestamp”:“2015-06-20T04:57:00.235571+0000”,“level”:“info”,“message”:"processing
> > 
> > > event",“event”:{“id”:“b67033bb-9a78-4fd6-a98b-3a525f7bf552”,“client”:{“name”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“address”:“localhost”,“subscriptions”:[“common”],“version”:“0.19.2”,“timestamp”:1434776206},“check”:{“handlers”:[“ponymailer”],“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > -w 303800 -c
> > 
> > > 303800",“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > CRITICAL - free system memory: 672
> > 
> > > MB\n",“status”:2,“history”:[“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”],“total\_state\_change”:0},“occurrences”:723,“action”:“create”}}
> > 
> > > {“timestamp”:“2015-06-20T04:57:00.235927+0000”,“level”:“debug”,“message”:"handling
> > 
> > > event",“event\_data”:"{"id":"b67033bb-9a78-4fd6-a98b-3a525f7bf552","client":{"name":"[pdx01.infra.domain.net](http://pdx01.infra.domain.net)","address":"localhost","subscriptions":["common"],"version":"0.19.2","timestamp":1434776206},"check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh
> > 
> > > -w 303800 -c
> > 
> > > 303800","interval":10,"subscribers":["common"],"name":"memory","issued":1434776220,"executed":1434776220,"duration":0.006,"output":"MEM
> > 
> > > CRITICAL - free system memory: 672
> > 
> > > MB\n","status":2,"history":["2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total\_state\_change":0},"occurrences":723,"action":"create"}“,“handler”:{“type”:“pipe”,“command”:”/opt/sensu/embedded/bin/ruby
> > 
> > > /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”}}
> > 
> > > {“timestamp”:“2015-06-20T04:57:00.805423+0000”,“level”:“info”,“message”:"handler
> > 
> > > output",“handler”:{“type”:“pipe”,“command”:"/opt/sensu/embedded/bin/ruby
> > 
> > > /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”},“output”:["only
> > 
> > > handling every 180 occurrences: [pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)"]}
> 
> –
> 
> **Robert Tsai**
> 
> **RiverMeadow Operations  
> (650) 452 - 2020**

---

<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:** [June 20, 2015, 9:46pm UTC](https://discourse.sensu.io/t/emails-not-sending-with-both-mailer-rb-and-polymailer-rb/451/4 "2015-06-20T21:46:52Z")

</div>

If you want to debug a handler not working, you have to get it "in the act"  
You could decrease the occurences setting to "1" so it fires all the time.  
Or maybe grep the logs harder? Are there logs that were logrotated + gzipd?

zgrep 'handler output' /var/log/sensu-server\*

> **···**
>
> On Sat, Jun 20, 2015 at 1:26 PM, Robert Tsai \<rtsai@rivermeadow.com\> wrote:
> 
> > Hey Kyle,
> > 
> > Thanks for helping out! Below is the grepped output but I'm only seeing  
> > info messages for the handler messages. In my /etc/default/sensu, I have  
> > LOG\_LEVEL=debug. I have restarted the sensu-server service. Is there  
> > another place I need to change the log level? Thanks again!!
> > 
> > -Rob
> > 
> > /ponymailer.rb","name":"ponymailer"},"output":["only handling every 180  
> > occurrences: pdx01.infra.domain.net/memory\n"]}  
> > {"timestamp":"2015-06-20T20:11:30.814117+0000","level":"info","message":"handler  
> > output","handler":{"type":"pipe","command":"/opt/sensu/embedded/bin/ruby  
> > /etc/sensu/handlers/ponymailer.rb","name":"ponymailer"},"output":["only  
> > handling every 180 occurrences:pdx01.infra.domain.net/memory\n"]}  
> > {"timestamp":"2015-06-20T20:11:40.807064+0000","level":"info","message":"handler  
> > output","handler":{"type":"pipe","command":"/opt/sensu/embedded/bin/ruby  
> > /etc/sensu/handlers/ponymailer.rb","name":"ponymailer"},"output":["only  
> > handling every 180 occurrences: pdx01.infra.domain.net/memory\n"]}  
> > {"timestamp":"2015-06-20T20:14:30.838181+0000","level":"info","message":"handler  
> > output","handler":
> > 
> > On Sat, Jun 20, 2015 at 10:53 AM, Kyle Anderson \<kyle@xkyle.com\> wrote:
> > 
> > > Can you find events in the log where there was output from the  
> > > ponymailer command? Or any handler?  
> > > The one posted was filtered.
> > > 
> > > Try grepping for "handler output" and then grep out "only handling  
> > > every" to see the relevant log lines.
> > > 
> > > On Fri, Jun 19, 2015 at 10:17 PM, Robert Tsai \<rtsai@rivermeadow.com\> \>\> wrote:  
> > > \> HI I can't get either ponymailer nor mailer to send an email out. I  
> > > \> have  
> > > \> sendmail installed and was able to send an email with mail -s. Below is  
> > > \> what I have confgured for ponymailer. Any guideline is welcome.  
> > > \> Thanks,  
> > > \> Robert  
> > > \>  
> > > \> /opt/sensu/embedded/bin/gem list  
> > > \>  
> > > \> \*\*\* LOCAL GEMS \*\*\*  
> > > \>  
> > > \> amq-protocol (1.9.2)  
> > > \> amqp (1.5.0)  
> > > \> async\_sinatra (1.2.0)  
> > > \> bigdecimal (1.2.0)  
> > > \> childprocess (0.5.3)  
> > > \> daemons (1.2.2)  
> > > \> em-redis-unified (1.0.0)  
> > > \> em-worker (0.0.2)  
> > > \> eventmachine (1.0.3)  
> > > \> ffi (1.9.8)  
> > > \> io-console (0.4.2)  
> > > \> ipaddress (0.8.0)  
> > > \> json (1.7.7)  
> > > \> mail (2.5.4)  
> > > \> mime-types (2.6.1, 1.25.1)  
> > > \> minitest (4.3.2)  
> > > \> mixlib-cli (1.5.0)  
> > > \> mixlib-config (2.2.1)  
> > > \> mixlib-log (1.6.0)  
> > > \> mixlib-shellout (2.1.0)  
> > > \> multi\_json (1.11.0)  
> > > \> ohai (6.16.0)  
> > > \> polyglot (0.3.5)  
> > > \> pony (1.11)  
> > > \> psych (2.0.0)  
> > > \> rack (1.6.1)  
> > > \> rack-protection (1.5.3)  
> > > \> rake (0.9.6)  
> > > \> rdoc (4.0.0)  
> > > \> sensu (0.19.2)  
> > > \> sensu-em (2.5.2)  
> > > \> sensu-extension (1.1.2)  
> > > \> sensu-extensions (1.2.0)  
> > > \> sensu-logger (1.0.0)  
> > > \> sensu-plugin (1.1.0)  
> > > \> sensu-settings (1.9.0)  
> > > \> sensu-spawn (1.2.0)  
> > > \> sensu-transport (3.0.0)  
> > > \> sinatra (1.4.6)  
> > > \> systemu (2.6.5, 2.5.2)  
> > > \> test-unit (2.0.0.0)  
> > > \> thin (1.6.3)  
> > > \> tilt (2.0.1)  
> > > \> treetop (1.4.15)  
> > > \> uuidtools (2.1.5)  
> > > \> yajl-ruby (1.2.1)  
> > > \>  
> > > \>  
> > > \> cat /etc/sensu/handlers/ponymailer.rb  
> > > \> #!/usr/bin/env ruby  
> > > \> #  
> > > \> # Sensu Handler: ponymailer  
> > > \> #  
> > > \> # This handler formats alerts as mails and sends them off to a  
> > > \> pre-defined  
> > > \> recipient.  
> > > \> #  
> > > \> # Copyright 2012 Panagiotis Papadomitsos \<pj@ezgr.net\>  
> > > \> #  
> > > \> # Released under the same terms as Sensu (the MIT license); see LICENSE  
> > > \> # for details.  
> > > \>  
> > > \> require 'rubygems' if RUBY\_VERSION \< '1.9.0'  
> > > \> require 'sensu-handler'  
> > > \> require 'timeout'  
> > > \> require 'pony'  
> > > \> require 'date'  
> > > \>  
> > > \> class PonyMailer \< Sensu::Handler  
> > > \> STATUSES = {  
> > > \> 0 =\> 'OK',  
> > > \> 1 =\> 'WARNING',  
> > > \> 2 =\> 'CRITICAL'  
> > > \> }  
> > > \>  
> > > \> def short\_name  
> > > \> @event['client']['name'] + '/' + @event['check']['name']  
> > > \> end  
> > > \>  
> > > \> def action\_to\_string  
> > > \> @event['action'].eql?('resolve') ? 'RESOLVED' : 'ALERT'  
> > > \> end  
> > > \>  
> > > \> def handle  
> > > \> if settings['ponymailer']['only\_send\_on\_change']  
> > > \> last\_status = @event['check']['history'][-2].to\_i  
> > > \> if last\_status == @event['check']['status']  
> > > \> return  
> > > \> end  
> > > \> end  
> > > \>  
> > > \> mail\_options = {  
> > > \> subject: "Sensu Monitoring Alert: #{action\_to\_string} ::  
> > > \> #{short\_name}",  
> > > \> from: "#{settings['ponymailer']['fromname']}  
> > > \> \<#{settings['ponymailer']['from']}\>",  
> > > \> via: :smtp,  
> > > \> via\_options: {  
> > > \> address: settings['ponymailer']['hostname'],  
> > > \> port: settings['ponymailer']['port'],  
> > > \> enable\_starttls\_auto: settings['ponymailer']['tls']  
> > > \> },  
> > > \> charset: 'utf-8',  
> > > \> sender: settings['ponymailer']['from']  
> > > \> }  
> > > \> mail\_options.merge!(via\_options: {  
> > > \> address: settings['ponymailer']['hostname'],  
> > > \> port: settings['ponymailer']['port'],  
> > > \> enable\_starttls\_auto:  
> > > \> settings['ponymailer']['tls'],  
> > > \> user\_name: settings['ponymailer']['username'],  
> > > \> password: settings['ponymailer']['password'],  
> > > \> authentication: :plain  
> > > \> }) if settings['ponymailer']['authenticate']  
> > > \>  
> > > \> mail\_options[:body] = %(Sensu has detected a failed check. Event  
> > > \> analysis follows:  
> > > \> Event Timestamp: #{Time.at(@event['check']['issued'].to\_i)}  
> > > \> Check That Failed: #{@event['check']['name']}  
> > > \> Check Command: #{@event['check']['command']}  
> > > \> Check Flapping: #{@event['check']['flapping']}  
> > > \> Check Occurrences: #{@event['occurrences']}  
> > > \> Check History: #{@event['check']['history'].map { |h|  
> > > \> STATUSES[h.to\_i]  
> > > \> }.join(' =\> ')}  
> > > \> Node Name: #{@event['client']['name']}  
> > > \> Node IP Address: #{@event['client']['address']}  
> > > \> Node LPOL: #{Time.at(@event['client']['timestamp'].to\_i)}  
> > > \> Node Subscriptions: #{@event['client']['subscriptions'].join(', ')}  
> > > \> ====================  
> > > \> === Check Output ===  
> > > \> ====================  
> > > \> #{@event['check']['output']}  
> > > \> )  
> > > \> Pony.options = mail\_options  
> > > \>  
> > > \> # #YELLOW  
> > > \> unless settings['ponymailer']['recipients'].empty? # rubocop:disable  
> > > \> GuardClause  
> > > \> settings['ponymailer']['recipients'].each do |to|  
> > > \> begin  
> > > \> Timeout.timeout 10 do  
> > > \> Pony.mail(to: to)  
> > > \> puts 'mail -- sent alert for ' + short\_name + ' to ' + to  
> > > \> end  
> > > \> rescue Timeout::Error  
> > > \> puts 'mail -- timed out while attempting to ' + @event['action']  
> > > \> + '  
> > > \> an incident -- ' + short\_name  
> > > \> end  
> > > \> end  
> > > \> end  
> > > \> end  
> > > \> end  
> > > \>  
> > > \>  
> > > \>  
> > > \> /etc/sensu/conf.d/ponymailer.json  
> > > \> {  
> > > \> "ponymailer": {  
> > > \> "authenticate":true,  
> > > \> "only\_send\_on\_change":false,  
> > > \> "username":"xxx@gmail.com",  
> > > \> "tls":true,  
> > > \> "port":"587",  
> > > \> "fromname":"Operations",  
> > > \> "hostname":"smtp.gmail.com",  
> > > \> "password":"xxxx",  
> > > \> "from":"ops@xxxx.net",  
> > > \> "recipients":[  
> > > \> "xxxx@gmail.com"  
> > > \> ]  
> > > \> }  
> > > \> }  
> > > \>  
> > > \>  
> > > \> /etc/sensu/conf.d/handler\_ponymailer.json  
> > > \> {  
> > > \> "handlers": {  
> > > \> "ponymailer": {  
> > > \> "type": "pipe",  
> > > \> "command": "/opt/sensu/embedded/bin/ruby  
> > > \> /etc/sensu/handlers/ponymailer.rb"  
> > > \> }  
> > > \> }  
> > > \> }  
> > > \>  
> > > \>  
> > > \>  
> > > \>  
> > > \>  
> > > \> {"timestamp":"2015-06-20T04:57:00.233492+0000","level":"debug","message":"received  
> > > \>  
> > > \> result","result":{"client":"pdx01.infra.domain.net","check":{"name":"memory","issued":1434776220,"command":"/etc/sensu/plugins/check-mem.sh  
> > > \> -w 303800 -c  
> > > \>  
> > > \> 303800","handlers":["ponymailer"],"interval":10,"subscribers":["common"],"executed":1434776220,"duration":0.006,"output":"MEM  
> > > \> CRITICAL - free system memory: 672 MB\n","status":2}}}  
> > > \>  
> > > \> {"timestamp":"2015-06-20T04:57:00.233610+0000","level":"debug","message":"processing  
> > > \>  
> > > \> result","result":{"client":"pdx01.infra.domain.net","check":{"name":"memory","issued":1434776220,"command":"/etc/sensu/plugins/check-mem.sh  
> > > \> -w 303800 -c  
> > > \>  
> > > \> 303800","handlers":["ponymailer"],"interval":10,"subscribers":["common"],"executed":1434776220,"duration":0.006,"output":"MEM  
> > > \> CRITICAL - free system memory: 672 MB\n","status":2}}}  
> > > \>  
> > > \> {"timestamp":"2015-06-20T04:57:00.234173+0000","level":"debug","message":"storing  
> > > \> check  
> > > \>  
> > > \> result","check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh  
> > > \> -w 303800 -c  
> > > \>  
> > > \> 303800","interval":10,"subscribers":["common"],"name":"memory","issued":1434776220,"executed":1434776220,"duration":0.006,"output":"MEM  
> > > \> CRITICAL - free system memory: 672 MB\n","status":2}}  
> > > \>  
> > > \> {"timestamp":"2015-06-20T04:57:00.235571+0000","level":"info","message":"processing  
> > > \>  
> > > \> event","event":{"id":"b67033bb-9a78-4fd6-a98b-3a525f7bf552","client":{"name":"pdx01.infra.domain.net","address":"localhost","subscriptions":["common"],"version":"0.19.2","timestamp":1434776206},"check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh  
> > > \> -w 303800 -c  
> > > \>  
> > > \> 303800","interval":10,"subscribers":["common"],"name":"memory","issued":1434776220,"executed":1434776220,"duration":0.006,"output":"MEM  
> > > \> CRITICAL - free system memory: 672  
> > > \>  
> > > \> MB\n","status":2,"history":["2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total\_state\_change":0},"occurrences":723,"action":"create"}}  
> > > \>  
> > > \> {"timestamp":"2015-06-20T04:57:00.235927+0000","level":"debug","message":"handling  
> > > \>  
> > > \> event","event\_data":"{\"id\":\"b67033bb-9a78-4fd6-a98b-3a525f7bf552\",\"client\":{\"name\":\"pdx01.infra.domain.net\",\"address\":\"localhost\",\"subscriptions\":[\"common\"],\"version\":\"0.19.2\",\"timestamp\":1434776206},\"check\":{\"handlers\":[\"ponymailer\"],\"command\":\"/etc/sensu/plugins/check-mem.sh  
> > > \> -w 303800 -c  
> > > \>  
> > > \> 303800\",\"interval\":10,\"subscribers\":[\"common\"],\"name\":\"memory\",\"issued\":1434776220,\"executed\":1434776220,\"duration\":0.006,\"output\":\"MEM  
> > > \> CRITICAL - free system memory: 672  
> > > \>  
> > > \> MB\\n\",\"status\":2,\"history\":[\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\"],\"total\_state\_change\":0},\"occurrences\":723,\"action\":\"create\"}","handler":{"type":"pipe","command":"/opt/sensu/embedded/bin/ruby  
> > > \> /etc/sensu/handlers/ponymailer.rb","name":"ponymailer"}}  
> > > \>  
> > > \> {"timestamp":"2015-06-20T04:57:00.805423+0000","level":"info","message":"handler  
> > > \> output","handler":{"type":"pipe","command":"/opt/sensu/embedded/bin/ruby  
> > > \> /etc/sensu/handlers/ponymailer.rb","name":"ponymailer"},"output":["only  
> > > \> handling every 180 occurrences: pdx01.infra.domain.net/memory\n"]}
> > 
> > --  
> > Robert Tsai  
> > RiverMeadow Operations  
> > (650) 452 - 2020

---

<div class="post-metadata">

**Author:** ![Robert\_Tsai](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@Robert\_Tsai](https://discourse.sensu.io/u/Robert_Tsai)\
**Post date:** [June 21, 2015, 5:25am UTC](https://discourse.sensu.io/t/emails-not-sending-with-both-mailer-rb-and-polymailer-rb/451/5 "2015-06-21T05:25:03Z")

</div>

Hi Kyle,

Here is what I found after I changed the occurances to 1.

{“timestamp”:“2015-06-21T05:23:10.275236+0000”,“level”:“debug”,“message”:“handling event”,“event\_data”:“{"id":"e455f544-7a70-450d-a9e6-57000e99890c","client":{"name":"[infra.domain.net](http://infra.domain.net)","address":"localhost","subscriptions":["common"],"version":"0.19.2","timestamp":1434864189},"check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh -w 200 -c 395064","interval":10,"occurrences":1,"refresh":20,"subscribers":["common"],"name":"memory","issued":1434864190,"executed":1434864190,"duration":0.006,"output":"MEM CRITICAL - free system memory: 632 MB\n","status":2,"history":["2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total\_state\_change":0},"occurrences":200,"action":"create"}”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/ponymailer.rb ",“name”:“ponymailer”}}

{“timestamp”:“2015-06-21T05:17:50.847345+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:“/etc/sensu/handlers/ponymailer.rb “,“name”:“ponymailer”},“output”:[”/opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1533:in `addr_port': undefined method `+’ for nil:NilClass (NoMethodError)\n”,“\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1466:in `begin_transport'\n","\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1408:in `transport\_request’\n”,“\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1382:in `request'\n","\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1375:in `block in request’\n”,“\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:852:in `start'\n","\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1373:in `request’\n”,“\tfrom /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:85:in `api_request'\n","\tfrom /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:120:in `stash\_exists?'\n”,“\tfrom /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:132:in `block (2 levels) in filter_silenced'\n","\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:66:in `timeout’\n”,“\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:97:in `timeout'\n","\tfrom /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:131:in `block in filter\_silenced’\n”,“\tfrom /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:129:in `each'\n","\tfrom /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:129:in `filter\_silenced’\n”,“\tfrom /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:31:in `filter'\n","\tfrom /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:54:in `block in class:Handler’\n”]}

/opt/sensu/embedded/bin/gem list

\*\*\* LOCAL GEMS \*\*\*

bigdecimal (1.2.0)

io-console (0.4.2)

json (1.7.7)

mail (2.6.3)

mime-types (2.6.1)

minitest (4.3.2)

mixlib-cli (1.5.0)

pony (1.11)

psych (2.0.0)

rake (0.9.6)

rdoc (4.0.0)

sendmail (0.0.1)

sensu-plugin (1.1.0)

test-unit (2.0.0.0)

timeout (0.0.1)

timeout-extensions (0.0.0)

cat /etc/sensu/conf.d/handler\_ponymailer.json

{

“handlers”: {

“ponymailer”: {

“type”: “pipe”,

“command”: "/etc/sensu/handlers/ponymailer.rb "

}

}

}

cat /etc/sensu/conf.d/ponymailer.json

{

```
"ponymailer": {

	"authenticate":true,

	"only_send_on_change":false,

	"username":"user@gmail.com",

	"tls":true,

	"port":"587",

	"fromname":"Operations",

	"hostname":"[smtp.gmail.com](http://smtp.gmail.com)",

	"password":"xxxxx",

	"from":"ops@xxxx",

	"recipients":[

		"user@gmail.com"

	]

}

```

}

> **···**
>
> On Sat, Jun 20, 2015 at 2:46 PM, Kyle Anderson [kyle@xkyle.com](mailto:kyle@xkyle.com) wrote:
> 
> > If you want to debug a handler not working, you have to get it “in the act”
> > 
> > You could decrease the occurences setting to “1” so it fires all the time.
> > 
> > Or maybe grep the logs harder? Are there logs that were logrotated + gzipd?
> > 
> > zgrep ‘handler output’ /var/log/sensu-server\*
> > 
> > On Sat, Jun 20, 2015 at 1:26 PM, Robert Tsai [rtsai@rivermeadow.com](mailto:rtsai@rivermeadow.com) wrote:
> > 
> > > Hey Kyle,
> > 
> > > 
> > 
> > > Thanks for helping out! Below is the grepped output but I’m only seeing
> > 
> > > info messages for the handler messages. In my /etc/default/sensu, I have
> > 
> > > LOG\_LEVEL=debug. I have restarted the sensu-server service. Is there
> > 
> > > another place I need to change the log level? Thanks again!!
> > 
> > > 
> > 
> > > -Rob
> > 
> > > 
> > 
> > > /ponymailer.rb",“name”:“ponymailer”},“output”:["only handling every 180
> > 
> > > occurrences: [pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)"]}
> > 
> > > {“timestamp”:“2015-06-20T20:11:30.814117+0000”,“level”:“info”,“message”:"handler
> > 
> > > output",“handler”:{“type”:“pipe”,“command”:"/opt/sensu/embedded/bin/ruby
> > 
> > > /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”},“output”:["only
> > 
> > > handling every 180 occurrences:[pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)"]}
> > 
> > > {“timestamp”:“2015-06-20T20:11:40.807064+0000”,“level”:“info”,“message”:"handler
> > 
> > > output",“handler”:{“type”:“pipe”,“command”:"/opt/sensu/embedded/bin/ruby
> > 
> > > /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”},“output”:["only
> > 
> > > handling every 180 occurrences: [pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)"]}
> > 
> > > {“timestamp”:“2015-06-20T20:14:30.838181+0000”,“level”:“info”,“message”:"handler
> > 
> > > output",“handler”:
> > 
> > > 
> > 
> > > On Sat, Jun 20, 2015 at 10:53 AM, Kyle Anderson [kyle@xkyle.com](mailto:kyle@xkyle.com) wrote:
> > 
> > > >
> > 
> > > > Can you find events in the log where there was output from the
> > 
> > > > ponymailer command? Or any handler?
> > 
> > > > The one posted was filtered.
> > 
> > > >
> > 
> > > > Try grepping for “handler output” and then grep out "only handling
> > 
> > > > every" to see the relevant log lines.
> > 
> > > >
> > 
> > > > On Fri, Jun 19, 2015 at 10:17 PM, Robert Tsai [rtsai@rivermeadow.com](mailto:rtsai@rivermeadow.com)
> > 
> > > > wrote:
> > 
> > > > > HI I can’t get either ponymailer nor mailer to send an email out. I
> > 
> > > > > have
> > 
> > > > > sendmail installed and was able to send an email with mail -s. Below is
> > 
> > > > > what I have confgured for ponymailer. Any guideline is welcome.
> > 
> > > > > Thanks,
> > 
> > > > > Robert
> > 
> > > > >
> > 
> > > > > /opt/sensu/embedded/bin/gem list
> > 
> > > > >
> > 
> > > > > \*\*\* LOCAL GEMS \*\*\*
> > 
> > > > >
> > 
> > > > > amq-protocol (1.9.2)
> > 
> > > > > amqp (1.5.0)
> > 
> > > > > async\_sinatra (1.2.0)
> > 
> > > > > bigdecimal (1.2.0)
> > 
> > > > > childprocess (0.5.3)
> > 
> > > > > daemons (1.2.2)
> > 
> > > > > em-redis-unified (1.0.0)
> > 
> > > > > em-worker (0.0.2)
> > 
> > > > > eventmachine (1.0.3)
> > 
> > > > > ffi (1.9.8)
> > 
> > > > > io-console (0.4.2)
> > 
> > > > > ipaddress (0.8.0)
> > 
> > > > > json (1.7.7)
> > 
> > > > > mail (2.5.4)
> > 
> > > > > mime-types (2.6.1, 1.25.1)
> > 
> > > > > minitest (4.3.2)
> > 
> > > > > mixlib-cli (1.5.0)
> > 
> > > > > mixlib-config (2.2.1)
> > 
> > > > > mixlib-log (1.6.0)
> > 
> > > > > mixlib-shellout (2.1.0)
> > 
> > > > > multi\_json (1.11.0)
> > 
> > > > > ohai (6.16.0)
> > 
> > > > > polyglot (0.3.5)
> > 
> > > > > pony (1.11)
> > 
> > > > > psych (2.0.0)
> > 
> > > > > rack (1.6.1)
> > 
> > > > > rack-protection (1.5.3)
> > 
> > > > > rake (0.9.6)
> > 
> > > > > rdoc (4.0.0)
> > 
> > > > > sensu (0.19.2)
> > 
> > > > > sensu-em (2.5.2)
> > 
> > > > > sensu-extension (1.1.2)
> > 
> > > > > sensu-extensions (1.2.0)
> > 
> > > > > sensu-logger (1.0.0)
> > 
> > > > > sensu-plugin (1.1.0)
> > 
> > > > > sensu-settings (1.9.0)
> > 
> > > > > sensu-spawn (1.2.0)
> > 
> > > > > sensu-transport (3.0.0)
> > 
> > > > > sinatra (1.4.6)
> > 
> > > > > systemu (2.6.5, 2.5.2)
> > 
> > > > > test-unit (2.0.0.0)
> > 
> > > > > thin (1.6.3)
> > 
> > > > > tilt (2.0.1)
> > 
> > > > > treetop (1.4.15)
> > 
> > > > > uuidtools (2.1.5)
> > 
> > > > > yajl-ruby (1.2.1)
> > 
> > > > >
> > 
> > > > >
> > 
> > > > > cat /etc/sensu/handlers/ponymailer.rb
> > 
> > > > > #!/usr/bin/env ruby
> > 
> > > > > #
> > 
> > > > > # Sensu Handler: ponymailer
> > 
> > > > > #
> > 
> > > > > # This handler formats alerts as mails and sends them off to a
> > 
> > > > > pre-defined
> > 
> > > > > recipient.
> > 
> > > > > #
> > 
> > > > > # Copyright 2012 Panagiotis Papadomitsos [pj@ezgr.net](mailto:pj@ezgr.net)
> > 
> > > > > #
> > 
> > > > > # Released under the same terms as Sensu (the MIT license); see LICENSE
> > 
> > > > > # for details.
> > 
> > > > >
> > 
> > > > > require ‘rubygems’ if RUBY\_VERSION \< ‘1.9.0’
> > 
> > > > > require ‘sensu-handler’
> > 
> > > > > require ‘timeout’
> > 
> > > > > require ‘pony’
> > 
> > > > > require ‘date’
> > 
> > > > >
> > 
> > > > > class PonyMailer \< Sensu::Handler
> > 
> > > > > STATUSES = {
> > 
> > > > > ```
> > > > > 0 => 'OK',
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > 1 => 'WARNING',
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > 2 => 'CRITICAL'
> > > > > 
> > > > > ```
> > 
> > > > > }
> > 
> > > > >
> > 
> > > > > def short\_name
> > 
> > > > > ```
> > > > > @event['client']['name'] + '/' + @event['check']['name']
> > > > > 
> > > > > ```
> > 
> > > > > end
> > 
> > > > >
> > 
> > > > > def action\_to\_string
> > 
> > > > > ```
> > > > > @event['action'].eql?('resolve') ? 'RESOLVED' : 'ALERT'
> > > > > 
> > > > > ```
> > 
> > > > > end
> > 
> > > > >
> > 
> > > > > def handle
> > 
> > > > > ```
> > > > > if settings['ponymailer']['only_send_on_change']
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > last_status = @event['check']['history'][-2].to_i
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > if last_status == @event['check']['status']
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > return
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > end
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > end
> > > > > 
> > > > > ```
> > 
> > > > >
> > 
> > > > > ```
> > > > > mail_options = {
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > subject: "Sensu Monitoring Alert: #{action_to_string} ::
> > > > > 
> > > > > ```
> > 
> > > > > #{short\_name}",
> > 
> > > > > ```
> > > > > from: "#{settings['ponymailer']['fromname']}
> > > > > 
> > > > > ```
> > 
> > > > > \<#{settings[‘ponymailer’][‘from’]}\>",
> > 
> > > > > ```
> > > > > via: :smtp,
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > via_options: {
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > address: settings['ponymailer']['hostname'],
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > port: settings['ponymailer']['port'],
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > enable_starttls_auto: settings['ponymailer']['tls']
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > },
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > charset: 'utf-8',
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > sender: settings['ponymailer']['from']
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > }
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > mail_options.merge!(via_options: {
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > address: settings['ponymailer']['hostname'],
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > port: settings['ponymailer']['port'],
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > enable_starttls_auto:
> > > > > 
> > > > > ```
> > 
> > > > > settings[‘ponymailer’][‘tls’],
> > 
> > > > > ```
> > > > > user_name: settings['ponymailer']['username'],
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > password: settings['ponymailer']['password'],
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > authentication: :plain
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > }) if settings['ponymailer']['authenticate']
> > > > > 
> > > > > ```
> > 
> > > > >
> > 
> > > > > ```
> > > > > mail_options[:body] = %(Sensu has detected a failed check. Event
> > > > > 
> > > > > ```
> > 
> > > > > analysis follows:
> > 
> > > > > Event Timestamp: #{Time.at(@event[‘check’][‘issued’].to\_i)}
> > 
> > > > > Check That Failed: #{@event[‘check’][‘name’]}
> > 
> > > > > Check Command: #{@event[‘check’][‘command’]}
> > 
> > > > > Check Flapping: #{@event[‘check’][‘flapping’]}
> > 
> > > > > Check Occurrences: #{@event[‘occurrences’]}
> > 
> > > > > Check History: #{@event[‘check’][‘history’].map { |h|
> > 
> > > > > STATUSES[h.to\_i]
> > 
> > > > > }.join(’ =\> ')}
> > 
> > > > > Node Name: #{@event[‘client’][‘name’]}
> > 
> > > > > Node IP Address: #{@event[‘client’][‘address’]}
> > 
> > > > > Node LPOL: #{Time.at(@event[‘client’][‘timestamp’].to\_i)}
> > 
> > > > > Node Subscriptions: #{@event[‘client’][‘subscriptions’].join(', ')}
> > 
> > > > > ====================
> > 
> > > > > === Check Output ===
> > 
> > > > > ====================
> > 
> > > > > #{@event[‘check’][‘output’]}
> > 
> > > > > )
> > 
> > > > > ```
> > > > > Pony.options = mail_options
> > > > > 
> > > > > ```
> > 
> > > > >
> > 
> > > > > ```
> > > > > # #YELLOW
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > unless settings['ponymailer']['recipients'].empty? # rubocop:disable
> > > > > 
> > > > > ```
> > 
> > > > > GuardClause
> > 
> > > > > ```
> > > > > settings['ponymailer']['recipients'].each do |to|
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > begin
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > Timeout.timeout 10 do
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > Pony.mail(to: to)
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > puts 'mail -- sent alert for ' + short_name + ' to ' + to
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > end
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > rescue Timeout::Error
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > puts 'mail -- timed out while attempting to ' + @event['action']
> > > > > 
> > > > > ```
> > 
> > > > > - ’
> > 
> > > > > an incident – ’ + short\_name
> > 
> > > > > ```
> > > > > end
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > end
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > end
> > > > > 
> > > > > ```
> > 
> > > > > end
> > 
> > > > > end
> > 
> > > > >
> > 
> > > > >
> > 
> > > > >
> > 
> > > > > /etc/sensu/conf.d/ponymailer.json
> > 
> > > > > {
> > 
> > > > > ```
> > > > > "ponymailer": {
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > "authenticate":true,
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > "only_send_on_change":false,
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > "username":"xxx@gmail.com",
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > "tls":true,
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > "port":"587",
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > "fromname":"Operations",
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > "hostname":"[smtp.gmail.com](http://smtp.gmail.com)",
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > "password":"xxxx",
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > "from":"ops@xxxx.net",
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > "recipients":[
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > "xxxx@gmail.com"
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > ]
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > }
> > > > > 
> > > > > ```
> > 
> > > > > }
> > 
> > > > >
> > 
> > > > >
> > 
> > > > > /etc/sensu/conf.d/handler\_ponymailer.json
> > 
> > > > > {
> > 
> > > > > ```
> > > > > "handlers": {
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > "ponymailer": {
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > "type": "pipe",
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > "command": "/opt/sensu/embedded/bin/ruby
> > > > > 
> > > > > ```
> > 
> > > > > /etc/sensu/handlers/ponymailer.rb"
> > 
> > > > > ```
> > > > > }
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > }
> > > > > 
> > > > > ```
> > 
> > > > > }
> > 
> > > > >
> > 
> > > > >
> > 
> > > > >
> > 
> > > > >
> > 
> > > > >
> > 
> > > > > {“timestamp”:“2015-06-20T04:57:00.233492+0000”,“level”:“debug”,“message”:"received
> > 
> > > > >
> > 
> > > > > result",“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > -w 303800 -c
> > 
> > > > >
> > 
> > > > > 303800",“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > > > CRITICAL - free system memory: 672 MB\n",“status”:2}}}
> > 
> > > > >
> > 
> > > > > {“timestamp”:“2015-06-20T04:57:00.233610+0000”,“level”:“debug”,“message”:"processing
> > 
> > > > >
> > 
> > > > > result",“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > -w 303800 -c
> > 
> > > > >
> > 
> > > > > 303800",“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > > > CRITICAL - free system memory: 672 MB\n",“status”:2}}}
> > 
> > > > >
> > 
> > > > > {“timestamp”:“2015-06-20T04:57:00.234173+0000”,“level”:“debug”,“message”:"storing
> > 
> > > > > check
> > 
> > > > >
> > 
> > > > > result",“check”:{“handlers”:[“ponymailer”],“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > -w 303800 -c
> > 
> > > > >
> > 
> > > > > 303800",“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > > > CRITICAL - free system memory: 672 MB\n",“status”:2}}
> > 
> > > > >
> > 
> > > > > {“timestamp”:“2015-06-20T04:57:00.235571+0000”,“level”:“info”,“message”:"processing
> > 
> > > > >
> > 
> > > > > event",“event”:{“id”:“b67033bb-9a78-4fd6-a98b-3a525f7bf552”,“client”:{“name”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“address”:“localhost”,“subscriptions”:[“common”],“version”:“0.19.2”,“timestamp”:1434776206},“check”:{“handlers”:[“ponymailer”],“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > -w 303800 -c
> > 
> > > > >
> > 
> > > > > 303800",“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > > > CRITICAL - free system memory: 672
> > 
> > > > >
> > 
> > > > > MB\n",“status”:2,“history”:[“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”],“total\_state\_change”:0},“occurrences”:723,“action”:“create”}}
> > 
> > > > >
> > 
> > > > > {“timestamp”:“2015-06-20T04:57:00.235927+0000”,“level”:“debug”,“message”:"handling
> > 
> > > > >
> > 
> > > > > event",“event\_data”:"{"id":"b67033bb-9a78-4fd6-a98b-3a525f7bf552","client":{"name":"[pdx01.infra.domain.net](http://pdx01.infra.domain.net)","address":"localhost","subscriptions":["common"],"version":"0.19.2","timestamp":1434776206},"check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > -w 303800 -c
> > 
> > > > >
> > 
> > > > > 303800","interval":10,"subscribers":["common"],"name":"memory","issued":1434776220,"executed":1434776220,"duration":0.006,"output":"MEM
> > 
> > > > > CRITICAL - free system memory: 672
> > 
> > > > >
> > 
> > > > > MB\n","status":2,"history":["2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total\_state\_change":0},"occurrences":723,"action":"create"}“,“handler”:{“type”:“pipe”,“command”:”/opt/sensu/embedded/bin/ruby
> > 
> > > > > /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”}}
> > 
> > > > >
> > 
> > > > > {“timestamp”:“2015-06-20T04:57:00.805423+0000”,“level”:“info”,“message”:"handler
> > 
> > > > > output",“handler”:{“type”:“pipe”,“command”:"/opt/sensu/embedded/bin/ruby
> > 
> > > > > /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”},“output”:["only
> > 
> > > > > handling every 180 occurrences: [pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)"]}
> > 
> > > 
> > 
> > > 
> > 
> > > 
> > 
> > > 
> > 
> > > –
> > 
> > > Robert Tsai
> > 
> > > RiverMeadow Operations
> > 
> > > (650) 452 - 2020
> > 
> > >
> 
> –
> 
> **Robert Tsai**
> 
> **RiverMeadow Operations  
> (650) 452 - 2020**

---

<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:** [June 21, 2015, 5:34am UTC](https://discourse.sensu.io/t/emails-not-sending-with-both-mailer-rb-and-polymailer-rb/451/6 "2015-06-21T05:34:29Z")

</div>

Great, there is the smoking gun more or less. Reprinting for readability:

/opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1533:in `addr\_port':  
undefined method `+' for nil:NilClass (NoMethodError)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1466:in  
`begin\_transport'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1408:in  
`transport\_request'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1382:in `request'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1375:in  
`block in request'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:852:in `start'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1373:in `request'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:85:in  
`api\_request'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:120:in  
`stash\_exists?'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:132:in  
`block (2 levels) in filter\_silenced'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:66:in `timeout'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:97:in `timeout'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:131:in  
`block in filter\_silenced'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:129:in  
`each'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:129:in  
`filter\_silenced'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:31:in  
`filter'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:54:in  
`block in \<class:Handler\>'

Makes me think that it isn't pony-mailer related at all.  
Is the "port" setting missing from your general sensu api settings  
configuration? ([https://sensuapp.org/docs/0.19/install-sensu#configure-connections\](https://sensuapp.org/docs/0.19/install-sensu#configure-connections%5C))  
Sensu handlers use the sensu-api to tell if things are silenced or  
not, and that error kinda hints that the port is empty.

> **···**
>
> On Sat, Jun 20, 2015 at 10:25 PM, Robert Tsai \<rtsai@rivermeadow.com\> wrote:
> 
> > Hi Kyle,
> > 
> > Here is what I found after I changed the occurances to 1.
> > 
> > {"timestamp":"2015-06-21T05:23:10.275236+0000","level":"debug","message":"handling  
> > event","event\_data":"{\"id\":\"e455f544-7a70-450d-a9e6-57000e99890c\",\"client\":{\"name\":\"infra.domain.net\",\"address\":\"localhost\",\"subscriptions\":[\"common\"],\"version\":\"0.19.2\",\"timestamp\":1434864189},\"check\":{\"handlers\":[\"ponymailer\"],\"command\":\"/etc/sensu/plugins/check-mem.sh  
> > -w 200 -c  
> > 395064\",\"interval\":10,\"occurrences\":1,\"refresh\":20,\"subscribers\":[\"common\"],\"name\":\"memory\",\"issued\":1434864190,\"executed\":1434864190,\"duration\":0.006,\"output\":\"MEM  
> > CRITICAL - free system memory: 632  
> > MB\\n\",\"status\":2,\"history\":[\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\"],\"total\_state\_change\":0},\"occurrences\":200,\"action\":\"create\"}","handler":{"type":"pipe","command":"/etc/sensu/handlers/ponymailer.rb  
> > ","name":"ponymailer"}}
> > 
> > {"timestamp":"2015-06-21T05:17:50.847345+0000","level":"info","message":"handler  
> > output","handler":{"type":"pipe","command":"/etc/sensu/handlers/ponymailer.rb  
> > ","name":"ponymailer"},"output":["/opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1533:in  
> > `addr_port': undefined method `+' for nil:NilClass  
> > (NoMethodError)\n","\tfrom  
> > /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1466:in  
> > `begin\_transport'\n","\tfrom  
> > /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1408:in  
> > `transport\_request'\n","\tfrom  
> > /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1382:in `request'\n","\tfrom  
> > /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1375:in `block in  
> > request'\n","\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:852:in  
> > `start'\n","\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1373:in  
> > `request'\n","\tfrom  
> > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:85:in  
> > `api\_request'\n","\tfrom  
> > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:120:in  
> > `stash\_exists?'\n","\tfrom  
> > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:132:in  
> > `block (2 levels) in filter\_silenced'\n","\tfrom  
> > /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:66:in `timeout'\n","\tfrom  
> > /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:97:in `timeout'\n","\tfrom  
> > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:131:in  
> > `block in filter\_silenced'\n","\tfrom  
> > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:129:in  
> > `each'\n","\tfrom  
> > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:129:in  
> > `filter\_silenced'\n","\tfrom  
> > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:31:in  
> > `filter'\n","\tfrom  
> > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:54:in  
> > `block in \<class:Handler\>'\n"]}
> > 
> > /opt/sensu/embedded/bin/gem list
> > 
> > \*\*\* LOCAL GEMS \*\*\*
> > 
> > bigdecimal (1.2.0)  
> > io-console (0.4.2)  
> > json (1.7.7)  
> > mail (2.6.3)  
> > mime-types (2.6.1)  
> > minitest (4.3.2)  
> > mixlib-cli (1.5.0)  
> > pony (1.11)  
> > psych (2.0.0)  
> > rake (0.9.6)  
> > rdoc (4.0.0)  
> > sendmail (0.0.1)  
> > sensu-plugin (1.1.0)  
> > test-unit (2.0.0.0)  
> > timeout (0.0.1)  
> > timeout-extensions (0.0.0)
> > 
> > cat /etc/sensu/conf.d/handler\_ponymailer.json  
> > {  
> > &nbsp;&nbsp;&nbsp;&nbsp;"handlers": {  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ponymailer": {  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"type": "pipe",  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"command": "/etc/sensu/handlers/ponymailer.rb "  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
> > &nbsp;&nbsp;&nbsp;&nbsp;}  
> > }
> > 
> > cat /etc/sensu/conf.d/ponymailer.json  
> > {  
> > "ponymailer": {  
> > "authenticate":true,  
> > "only\_send\_on\_change":false,  
> > "username":"user@gmail.com",  
> > "tls":true,  
> > "port":"587",  
> > "fromname":"Operations",  
> > "hostname":"smtp.gmail.com",  
> > "password":"xxxxx",  
> > "from":"ops@xxxx",  
> > "recipients":[  
> > "user@gmail.com"  
> > ]  
> > }  
> > }
> > 
> > On Sat, Jun 20, 2015 at 2:46 PM, Kyle Anderson \<kyle@xkyle.com\> wrote:
> > 
> > > If you want to debug a handler not working, you have to get it "in the  
> > > act"  
> > > You could decrease the occurences setting to "1" so it fires all the time.  
> > > Or maybe grep the logs harder? Are there logs that were logrotated +  
> > > gzipd?
> > > 
> > > zgrep 'handler output' /var/log/sensu-server\*
> > > 
> > > On Sat, Jun 20, 2015 at 1:26 PM, Robert Tsai \<rtsai@rivermeadow.com\> \>\> wrote:  
> > > \> Hey Kyle,  
> > > \>  
> > > \> Thanks for helping out! Below is the grepped output but I'm only seeing  
> > > \> info messages for the handler messages. In my /etc/default/sensu, I  
> > > \> have  
> > > \> LOG\_LEVEL=debug. I have restarted the sensu-server service. Is there  
> > > \> another place I need to change the log level? Thanks again!!  
> > > \>  
> > > \> -Rob  
> > > \>  
> > > \> /ponymailer.rb","name":"ponymailer"},"output":["only handling every 180  
> > > \> occurrences: pdx01.infra.domain.net/memory\n"]}  
> > > \>  
> > > \> {"timestamp":"2015-06-20T20:11:30.814117+0000","level":"info","message":"handler  
> > > \> output","handler":{"type":"pipe","command":"/opt/sensu/embedded/bin/ruby  
> > > \> /etc/sensu/handlers/ponymailer.rb","name":"ponymailer"},"output":["only  
> > > \> handling every 180 occurrences:pdx01.infra.domain.net/memory\n"]}  
> > > \>  
> > > \> {"timestamp":"2015-06-20T20:11:40.807064+0000","level":"info","message":"handler  
> > > \> output","handler":{"type":"pipe","command":"/opt/sensu/embedded/bin/ruby  
> > > \> /etc/sensu/handlers/ponymailer.rb","name":"ponymailer"},"output":["only  
> > > \> handling every 180 occurrences: pdx01.infra.domain.net/memory\n"]}  
> > > \>  
> > > \> {"timestamp":"2015-06-20T20:14:30.838181+0000","level":"info","message":"handler  
> > > \> output","handler":  
> > > \>  
> > > \> On Sat, Jun 20, 2015 at 10:53 AM, Kyle Anderson \<kyle@xkyle.com\> wrote:  
> > > \>\>  
> > > \>\> Can you find events in the log where there was output from the  
> > > \>\> ponymailer command? Or any handler?  
> > > \>\> The one posted was filtered.  
> > > \>\>  
> > > \>\> Try grepping for "handler output" and then grep out "only handling  
> > > \>\> every" to see the relevant log lines.  
> > > \>\>  
> > > \>\> On Fri, Jun 19, 2015 at 10:17 PM, Robert Tsai \<rtsai@rivermeadow.com\> \>\> \>\> wrote:  
> > > \>\> \> HI I can't get either ponymailer nor mailer to send an email out. I  
> > > \>\> \> have  
> > > \>\> \> sendmail installed and was able to send an email with mail -s. Below  
> > > \>\> \> is  
> > > \>\> \> what I have confgured for ponymailer. Any guideline is welcome.  
> > > \>\> \> Thanks,  
> > > \>\> \> Robert  
> > > \>\> \>  
> > > \>\> \> /opt/sensu/embedded/bin/gem list  
> > > \>\> \>  
> > > \>\> \> \*\*\* LOCAL GEMS \*\*\*  
> > > \>\> \>  
> > > \>\> \> amq-protocol (1.9.2)  
> > > \>\> \> amqp (1.5.0)  
> > > \>\> \> async\_sinatra (1.2.0)  
> > > \>\> \> bigdecimal (1.2.0)  
> > > \>\> \> childprocess (0.5.3)  
> > > \>\> \> daemons (1.2.2)  
> > > \>\> \> em-redis-unified (1.0.0)  
> > > \>\> \> em-worker (0.0.2)  
> > > \>\> \> eventmachine (1.0.3)  
> > > \>\> \> ffi (1.9.8)  
> > > \>\> \> io-console (0.4.2)  
> > > \>\> \> ipaddress (0.8.0)  
> > > \>\> \> json (1.7.7)  
> > > \>\> \> mail (2.5.4)  
> > > \>\> \> mime-types (2.6.1, 1.25.1)  
> > > \>\> \> minitest (4.3.2)  
> > > \>\> \> mixlib-cli (1.5.0)  
> > > \>\> \> mixlib-config (2.2.1)  
> > > \>\> \> mixlib-log (1.6.0)  
> > > \>\> \> mixlib-shellout (2.1.0)  
> > > \>\> \> multi\_json (1.11.0)  
> > > \>\> \> ohai (6.16.0)  
> > > \>\> \> polyglot (0.3.5)  
> > > \>\> \> pony (1.11)  
> > > \>\> \> psych (2.0.0)  
> > > \>\> \> rack (1.6.1)  
> > > \>\> \> rack-protection (1.5.3)  
> > > \>\> \> rake (0.9.6)  
> > > \>\> \> rdoc (4.0.0)  
> > > \>\> \> sensu (0.19.2)  
> > > \>\> \> sensu-em (2.5.2)  
> > > \>\> \> sensu-extension (1.1.2)  
> > > \>\> \> sensu-extensions (1.2.0)  
> > > \>\> \> sensu-logger (1.0.0)  
> > > \>\> \> sensu-plugin (1.1.0)  
> > > \>\> \> sensu-settings (1.9.0)  
> > > \>\> \> sensu-spawn (1.2.0)  
> > > \>\> \> sensu-transport (3.0.0)  
> > > \>\> \> sinatra (1.4.6)  
> > > \>\> \> systemu (2.6.5, 2.5.2)  
> > > \>\> \> test-unit (2.0.0.0)  
> > > \>\> \> thin (1.6.3)  
> > > \>\> \> tilt (2.0.1)  
> > > \>\> \> treetop (1.4.15)  
> > > \>\> \> uuidtools (2.1.5)  
> > > \>\> \> yajl-ruby (1.2.1)  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> cat /etc/sensu/handlers/ponymailer.rb  
> > > \>\> \> #!/usr/bin/env ruby  
> > > \>\> \> #  
> > > \>\> \> # Sensu Handler: ponymailer  
> > > \>\> \> #  
> > > \>\> \> # This handler formats alerts as mails and sends them off to a  
> > > \>\> \> pre-defined  
> > > \>\> \> recipient.  
> > > \>\> \> #  
> > > \>\> \> # Copyright 2012 Panagiotis Papadomitsos \<pj@ezgr.net\>  
> > > \>\> \> #  
> > > \>\> \> # Released under the same terms as Sensu (the MIT license); see  
> > > \>\> \> LICENSE  
> > > \>\> \> # for details.  
> > > \>\> \>  
> > > \>\> \> require 'rubygems' if RUBY\_VERSION \< '1.9.0'  
> > > \>\> \> require 'sensu-handler'  
> > > \>\> \> require 'timeout'  
> > > \>\> \> require 'pony'  
> > > \>\> \> require 'date'  
> > > \>\> \>  
> > > \>\> \> class PonyMailer \< Sensu::Handler  
> > > \>\> \> STATUSES = {  
> > > \>\> \> 0 =\> 'OK',  
> > > \>\> \> 1 =\> 'WARNING',  
> > > \>\> \> 2 =\> 'CRITICAL'  
> > > \>\> \> }  
> > > \>\> \>  
> > > \>\> \> def short\_name  
> > > \>\> \> @event['client']['name'] + '/' + @event['check']['name']  
> > > \>\> \> end  
> > > \>\> \>  
> > > \>\> \> def action\_to\_string  
> > > \>\> \> @event['action'].eql?('resolve') ? 'RESOLVED' : 'ALERT'  
> > > \>\> \> end  
> > > \>\> \>  
> > > \>\> \> def handle  
> > > \>\> \> if settings['ponymailer']['only\_send\_on\_change']  
> > > \>\> \> last\_status = @event['check']['history'][-2].to\_i  
> > > \>\> \> if last\_status == @event['check']['status']  
> > > \>\> \> return  
> > > \>\> \> end  
> > > \>\> \> end  
> > > \>\> \>  
> > > \>\> \> mail\_options = {  
> > > \>\> \> subject: "Sensu Monitoring Alert: #{action\_to\_string} ::  
> > > \>\> \> #{short\_name}",  
> > > \>\> \> from: "#{settings['ponymailer']['fromname']}  
> > > \>\> \> \<#{settings['ponymailer']['from']}\>",  
> > > \>\> \> via: :smtp,  
> > > \>\> \> via\_options: {  
> > > \>\> \> address: settings['ponymailer']['hostname'],  
> > > \>\> \> port: settings['ponymailer']['port'],  
> > > \>\> \> enable\_starttls\_auto: settings['ponymailer']['tls']  
> > > \>\> \> },  
> > > \>\> \> charset: 'utf-8',  
> > > \>\> \> sender: settings['ponymailer']['from']  
> > > \>\> \> }  
> > > \>\> \> mail\_options.merge!(via\_options: {  
> > > \>\> \> address:  
> > > \>\> \> settings['ponymailer']['hostname'],  
> > > \>\> \> port: settings['ponymailer']['port'],  
> > > \>\> \> enable\_starttls\_auto:  
> > > \>\> \> settings['ponymailer']['tls'],  
> > > \>\> \> user\_name:  
> > > \>\> \> settings['ponymailer']['username'],  
> > > \>\> \> password:  
> > > \>\> \> settings['ponymailer']['password'],  
> > > \>\> \> authentication: :plain  
> > > \>\> \> }) if settings['ponymailer']['authenticate']  
> > > \>\> \>  
> > > \>\> \> mail\_options[:body] = %(Sensu has detected a failed check. Event  
> > > \>\> \> analysis follows:  
> > > \>\> \> Event Timestamp: #{Time.at(@event['check']['issued'].to\_i)}  
> > > \>\> \> Check That Failed: #{@event['check']['name']}  
> > > \>\> \> Check Command: #{@event['check']['command']}  
> > > \>\> \> Check Flapping: #{@event['check']['flapping']}  
> > > \>\> \> Check Occurrences: #{@event['occurrences']}  
> > > \>\> \> Check History: #{@event['check']['history'].map { |h|  
> > > \>\> \> STATUSES[h.to\_i]  
> > > \>\> \> }.join(' =\> ')}  
> > > \>\> \> Node Name: #{@event['client']['name']}  
> > > \>\> \> Node IP Address: #{@event['client']['address']}  
> > > \>\> \> Node LPOL: #{Time.at(@event['client']['timestamp'].to\_i)}  
> > > \>\> \> Node Subscriptions: #{@event['client']['subscriptions'].join(', ')}  
> > > \>\> \> ====================  
> > > \>\> \> === Check Output ===  
> > > \>\> \> ====================  
> > > \>\> \> #{@event['check']['output']}  
> > > \>\> \> )  
> > > \>\> \> Pony.options = mail\_options  
> > > \>\> \>  
> > > \>\> \> # #YELLOW  
> > > \>\> \> unless settings['ponymailer']['recipients'].empty? #  
> > > \>\> \> rubocop:disable  
> > > \>\> \> GuardClause  
> > > \>\> \> settings['ponymailer']['recipients'].each do |to|  
> > > \>\> \> begin  
> > > \>\> \> Timeout.timeout 10 do  
> > > \>\> \> Pony.mail(to: to)  
> > > \>\> \> puts 'mail -- sent alert for ' + short\_name + ' to ' + to  
> > > \>\> \> end  
> > > \>\> \> rescue Timeout::Error  
> > > \>\> \> puts 'mail -- timed out while attempting to ' +  
> > > \>\> \> @event['action']  
> > > \>\> \> + '  
> > > \>\> \> an incident -- ' + short\_name  
> > > \>\> \> end  
> > > \>\> \> end  
> > > \>\> \> end  
> > > \>\> \> end  
> > > \>\> \> end  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> /etc/sensu/conf.d/ponymailer.json  
> > > \>\> \> {  
> > > \>\> \> "ponymailer": {  
> > > \>\> \> "authenticate":true,  
> > > \>\> \> "only\_send\_on\_change":false,  
> > > \>\> \> "username":"xxx@gmail.com",  
> > > \>\> \> "tls":true,  
> > > \>\> \> "port":"587",  
> > > \>\> \> "fromname":"Operations",  
> > > \>\> \> "hostname":"smtp.gmail.com",  
> > > \>\> \> "password":"xxxx",  
> > > \>\> \> "from":"ops@xxxx.net",  
> > > \>\> \> "recipients":[  
> > > \>\> \> "xxxx@gmail.com"  
> > > \>\> \> ]  
> > > \>\> \> }  
> > > \>\> \> }  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> /etc/sensu/conf.d/handler\_ponymailer.json  
> > > \>\> \> {  
> > > \>\> \> "handlers": {  
> > > \>\> \> "ponymailer": {  
> > > \>\> \> "type": "pipe",  
> > > \>\> \> "command": "/opt/sensu/embedded/bin/ruby  
> > > \>\> \> /etc/sensu/handlers/ponymailer.rb"  
> > > \>\> \> }  
> > > \>\> \> }  
> > > \>\> \> }  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> {"timestamp":"2015-06-20T04:57:00.233492+0000","level":"debug","message":"received  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> result","result":{"client":"pdx01.infra.domain.net","check":{"name":"memory","issued":1434776220,"command":"/etc/sensu/plugins/check-mem.sh  
> > > \>\> \> -w 303800 -c  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> 303800","handlers":["ponymailer"],"interval":10,"subscribers":["common"],"executed":1434776220,"duration":0.006,"output":"MEM  
> > > \>\> \> CRITICAL - free system memory: 672 MB\n","status":2}}}  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> {"timestamp":"2015-06-20T04:57:00.233610+0000","level":"debug","message":"processing  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> result","result":{"client":"pdx01.infra.domain.net","check":{"name":"memory","issued":1434776220,"command":"/etc/sensu/plugins/check-mem.sh  
> > > \>\> \> -w 303800 -c  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> 303800","handlers":["ponymailer"],"interval":10,"subscribers":["common"],"executed":1434776220,"duration":0.006,"output":"MEM  
> > > \>\> \> CRITICAL - free system memory: 672 MB\n","status":2}}}  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> {"timestamp":"2015-06-20T04:57:00.234173+0000","level":"debug","message":"storing  
> > > \>\> \> check  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> result","check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh  
> > > \>\> \> -w 303800 -c  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> 303800","interval":10,"subscribers":["common"],"name":"memory","issued":1434776220,"executed":1434776220,"duration":0.006,"output":"MEM  
> > > \>\> \> CRITICAL - free system memory: 672 MB\n","status":2}}  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> {"timestamp":"2015-06-20T04:57:00.235571+0000","level":"info","message":"processing  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> event","event":{"id":"b67033bb-9a78-4fd6-a98b-3a525f7bf552","client":{"name":"pdx01.infra.domain.net","address":"localhost","subscriptions":["common"],"version":"0.19.2","timestamp":1434776206},"check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh  
> > > \>\> \> -w 303800 -c  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> 303800","interval":10,"subscribers":["common"],"name":"memory","issued":1434776220,"executed":1434776220,"duration":0.006,"output":"MEM  
> > > \>\> \> CRITICAL - free system memory: 672  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> MB\n","status":2,"history":["2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total\_state\_change":0},"occurrences":723,"action":"create"}}  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> {"timestamp":"2015-06-20T04:57:00.235927+0000","level":"debug","message":"handling  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> event","event\_data":"{\"id\":\"b67033bb-9a78-4fd6-a98b-3a525f7bf552\",\"client\":{\"name\":\"pdx01.infra.domain.net\",\"address\":\"localhost\",\"subscriptions\":[\"common\"],\"version\":\"0.19.2\",\"timestamp\":1434776206},\"check\":{\"handlers\":[\"ponymailer\"],\"command\":\"/etc/sensu/plugins/check-mem.sh  
> > > \>\> \> -w 303800 -c  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> 303800\",\"interval\":10,\"subscribers\":[\"common\"],\"name\":\"memory\",\"issued\":1434776220,\"executed\":1434776220,\"duration\":0.006,\"output\":\"MEM  
> > > \>\> \> CRITICAL - free system memory: 672  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> MB\\n\",\"status\":2,\"history\":[\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\"],\"total\_state\_change\":0},\"occurrences\":723,\"action\":\"create\"}","handler":{"type":"pipe","command":"/opt/sensu/embedded/bin/ruby  
> > > \>\> \> /etc/sensu/handlers/ponymailer.rb","name":"ponymailer"}}  
> > > \>\> \>  
> > > \>\> \>  
> > > \>\> \> {"timestamp":"2015-06-20T04:57:00.805423+0000","level":"info","message":"handler  
> > > \>\> \>  
> > > \>\> \> output","handler":{"type":"pipe","command":"/opt/sensu/embedded/bin/ruby  
> > > \>\> \>  
> > > \>\> \> /etc/sensu/handlers/ponymailer.rb","name":"ponymailer"},"output":["only  
> > > \>\> \> handling every 180 occurrences: pdx01.infra.domain.net/memory\n"]}  
> > > \>  
> > > \>  
> > > \>  
> > > \>  
> > > \> --  
> > > \> Robert Tsai  
> > > \> RiverMeadow Operations  
> > > \> (650) 452 - 2020  
> > > \>
> > 
> > --  
> > Robert Tsai  
> > RiverMeadow Operations  
> > (650) 452 - 2020

---

<div class="post-metadata">

**Author:** ![Robert\_Tsai](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@Robert\_Tsai](https://discourse.sensu.io/u/Robert_Tsai)\
**Post date:** [June 21, 2015, 5:48am UTC](https://discourse.sensu.io/t/emails-not-sending-with-both-mailer-rb-and-polymailer-rb/451/7 "2015-06-21T05:48:56Z")

</div>

nope it looks good.

{

“rabbitmq”: {

“host”: “localhost”,

“vhost”: “/sensu”,

“user”: “sensu”,

“password”: “xxxxxxx”

},

“redis”: {

“host”: “localhost”

},

“api”: {

“port”: 4567

}

}

> **···**
>
> On Sat, Jun 20, 2015 at 10:34 PM, Kyle Anderson [kyle@xkyle.com](mailto:kyle@xkyle.com) wrote:
> 
> > Great, there is the smoking gun more or less. Reprinting for readability:
> > 
> > /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1533:in `addr\_port’:
> > 
> > undefined method `+’ for nil:NilClass (NoMethodError)
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1466:in
> > 
> > ```
> > 
> > `begin\_transport’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1408:in
> > 
> > ```
> > 
> > `transport\_request’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1382:in `request'
> > 
> > from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1375:in
> > 
> > ```
> > 
> > `block in request’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:852:in `start'
> > 
> > from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1373:in `request'
> > 
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:85:in
> > 
> > ```
> > 
> > `api\_request’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:120:in
> > 
> > ```
> > 
> > `stash\_exists?’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:132:in
> > 
> > ```
> > 
> > `block (2 levels) in filter\_silenced’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:66:in `timeout'
> > 
> > from /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:97:in `timeout'
> > 
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:131:in
> > 
> > ```
> > 
> > `block in filter\_silenced’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:129:in
> > 
> > ```
> > 
> > `each’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:129:in
> > 
> > ```
> > 
> > `filter\_silenced’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:31:in
> > 
> > ```
> > 
> > `filter’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:54:in
> > 
> > ```
> > 
> > `block in class:Handler’
> > 
> > Makes me think that it isn’t pony-mailer related at all.
> > 
> > Is the “port” setting missing from your general sensu api settings
> > 
> > configuration? ([https://sensuapp.org/docs/0.19/install-sensu#configure-connections](https://sensuapp.org/docs/0.19/install-sensu#configure-connections))
> > 
> > Sensu handlers use the sensu-api to tell if things are silenced or
> > 
> > not, and that error kinda hints that the port is empty.
> > 
> > On Sat, Jun 20, 2015 at 10:25 PM, Robert Tsai [rtsai@rivermeadow.com](mailto:rtsai@rivermeadow.com) wrote:
> > 
> > > Hi Kyle,
> > 
> > > 
> > 
> > > Here is what I found after I changed the occurances to 1.
> > 
> > > 
> > 
> > > {“timestamp”:“2015-06-21T05:23:10.275236+0000”,“level”:“debug”,“message”:"handling
> > 
> > > event",“event\_data”:"{"id":"e455f544-7a70-450d-a9e6-57000e99890c","client":{"name":"[infra.domain.net](http://infra.domain.net)","address":"localhost","subscriptions":["common"],"version":"0.19.2","timestamp":1434864189},"check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh
> > 
> > > -w 200 -c
> > 
> > > 395064","interval":10,"occurrences":1,"refresh":20,"subscribers":["common"],"name":"memory","issued":1434864190,"executed":1434864190,"duration":0.006,"output":"MEM
> > 
> > > CRITICAL - free system memory: 632
> > 
> > > MB\n","status":2,"history":["2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total\_state\_change":0},"occurrences":200,"action":"create"}“,“handler”:{“type”:“pipe”,“command”:”/etc/sensu/handlers/ponymailer.rb
> > 
> > > ",“name”:“ponymailer”}}
> > 
> > > 
> > 
> > > {“timestamp”:“2015-06-21T05:17:50.847345+0000”,“level”:“info”,“message”:"handler
> > 
> > > output",“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/ponymailer.rb
> > 
> > > “,“name”:“ponymailer”},“output”:[”/opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1533:in
> > 
> > > `addr_port': undefined method `+’ for nil:NilClass
> > 
> > > (NoMethodError)\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1466:in
> > 
> > > `begin\_transport’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1408:in
> > 
> > > `transport\_request’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1382:in `request’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1375:in `block in
> > 
> > > request’\n","\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:852:in
> > 
> > > `start’\n","\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1373:in
> > 
> > > `request’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:85:in
> > 
> > > `api\_request’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:120:in
> > 
> > > `stash\_exists?'\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:132:in
> > 
> > > `block (2 levels) in filter\_silenced’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:66:in `timeout’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:97:in `timeout’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:131:in
> > 
> > > `block in filter\_silenced’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:129:in
> > 
> > > `each’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:129:in
> > 
> > > `filter\_silenced’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:31:in
> > 
> > > `filter’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:54:in
> > 
> > > `block in class:Handler’\n"]}
> > 
> > > 
> > 
> > > 
> > 
> > > /opt/sensu/embedded/bin/gem list
> > 
> > > 
> > 
> > > \*\*\* LOCAL GEMS \*\*\*
> > 
> > > 
> > 
> > > bigdecimal (1.2.0)
> > 
> > > io-console (0.4.2)
> > 
> > > json (1.7.7)
> > 
> > > mail (2.6.3)
> > 
> > > mime-types (2.6.1)
> > 
> > > minitest (4.3.2)
> > 
> > > mixlib-cli (1.5.0)
> > 
> > > pony (1.11)
> > 
> > > psych (2.0.0)
> > 
> > > rake (0.9.6)
> > 
> > > rdoc (4.0.0)
> > 
> > > sendmail (0.0.1)
> > 
> > > sensu-plugin (1.1.0)
> > 
> > > test-unit (2.0.0.0)
> > 
> > > timeout (0.0.1)
> > 
> > > timeout-extensions (0.0.0)
> > 
> > > 
> > 
> > > cat /etc/sensu/conf.d/handler\_ponymailer.json
> > 
> > > {
> > 
> > > ```
> > > "handlers": {
> > > 
> > > ```
> > 
> > > ```
> > > "ponymailer": {
> > > 
> > > ```
> > 
> > > ```
> > > "type": "pipe",
> > > 
> > > ```
> > 
> > > ```
> > > "command": "/etc/sensu/handlers/ponymailer.rb "
> > > 
> > > ```
> > 
> > > ```
> > > }
> > > 
> > > ```
> > 
> > > ```
> > > }
> > > 
> > > ```
> > 
> > > }
> > 
> > > 
> > 
> > > cat /etc/sensu/conf.d/ponymailer.json
> > 
> > > {
> > 
> > > “ponymailer”: {
> > 
> > > “authenticate”:true,
> > 
> > > “only\_send\_on\_change”:false,
> > 
> > > “[username":"user@gmail.com](mailto:username%22:%22user@gmail.com)”,
> > 
> > > “tls”:true,
> > 
> > > “port”:“587”,
> > 
> > > “fromname”:“Operations”,
> > 
> > > “hostname”:“[smtp.gmail.com](http://smtp.gmail.com)”,
> > 
> > > “password”:“xxxxx”,
> > 
> > > “from”:“ops@xxxx”,
> > 
> > > “recipients”:[
> > 
> > > “[user@gmail.com](mailto:user@gmail.com)”
> > 
> > > ]
> > 
> > > }
> > 
> > > }
> > 
> > > 
> > 
> > > On Sat, Jun 20, 2015 at 2:46 PM, Kyle Anderson [kyle@xkyle.com](mailto:kyle@xkyle.com) wrote:
> > 
> > > >
> > 
> > > > If you want to debug a handler not working, you have to get it "in the
> > 
> > > > act"
> > 
> > > > You could decrease the occurences setting to “1” so it fires all the time.
> > 
> > > > Or maybe grep the logs harder? Are there logs that were logrotated +
> > 
> > > > gzipd?
> > 
> > > >
> > 
> > > > zgrep ‘handler output’ /var/log/sensu-server\*
> > 
> > > >
> > 
> > > > On Sat, Jun 20, 2015 at 1:26 PM, Robert Tsai [rtsai@rivermeadow.com](mailto:rtsai@rivermeadow.com)
> > 
> > > > wrote:
> > 
> > > > > Hey Kyle,
> > 
> > > > >
> > 
> > > > > Thanks for helping out! Below is the grepped output but I’m only seeing
> > 
> > > > > info messages for the handler messages. In my /etc/default/sensu, I
> > 
> > > > > have
> > 
> > > > > LOG\_LEVEL=debug. I have restarted the sensu-server service. Is there
> > 
> > > > > another place I need to change the log level? Thanks again!!
> > 
> > > > >
> > 
> > > > > -Rob
> > 
> > > > >
> > 
> > > > > /ponymailer.rb",“name”:“ponymailer”},“output”:["only handling every 180
> > 
> > > > > occurrences: [pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)"]}
> > 
> > > > >
> > 
> > > > > {“timestamp”:“2015-06-20T20:11:30.814117+0000”,“level”:“info”,“message”:"handler
> > 
> > > > > output",“handler”:{“type”:“pipe”,“command”:"/opt/sensu/embedded/bin/ruby
> > 
> > > > > /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”},“output”:["only
> > 
> > > > > handling every 180 occurrences:[pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)"]}
> > 
> > > > >
> > 
> > > > > {“timestamp”:“2015-06-20T20:11:40.807064+0000”,“level”:“info”,“message”:"handler
> > 
> > > > > output",“handler”:{“type”:“pipe”,“command”:"/opt/sensu/embedded/bin/ruby
> > 
> > > > > /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”},“output”:["only
> > 
> > > > > handling every 180 occurrences: [pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)"]}
> > 
> > > > >
> > 
> > > > > {“timestamp”:“2015-06-20T20:14:30.838181+0000”,“level”:“info”,“message”:"handler
> > 
> > > > > output",“handler”:
> > 
> > > > >
> > 
> > > > > On Sat, Jun 20, 2015 at 10:53 AM, Kyle Anderson [kyle@xkyle.com](mailto:kyle@xkyle.com) wrote:
> > 
> > > > > >
> > 
> > > > > > Can you find events in the log where there was output from the
> > 
> > > > > > ponymailer command? Or any handler?
> > 
> > > > > > The one posted was filtered.
> > 
> > > > > >
> > 
> > > > > > Try grepping for “handler output” and then grep out "only handling
> > 
> > > > > > every" to see the relevant log lines.
> > 
> > > > > >
> > 
> > > > > > On Fri, Jun 19, 2015 at 10:17 PM, Robert Tsai [rtsai@rivermeadow.com](mailto:rtsai@rivermeadow.com)
> > 
> > > > > > wrote:
> > 
> > > > > > > HI I can’t get either ponymailer nor mailer to send an email out. I
> > 
> > > > > > > have
> > 
> > > > > > > sendmail installed and was able to send an email with mail -s. Below
> > 
> > > > > > > is
> > 
> > > > > > > what I have confgured for ponymailer. Any guideline is welcome.
> > 
> > > > > > > Thanks,
> > 
> > > > > > > Robert
> > 
> > > > > > >
> > 
> > > > > > > /opt/sensu/embedded/bin/gem list
> > 
> > > > > > >
> > 
> > > > > > > \*\*\* LOCAL GEMS \*\*\*
> > 
> > > > > > >
> > 
> > > > > > > amq-protocol (1.9.2)
> > 
> > > > > > > amqp (1.5.0)
> > 
> > > > > > > async\_sinatra (1.2.0)
> > 
> > > > > > > bigdecimal (1.2.0)
> > 
> > > > > > > childprocess (0.5.3)
> > 
> > > > > > > daemons (1.2.2)
> > 
> > > > > > > em-redis-unified (1.0.0)
> > 
> > > > > > > em-worker (0.0.2)
> > 
> > > > > > > eventmachine (1.0.3)
> > 
> > > > > > > ffi (1.9.8)
> > 
> > > > > > > io-console (0.4.2)
> > 
> > > > > > > ipaddress (0.8.0)
> > 
> > > > > > > json (1.7.7)
> > 
> > > > > > > mail (2.5.4)
> > 
> > > > > > > mime-types (2.6.1, 1.25.1)
> > 
> > > > > > > minitest (4.3.2)
> > 
> > > > > > > mixlib-cli (1.5.0)
> > 
> > > > > > > mixlib-config (2.2.1)
> > 
> > > > > > > mixlib-log (1.6.0)
> > 
> > > > > > > mixlib-shellout (2.1.0)
> > 
> > > > > > > multi\_json (1.11.0)
> > 
> > > > > > > ohai (6.16.0)
> > 
> > > > > > > polyglot (0.3.5)
> > 
> > > > > > > pony (1.11)
> > 
> > > > > > > psych (2.0.0)
> > 
> > > > > > > rack (1.6.1)
> > 
> > > > > > > rack-protection (1.5.3)
> > 
> > > > > > > rake (0.9.6)
> > 
> > > > > > > rdoc (4.0.0)
> > 
> > > > > > > sensu (0.19.2)
> > 
> > > > > > > sensu-em (2.5.2)
> > 
> > > > > > > sensu-extension (1.1.2)
> > 
> > > > > > > sensu-extensions (1.2.0)
> > 
> > > > > > > sensu-logger (1.0.0)
> > 
> > > > > > > sensu-plugin (1.1.0)
> > 
> > > > > > > sensu-settings (1.9.0)
> > 
> > > > > > > sensu-spawn (1.2.0)
> > 
> > > > > > > sensu-transport (3.0.0)
> > 
> > > > > > > sinatra (1.4.6)
> > 
> > > > > > > systemu (2.6.5, 2.5.2)
> > 
> > > > > > > test-unit (2.0.0.0)
> > 
> > > > > > > thin (1.6.3)
> > 
> > > > > > > tilt (2.0.1)
> > 
> > > > > > > treetop (1.4.15)
> > 
> > > > > > > uuidtools (2.1.5)
> > 
> > > > > > > yajl-ruby (1.2.1)
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > cat /etc/sensu/handlers/ponymailer.rb
> > 
> > > > > > > #!/usr/bin/env ruby
> > 
> > > > > > > #
> > 
> > > > > > > # Sensu Handler: ponymailer
> > 
> > > > > > > #
> > 
> > > > > > > # This handler formats alerts as mails and sends them off to a
> > 
> > > > > > > pre-defined
> > 
> > > > > > > recipient.
> > 
> > > > > > > #
> > 
> > > > > > > # Copyright 2012 Panagiotis Papadomitsos [pj@ezgr.net](mailto:pj@ezgr.net)
> > 
> > > > > > > #
> > 
> > > > > > > # Released under the same terms as Sensu (the MIT license); see
> > 
> > > > > > > LICENSE
> > 
> > > > > > > # for details.
> > 
> > > > > > >
> > 
> > > > > > > require ‘rubygems’ if RUBY\_VERSION \< ‘1.9.0’
> > 
> > > > > > > require ‘sensu-handler’
> > 
> > > > > > > require ‘timeout’
> > 
> > > > > > > require ‘pony’
> > 
> > > > > > > require ‘date’
> > 
> > > > > > >
> > 
> > > > > > > class PonyMailer \< Sensu::Handler
> > 
> > > > > > > STATUSES = {
> > 
> > > > > > > ```
> > > > > > > 0 => 'OK',
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > 1 => 'WARNING',
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > 2 => 'CRITICAL'
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > }
> > 
> > > > > > >
> > 
> > > > > > > def short\_name
> > 
> > > > > > > ```
> > > > > > > @event['client']['name'] + '/' + @event['check']['name']
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > end
> > 
> > > > > > >
> > 
> > > > > > > def action\_to\_string
> > 
> > > > > > > ```
> > > > > > > @event['action'].eql?('resolve') ? 'RESOLVED' : 'ALERT'
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > end
> > 
> > > > > > >
> > 
> > > > > > > def handle
> > 
> > > > > > > ```
> > > > > > > if settings['ponymailer']['only_send_on_change']
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > last_status = @event['check']['history'][-2].to_i
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > if last_status == @event['check']['status']
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > return
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > end
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > end
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > >
> > 
> > > > > > > ```
> > > > > > > mail_options = {
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > subject: "Sensu Monitoring Alert: #{action_to_string} ::
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > #{short\_name}",
> > 
> > > > > > > ```
> > > > > > > from: "#{settings['ponymailer']['fromname']}
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > \<#{settings[‘ponymailer’][‘from’]}\>",
> > 
> > > > > > > ```
> > > > > > > via: :smtp,
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > via_options: {
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > address: settings['ponymailer']['hostname'],
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > port: settings['ponymailer']['port'],
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > enable_starttls_auto: settings['ponymailer']['tls']
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > },
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > charset: 'utf-8',
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > sender: settings['ponymailer']['from']
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > }
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > mail_options.merge!(via_options: {
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > address:
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > settings[‘ponymailer’][‘hostname’],
> > 
> > > > > > > ```
> > > > > > > port: settings['ponymailer']['port'],
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > enable_starttls_auto:
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > settings[‘ponymailer’][‘tls’],
> > 
> > > > > > > ```
> > > > > > > user_name:
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > settings[‘ponymailer’][‘username’],
> > 
> > > > > > > ```
> > > > > > > password:
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > settings[‘ponymailer’][‘password’],
> > 
> > > > > > > ```
> > > > > > > authentication: :plain
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > }) if settings['ponymailer']['authenticate']
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > >
> > 
> > > > > > > ```
> > > > > > > mail_options[:body] = %(Sensu has detected a failed check. Event
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > analysis follows:
> > 
> > > > > > > Event Timestamp: #{Time.at(@event[‘check’][‘issued’].to\_i)}
> > 
> > > > > > > Check That Failed: #{@event[‘check’][‘name’]}
> > 
> > > > > > > Check Command: #{@event[‘check’][‘command’]}
> > 
> > > > > > > Check Flapping: #{@event[‘check’][‘flapping’]}
> > 
> > > > > > > Check Occurrences: #{@event[‘occurrences’]}
> > 
> > > > > > > Check History: #{@event[‘check’][‘history’].map { |h|
> > 
> > > > > > > STATUSES[h.to\_i]
> > 
> > > > > > > }.join(’ =\> ')}
> > 
> > > > > > > Node Name: #{@event[‘client’][‘name’]}
> > 
> > > > > > > Node IP Address: #{@event[‘client’][‘address’]}
> > 
> > > > > > > Node LPOL: #{Time.at(@event[‘client’][‘timestamp’].to\_i)}
> > 
> > > > > > > Node Subscriptions: #{@event[‘client’][‘subscriptions’].join(', ')}
> > 
> > > > > > > ====================
> > 
> > > > > > > === Check Output ===
> > 
> > > > > > > ====================
> > 
> > > > > > > #{@event[‘check’][‘output’]}
> > 
> > > > > > > )
> > 
> > > > > > > ```
> > > > > > > Pony.options = mail_options
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > >
> > 
> > > > > > > ```
> > > > > > > # #YELLOW
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > unless settings['ponymailer']['recipients'].empty? #
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > rubocop:disable
> > 
> > > > > > > GuardClause
> > 
> > > > > > > ```
> > > > > > > settings['ponymailer']['recipients'].each do |to|
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > begin
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > Timeout.timeout 10 do
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > Pony.mail(to: to)
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > puts 'mail -- sent alert for ' + short_name + ' to ' + to
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > end
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > rescue Timeout::Error
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > puts 'mail -- timed out while attempting to ' +
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > @event[‘action’]
> > 
> > > > > > > - ’
> > 
> > > > > > > an incident – ’ + short\_name
> > 
> > > > > > > ```
> > > > > > > end
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > end
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > end
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > end
> > 
> > > > > > > end
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > /etc/sensu/conf.d/ponymailer.json
> > 
> > > > > > > {
> > 
> > > > > > > ```
> > > > > > > "ponymailer": {
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "authenticate":true,
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "only_send_on_change":false,
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "username":"xxx@gmail.com",
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "tls":true,
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "port":"587",
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "fromname":"Operations",
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "hostname":"[smtp.gmail.com](http://smtp.gmail.com)",
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "password":"xxxx",
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "from":"ops@xxxx.net",
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "recipients":[
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "xxxx@gmail.com"
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > ]
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > }
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > }
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > /etc/sensu/conf.d/handler\_ponymailer.json
> > 
> > > > > > > {
> > 
> > > > > > > ```
> > > > > > > "handlers": {
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "ponymailer": {
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "type": "pipe",
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "command": "/opt/sensu/embedded/bin/ruby
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > /etc/sensu/handlers/ponymailer.rb"
> > 
> > > > > > > ```
> > > > > > > }
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > }
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > }
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > {“timestamp”:“2015-06-20T04:57:00.233492+0000”,“level”:“debug”,“message”:"received
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > result",“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > > > -w 303800 -c
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > 303800",“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > > > > > CRITICAL - free system memory: 672 MB\n",“status”:2}}}
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > {“timestamp”:“2015-06-20T04:57:00.233610+0000”,“level”:“debug”,“message”:"processing
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > result",“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > > > -w 303800 -c
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > 303800",“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > > > > > CRITICAL - free system memory: 672 MB\n",“status”:2}}}
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > {“timestamp”:“2015-06-20T04:57:00.234173+0000”,“level”:“debug”,“message”:"storing
> > 
> > > > > > > check
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > result",“check”:{“handlers”:[“ponymailer”],“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > > > -w 303800 -c
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > 303800",“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > > > > > CRITICAL - free system memory: 672 MB\n",“status”:2}}
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > {“timestamp”:“2015-06-20T04:57:00.235571+0000”,“level”:“info”,“message”:"processing
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > event",“event”:{“id”:“b67033bb-9a78-4fd6-a98b-3a525f7bf552”,“client”:{“name”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“address”:“localhost”,“subscriptions”:[“common”],“version”:“0.19.2”,“timestamp”:1434776206},“check”:{“handlers”:[“ponymailer”],“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > > > -w 303800 -c
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > 303800",“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > > > > > CRITICAL - free system memory: 672
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > MB\n",“status”:2,“history”:[“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”],“total\_state\_change”:0},“occurrences”:723,“action”:“create”}}
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > {“timestamp”:“2015-06-20T04:57:00.235927+0000”,“level”:“debug”,“message”:"handling
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > event",“event\_data”:"{"id":"b67033bb-9a78-4fd6-a98b-3a525f7bf552","client":{"name":"[pdx01.infra.domain.net](http://pdx01.infra.domain.net)","address":"localhost","subscriptions":["common"],"version":"0.19.2","timestamp":1434776206},"check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > > > -w 303800 -c
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > 303800","interval":10,"subscribers":["common"],"name":"memory","issued":1434776220,"executed":1434776220,"duration":0.006,"output":"MEM
> > 
> > > > > > > CRITICAL - free system memory: 672
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > MB\n","status":2,"history":["2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total\_state\_change":0},"occurrences":723,"action":"create"}“,“handler”:{“type”:“pipe”,“command”:”/opt/sensu/embedded/bin/ruby
> > 
> > > > > > > /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”}}
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > {“timestamp”:“2015-06-20T04:57:00.805423+0000”,“level”:“info”,“message”:"handler
> > 
> > > > > > >
> > 
> > > > > > > output",“handler”:{“type”:“pipe”,“command”:"/opt/sensu/embedded/bin/ruby
> > 
> > > > > > >
> > 
> > > > > > > /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”},“output”:["only
> > 
> > > > > > > handling every 180 occurrences: [pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)"]}
> > 
> > > > >
> > 
> > > > >
> > 
> > > > >
> > 
> > > > >
> > 
> > > > > –
> > 
> > > > > Robert Tsai
> > 
> > > > > RiverMeadow Operations
> > 
> > > > > (650) 452 - 2020
> > 
> > > > >
> > 
> > > 
> > 
> > > 
> > 
> > > 
> > 
> > > 
> > 
> > > –
> > 
> > > Robert Tsai
> > 
> > > RiverMeadow Operations
> > 
> > > (650) 452 - 2020
> > 
> > >
> 
> –
> 
> **Robert Tsai**
> 
> **RiverMeadow Operations  
> (650) 452 - 2020**

---

<div class="post-metadata">

**Author:** ![Robert\_Tsai](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@Robert\_Tsai](https://discourse.sensu.io/u/Robert_Tsai)\
**Post date:** [June 21, 2015, 6:16am UTC](https://discourse.sensu.io/t/emails-not-sending-with-both-mailer-rb-and-polymailer-rb/451/8 "2015-06-21T06:16:40Z")

</div>

I set the port manually in /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb. It worked but know I’m getting smtp auth errors which is easy to fix on my end. I wonder why the port isn’t being picked up but at least I’m close to figuring out. Again, hanks for help, Kyle!

> **···**
>
> On Sat, Jun 20, 2015 at 10:48 PM, Robert Tsai [rtsai@rivermeadow.com](mailto:rtsai@rivermeadow.com) wrote:
> 
> > nope it looks good.
> 
> > {
> 
> > “rabbitmq”: {
> 
> > “host”: “localhost”,
> 
> > “vhost”: “/sensu”,
> 
> > “user”: “sensu”,
> 
> > “password”: “xxxxxxx”
> 
> > },
> 
> > “redis”: {
> 
> > “host”: “localhost”
> 
> > },
> 
> > “api”: {
> 
> > “port”: 4567
> 
> > }
> 
> > }
> 
> –
> 
> On Sat, Jun 20, 2015 at 10:34 PM, Kyle Anderson [kyle@xkyle.com](mailto:kyle@xkyle.com) wrote:
> 
> > Great, there is the smoking gun more or less. Reprinting for readability:
> > 
> > /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1533:in `addr\_port’:
> > 
> > undefined method `+’ for nil:NilClass (NoMethodError)
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1466:in
> > 
> > ```
> > 
> > `begin\_transport’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1408:in
> > 
> > ```
> > 
> > `transport\_request’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1382:in `request'
> > 
> > from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1375:in
> > 
> > ```
> > 
> > `block in request’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:852:in `start'
> > 
> > from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1373:in `request'
> > 
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:85:in
> > 
> > ```
> > 
> > `api\_request’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:120:in
> > 
> > ```
> > 
> > `stash\_exists?’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:132:in
> > 
> > ```
> > 
> > `block (2 levels) in filter\_silenced’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:66:in `timeout'
> > 
> > from /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:97:in `timeout'
> > 
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:131:in
> > 
> > ```
> > 
> > `block in filter\_silenced’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:129:in
> > 
> > ```
> > 
> > `each’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:129:in
> > 
> > ```
> > 
> > `filter\_silenced’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:31:in
> > 
> > ```
> > 
> > `filter’
> > 
> > ```
> > from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:54:in
> > 
> > ```
> > 
> > `block in class:Handler’
> > 
> > Makes me think that it isn’t pony-mailer related at all.
> > 
> > Is the “port” setting missing from your general sensu api settings
> > 
> > configuration? ([https://sensuapp.org/docs/0.19/install-sensu#configure-connections](https://sensuapp.org/docs/0.19/install-sensu#configure-connections))
> > 
> > Sensu handlers use the sensu-api to tell if things are silenced or
> > 
> > not, and that error kinda hints that the port is empty.
> > 
> > On Sat, Jun 20, 2015 at 10:25 PM, Robert Tsai [rtsai@rivermeadow.com](mailto:rtsai@rivermeadow.com) wrote:
> > 
> > > Hi Kyle,
> > 
> > > 
> > 
> > > Here is what I found after I changed the occurances to 1.
> > 
> > > 
> > 
> > > {“timestamp”:“2015-06-21T05:23:10.275236+0000”,“level”:“debug”,“message”:"handling
> > 
> > > event",“event\_data”:"{"id":"e455f544-7a70-450d-a9e6-57000e99890c","client":{"name":"[infra.domain.net](http://infra.domain.net)","address":"localhost","subscriptions":["common"],"version":"0.19.2","timestamp":1434864189},"check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh
> > 
> > > -w 200 -c
> > 
> > > 395064","interval":10,"occurrences":1,"refresh":20,"subscribers":["common"],"name":"memory","issued":1434864190,"executed":1434864190,"duration":0.006,"output":"MEM
> > 
> > > CRITICAL - free system memory: 632
> > 
> > > MB\n","status":2,"history":["2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total\_state\_change":0},"occurrences":200,"action":"create"}“,“handler”:{“type”:“pipe”,“command”:”/etc/sensu/handlers/ponymailer.rb
> > 
> > > ",“name”:“ponymailer”}}
> > 
> > > 
> > 
> > > {“timestamp”:“2015-06-21T05:17:50.847345+0000”,“level”:“info”,“message”:"handler
> > 
> > > output",“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/ponymailer.rb
> > 
> > > “,“name”:“ponymailer”},“output”:[”/opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1533:in
> > 
> > > `addr_port': undefined method `+’ for nil:NilClass
> > 
> > > (NoMethodError)\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1466:in
> > 
> > > `begin\_transport’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1408:in
> > 
> > > `transport\_request’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1382:in `request’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1375:in `block in
> > 
> > > request’\n","\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:852:in
> > 
> > > `start’\n","\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1373:in
> > 
> > > `request’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:85:in
> > 
> > > `api\_request’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:120:in
> > 
> > > `stash\_exists?'\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:132:in
> > 
> > > `block (2 levels) in filter\_silenced’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:66:in `timeout’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:97:in `timeout’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:131:in
> > 
> > > `block in filter\_silenced’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:129:in
> > 
> > > `each’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:129:in
> > 
> > > `filter\_silenced’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:31:in
> > 
> > > `filter’\n","\tfrom
> > 
> > > /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:54:in
> > 
> > > `block in class:Handler’\n"]}
> > 
> > > 
> > 
> > > 
> > 
> > > /opt/sensu/embedded/bin/gem list
> > 
> > > 
> > 
> > > \*\*\* LOCAL GEMS \*\*\*
> > 
> > > 
> > 
> > > bigdecimal (1.2.0)
> > 
> > > io-console (0.4.2)
> > 
> > > json (1.7.7)
> > 
> > > mail (2.6.3)
> > 
> > > mime-types (2.6.1)
> > 
> > > minitest (4.3.2)
> > 
> > > mixlib-cli (1.5.0)
> > 
> > > pony (1.11)
> > 
> > > psych (2.0.0)
> > 
> > > rake (0.9.6)
> > 
> > > rdoc (4.0.0)
> > 
> > > sendmail (0.0.1)
> > 
> > > sensu-plugin (1.1.0)
> > 
> > > test-unit (2.0.0.0)
> > 
> > > timeout (0.0.1)
> > 
> > > timeout-extensions (0.0.0)
> > 
> > > 
> > 
> > > cat /etc/sensu/conf.d/handler\_ponymailer.json
> > 
> > > {
> > 
> > > ```
> > > "handlers": {
> > > 
> > > ```
> > 
> > > ```
> > > "ponymailer": {
> > > 
> > > ```
> > 
> > > ```
> > > "type": "pipe",
> > > 
> > > ```
> > 
> > > ```
> > > "command": "/etc/sensu/handlers/ponymailer.rb "
> > > 
> > > ```
> > 
> > > ```
> > > }
> > > 
> > > ```
> > 
> > > ```
> > > }
> > > 
> > > ```
> > 
> > > }
> > 
> > > 
> > 
> > > cat /etc/sensu/conf.d/ponymailer.json
> > 
> > > {
> > 
> > > “ponymailer”: {
> > 
> > > “authenticate”:true,
> > 
> > > “only\_send\_on\_change”:false,
> > 
> > > “[username":"user@gmail.com](mailto:username%22:%22user@gmail.com)”,
> > 
> > > “tls”:true,
> > 
> > > “port”:“587”,
> > 
> > > “fromname”:“Operations”,
> > 
> > > “hostname”:“[smtp.gmail.com](http://smtp.gmail.com)”,
> > 
> > > “password”:“xxxxx”,
> > 
> > > “from”:“ops@xxxx”,
> > 
> > > “recipients”:[
> > 
> > > “[user@gmail.com](mailto:user@gmail.com)”
> > 
> > > ]
> > 
> > > }
> > 
> > > }
> > 
> > > 
> > 
> > > On Sat, Jun 20, 2015 at 2:46 PM, Kyle Anderson [kyle@xkyle.com](mailto:kyle@xkyle.com) wrote:
> > 
> > > >
> > 
> > > > If you want to debug a handler not working, you have to get it "in the
> > 
> > > > act"
> > 
> > > > You could decrease the occurences setting to “1” so it fires all the time.
> > 
> > > > Or maybe grep the logs harder? Are there logs that were logrotated +
> > 
> > > > gzipd?
> > 
> > > >
> > 
> > > > zgrep ‘handler output’ /var/log/sensu-server\*
> > 
> > > >
> > 
> > > > On Sat, Jun 20, 2015 at 1:26 PM, Robert Tsai [rtsai@rivermeadow.com](mailto:rtsai@rivermeadow.com)
> > 
> > > > wrote:
> > 
> > > > > Hey Kyle,
> > 
> > > > >
> > 
> > > > > Thanks for helping out! Below is the grepped output but I’m only seeing
> > 
> > > > > info messages for the handler messages. In my /etc/default/sensu, I
> > 
> > > > > have
> > 
> > > > > LOG\_LEVEL=debug. I have restarted the sensu-server service. Is there
> > 
> > > > > another place I need to change the log level? Thanks again!!
> > 
> > > > >
> > 
> > > > > -Rob
> > 
> > > > >
> > 
> > > > > /ponymailer.rb",“name”:“ponymailer”},“output”:["only handling every 180
> > 
> > > > > occurrences: [pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)"]}
> > 
> > > > >
> > 
> > > > > {“timestamp”:“2015-06-20T20:11:30.814117+0000”,“level”:“info”,“message”:"handler
> > 
> > > > > output",“handler”:{“type”:“pipe”,“command”:"/opt/sensu/embedded/bin/ruby
> > 
> > > > > /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”},“output”:["only
> > 
> > > > > handling every 180 occurrences:[pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)"]}
> > 
> > > > >
> > 
> > > > > {“timestamp”:“2015-06-20T20:11:40.807064+0000”,“level”:“info”,“message”:"handler
> > 
> > > > > output",“handler”:{“type”:“pipe”,“command”:"/opt/sensu/embedded/bin/ruby
> > 
> > > > > /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”},“output”:["only
> > 
> > > > > handling every 180 occurrences: [pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)"]}
> > 
> > > > >
> > 
> > > > > {“timestamp”:“2015-06-20T20:14:30.838181+0000”,“level”:“info”,“message”:"handler
> > 
> > > > > output",“handler”:
> > 
> > > > >
> > 
> > > > > On Sat, Jun 20, 2015 at 10:53 AM, Kyle Anderson [kyle@xkyle.com](mailto:kyle@xkyle.com) wrote:
> > 
> > > > > >
> > 
> > > > > > Can you find events in the log where there was output from the
> > 
> > > > > > ponymailer command? Or any handler?
> > 
> > > > > > The one posted was filtered.
> > 
> > > > > >
> > 
> > > > > > Try grepping for “handler output” and then grep out "only handling
> > 
> > > > > > every" to see the relevant log lines.
> > 
> > > > > >
> > 
> > > > > > On Fri, Jun 19, 2015 at 10:17 PM, Robert Tsai [rtsai@rivermeadow.com](mailto:rtsai@rivermeadow.com)
> > 
> > > > > > wrote:
> > 
> > > > > > > HI I can’t get either ponymailer nor mailer to send an email out. I
> > 
> > > > > > > have
> > 
> > > > > > > sendmail installed and was able to send an email with mail -s. Below
> > 
> > > > > > > is
> > 
> > > > > > > what I have confgured for ponymailer. Any guideline is welcome.
> > 
> > > > > > > Thanks,
> > 
> > > > > > > Robert
> > 
> > > > > > >
> > 
> > > > > > > /opt/sensu/embedded/bin/gem list
> > 
> > > > > > >
> > 
> > > > > > > \*\*\* LOCAL GEMS \*\*\*
> > 
> > > > > > >
> > 
> > > > > > > amq-protocol (1.9.2)
> > 
> > > > > > > amqp (1.5.0)
> > 
> > > > > > > async\_sinatra (1.2.0)
> > 
> > > > > > > bigdecimal (1.2.0)
> > 
> > > > > > > childprocess (0.5.3)
> > 
> > > > > > > daemons (1.2.2)
> > 
> > > > > > > em-redis-unified (1.0.0)
> > 
> > > > > > > em-worker (0.0.2)
> > 
> > > > > > > eventmachine (1.0.3)
> > 
> > > > > > > ffi (1.9.8)
> > 
> > > > > > > io-console (0.4.2)
> > 
> > > > > > > ipaddress (0.8.0)
> > 
> > > > > > > json (1.7.7)
> > 
> > > > > > > mail (2.5.4)
> > 
> > > > > > > mime-types (2.6.1, 1.25.1)
> > 
> > > > > > > minitest (4.3.2)
> > 
> > > > > > > mixlib-cli (1.5.0)
> > 
> > > > > > > mixlib-config (2.2.1)
> > 
> > > > > > > mixlib-log (1.6.0)
> > 
> > > > > > > mixlib-shellout (2.1.0)
> > 
> > > > > > > multi\_json (1.11.0)
> > 
> > > > > > > ohai (6.16.0)
> > 
> > > > > > > polyglot (0.3.5)
> > 
> > > > > > > pony (1.11)
> > 
> > > > > > > psych (2.0.0)
> > 
> > > > > > > rack (1.6.1)
> > 
> > > > > > > rack-protection (1.5.3)
> > 
> > > > > > > rake (0.9.6)
> > 
> > > > > > > rdoc (4.0.0)
> > 
> > > > > > > sensu (0.19.2)
> > 
> > > > > > > sensu-em (2.5.2)
> > 
> > > > > > > sensu-extension (1.1.2)
> > 
> > > > > > > sensu-extensions (1.2.0)
> > 
> > > > > > > sensu-logger (1.0.0)
> > 
> > > > > > > sensu-plugin (1.1.0)
> > 
> > > > > > > sensu-settings (1.9.0)
> > 
> > > > > > > sensu-spawn (1.2.0)
> > 
> > > > > > > sensu-transport (3.0.0)
> > 
> > > > > > > sinatra (1.4.6)
> > 
> > > > > > > systemu (2.6.5, 2.5.2)
> > 
> > > > > > > test-unit (2.0.0.0)
> > 
> > > > > > > thin (1.6.3)
> > 
> > > > > > > tilt (2.0.1)
> > 
> > > > > > > treetop (1.4.15)
> > 
> > > > > > > uuidtools (2.1.5)
> > 
> > > > > > > yajl-ruby (1.2.1)
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > cat /etc/sensu/handlers/ponymailer.rb
> > 
> > > > > > > #!/usr/bin/env ruby
> > 
> > > > > > > #
> > 
> > > > > > > # Sensu Handler: ponymailer
> > 
> > > > > > > #
> > 
> > > > > > > # This handler formats alerts as mails and sends them off to a
> > 
> > > > > > > pre-defined
> > 
> > > > > > > recipient.
> > 
> > > > > > > #
> > 
> > > > > > > # Copyright 2012 Panagiotis Papadomitsos [pj@ezgr.net](mailto:pj@ezgr.net)
> > 
> > > > > > > #
> > 
> > > > > > > # Released under the same terms as Sensu (the MIT license); see
> > 
> > > > > > > LICENSE
> > 
> > > > > > > # for details.
> > 
> > > > > > >
> > 
> > > > > > > require ‘rubygems’ if RUBY\_VERSION \< ‘1.9.0’
> > 
> > > > > > > require ‘sensu-handler’
> > 
> > > > > > > require ‘timeout’
> > 
> > > > > > > require ‘pony’
> > 
> > > > > > > require ‘date’
> > 
> > > > > > >
> > 
> > > > > > > class PonyMailer \< Sensu::Handler
> > 
> > > > > > > STATUSES = {
> > 
> > > > > > > ```
> > > > > > > 0 => 'OK',
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > 1 => 'WARNING',
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > 2 => 'CRITICAL'
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > }
> > 
> > > > > > >
> > 
> > > > > > > def short\_name
> > 
> > > > > > > ```
> > > > > > > @event['client']['name'] + '/' + @event['check']['name']
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > end
> > 
> > > > > > >
> > 
> > > > > > > def action\_to\_string
> > 
> > > > > > > ```
> > > > > > > @event['action'].eql?('resolve') ? 'RESOLVED' : 'ALERT'
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > end
> > 
> > > > > > >
> > 
> > > > > > > def handle
> > 
> > > > > > > ```
> > > > > > > if settings['ponymailer']['only_send_on_change']
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > last_status = @event['check']['history'][-2].to_i
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > if last_status == @event['check']['status']
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > return
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > end
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > end
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > >
> > 
> > > > > > > ```
> > > > > > > mail_options = {
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > subject: "Sensu Monitoring Alert: #{action_to_string} ::
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > #{short\_name}",
> > 
> > > > > > > ```
> > > > > > > from: "#{settings['ponymailer']['fromname']}
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > \<#{settings[‘ponymailer’][‘from’]}\>",
> > 
> > > > > > > ```
> > > > > > > via: :smtp,
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > via_options: {
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > address: settings['ponymailer']['hostname'],
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > port: settings['ponymailer']['port'],
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > enable_starttls_auto: settings['ponymailer']['tls']
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > },
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > charset: 'utf-8',
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > sender: settings['ponymailer']['from']
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > }
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > mail_options.merge!(via_options: {
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > address:
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > settings[‘ponymailer’][‘hostname’],
> > 
> > > > > > > ```
> > > > > > > port: settings['ponymailer']['port'],
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > enable_starttls_auto:
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > settings[‘ponymailer’][‘tls’],
> > 
> > > > > > > ```
> > > > > > > user_name:
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > settings[‘ponymailer’][‘username’],
> > 
> > > > > > > ```
> > > > > > > password:
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > settings[‘ponymailer’][‘password’],
> > 
> > > > > > > ```
> > > > > > > authentication: :plain
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > }) if settings['ponymailer']['authenticate']
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > >
> > 
> > > > > > > ```
> > > > > > > mail_options[:body] = %(Sensu has detected a failed check. Event
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > analysis follows:
> > 
> > > > > > > Event Timestamp: #{Time.at(@event[‘check’][‘issued’].to\_i)}
> > 
> > > > > > > Check That Failed: #{@event[‘check’][‘name’]}
> > 
> > > > > > > Check Command: #{@event[‘check’][‘command’]}
> > 
> > > > > > > Check Flapping: #{@event[‘check’][‘flapping’]}
> > 
> > > > > > > Check Occurrences: #{@event[‘occurrences’]}
> > 
> > > > > > > Check History: #{@event[‘check’][‘history’].map { |h|
> > 
> > > > > > > STATUSES[h.to\_i]
> > 
> > > > > > > }.join(’ =\> ')}
> > 
> > > > > > > Node Name: #{@event[‘client’][‘name’]}
> > 
> > > > > > > Node IP Address: #{@event[‘client’][‘address’]}
> > 
> > > > > > > Node LPOL: #{Time.at(@event[‘client’][‘timestamp’].to\_i)}
> > 
> > > > > > > Node Subscriptions: #{@event[‘client’][‘subscriptions’].join(', ')}
> > 
> > > > > > > ====================
> > 
> > > > > > > === Check Output ===
> > 
> > > > > > > ====================
> > 
> > > > > > > #{@event[‘check’][‘output’]}
> > 
> > > > > > > )
> > 
> > > > > > > ```
> > > > > > > Pony.options = mail_options
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > >
> > 
> > > > > > > ```
> > > > > > > # #YELLOW
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > unless settings['ponymailer']['recipients'].empty? #
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > rubocop:disable
> > 
> > > > > > > GuardClause
> > 
> > > > > > > ```
> > > > > > > settings['ponymailer']['recipients'].each do |to|
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > begin
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > Timeout.timeout 10 do
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > Pony.mail(to: to)
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > puts 'mail -- sent alert for ' + short_name + ' to ' + to
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > end
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > rescue Timeout::Error
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > puts 'mail -- timed out while attempting to ' +
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > @event[‘action’]
> > 
> > > > > > > - ’
> > 
> > > > > > > an incident – ’ + short\_name
> > 
> > > > > > > ```
> > > > > > > end
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > end
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > end
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > end
> > 
> > > > > > > end
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > /etc/sensu/conf.d/ponymailer.json
> > 
> > > > > > > {
> > 
> > > > > > > ```
> > > > > > > "ponymailer": {
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "authenticate":true,
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "only_send_on_change":false,
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "username":"xxx@gmail.com",
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "tls":true,
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "port":"587",
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "fromname":"Operations",
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "hostname":"[smtp.gmail.com](http://smtp.gmail.com)",
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "password":"xxxx",
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "from":"ops@xxxx.net",
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "recipients":[
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "xxxx@gmail.com"
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > ]
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > }
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > }
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > /etc/sensu/conf.d/handler\_ponymailer.json
> > 
> > > > > > > {
> > 
> > > > > > > ```
> > > > > > > "handlers": {
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "ponymailer": {
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "type": "pipe",
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > "command": "/opt/sensu/embedded/bin/ruby
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > /etc/sensu/handlers/ponymailer.rb"
> > 
> > > > > > > ```
> > > > > > > }
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > ```
> > > > > > > }
> > > > > > > 
> > > > > > > ```
> > 
> > > > > > > }
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > {“timestamp”:“2015-06-20T04:57:00.233492+0000”,“level”:“debug”,“message”:"received
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > result",“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > > > -w 303800 -c
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > 303800",“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > > > > > CRITICAL - free system memory: 672 MB\n",“status”:2}}}
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > {“timestamp”:“2015-06-20T04:57:00.233610+0000”,“level”:“debug”,“message”:"processing
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > result",“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > > > -w 303800 -c
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > 303800",“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > > > > > CRITICAL - free system memory: 672 MB\n",“status”:2}}}
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > {“timestamp”:“2015-06-20T04:57:00.234173+0000”,“level”:“debug”,“message”:"storing
> > 
> > > > > > > check
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > result",“check”:{“handlers”:[“ponymailer”],“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > > > -w 303800 -c
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > 303800",“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > > > > > CRITICAL - free system memory: 672 MB\n",“status”:2}}
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > {“timestamp”:“2015-06-20T04:57:00.235571+0000”,“level”:“info”,“message”:"processing
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > event",“event”:{“id”:“b67033bb-9a78-4fd6-a98b-3a525f7bf552”,“client”:{“name”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“address”:“localhost”,“subscriptions”:[“common”],“version”:“0.19.2”,“timestamp”:1434776206},“check”:{“handlers”:[“ponymailer”],“command”:"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > > > -w 303800 -c
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > 303800",“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:"MEM
> > 
> > > > > > > CRITICAL - free system memory: 672
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > MB\n",“status”:2,“history”:[“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”],“total\_state\_change”:0},“occurrences”:723,“action”:“create”}}
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > {“timestamp”:“2015-06-20T04:57:00.235927+0000”,“level”:“debug”,“message”:"handling
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > event",“event\_data”:"{"id":"b67033bb-9a78-4fd6-a98b-3a525f7bf552","client":{"name":"[pdx01.infra.domain.net](http://pdx01.infra.domain.net)","address":"localhost","subscriptions":["common"],"version":"0.19.2","timestamp":1434776206},"check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh
> > 
> > > > > > > -w 303800 -c
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > 303800","interval":10,"subscribers":["common"],"name":"memory","issued":1434776220,"executed":1434776220,"duration":0.006,"output":"MEM
> > 
> > > > > > > CRITICAL - free system memory: 672
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > MB\n","status":2,"history":["2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total\_state\_change":0},"occurrences":723,"action":"create"}“,“handler”:{“type”:“pipe”,“command”:”/opt/sensu/embedded/bin/ruby
> > 
> > > > > > > /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”}}
> > 
> > > > > > >
> > 
> > > > > > >
> > 
> > > > > > > {“timestamp”:“2015-06-20T04:57:00.805423+0000”,“level”:“info”,“message”:"handler
> > 
> > > > > > >
> > 
> > > > > > > output",“handler”:{“type”:“pipe”,“command”:"/opt/sensu/embedded/bin/ruby
> > 
> > > > > > >
> > 
> > > > > > > /etc/sensu/handlers/ponymailer.rb",“name”:“ponymailer”},“output”:["only
> > 
> > > > > > > handling every 180 occurrences: [pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)"]}
> > 
> > > > >
> > 
> > > > >
> > 
> > > > >
> > 
> > > > >
> > 
> > > > > –
> > 
> > > > > Robert Tsai
> > 
> > > > > RiverMeadow Operations
> > 
> > > > > (650) 452 - 2020
> > 
> > > > >
> > 
> > > 
> > 
> > > 
> > 
> > > 
> > 
> > > 
> > 
> > > –
> > 
> > > Robert Tsai
> > 
> > > RiverMeadow Operations
> > 
> > > (650) 452 - 2020
> > 
> > >
> 
> –  
> **Robert Tsai**
> 
> **RiverMeadow Operations  
> (650) 452 - 2020**
> 
> **Robert Tsai**
> 
> **RiverMeadow Operations  
> (650) 452 - 2020**

---

<div class="post-metadata">

**Author:** ![James\_Jelinek](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@James\_Jelinek](https://discourse.sensu.io/u/James_Jelinek)\
**Post date:** [July 23, 2015, 8:22pm UTC](https://discourse.sensu.io/t/emails-not-sending-with-both-mailer-rb-and-polymailer-rb/451/9 "2015-07-23T20:22:23Z")

</div>

Did you ever figure this one out? I have a similar problem that might be related.

> **···**
>
> On Saturday, June 20, 2015 at 12:17:38 AM UTC-5, Robert Tsai wrote:
> 
> > HI I can’t get either ponymailer nor mailer to send an email out. I have sendmail installed and was able to send an email with mail -s. Below is what I have confgured for ponymailer. Any guideline is welcome.  
> > Thanks,  
> > Robert
> > 
> > /opt/sensu/embedded/bin/gem list
> > 
> > \*\*\* LOCAL GEMS \*\*\*
> > 
> > amq-protocol (1.9.2)  
> > amqp (1.5.0)  
> > async\_sinatra (1.2.0)  
> > bigdecimal (1.2.0)  
> > childprocess (0.5.3)  
> > daemons (1.2.2)  
> > em-redis-unified (1.0.0)  
> > em-worker (0.0.2)  
> > eventmachine (1.0.3)  
> > ffi (1.9.8)  
> > io-console (0.4.2)  
> > ipaddress (0.8.0)  
> > json (1.7.7)  
> > mail (2.5.4)  
> > mime-types (2.6.1, 1.25.1)  
> > minitest (4.3.2)  
> > mixlib-cli (1.5.0)  
> > mixlib-config (2.2.1)  
> > mixlib-log (1.6.0)  
> > mixlib-shellout (2.1.0)  
> > multi\_json (1.11.0)  
> > ohai (6.16.0)  
> > polyglot (0.3.5)  
> > pony (1.11)  
> > psych (2.0.0)  
> > rack (1.6.1)  
> > rack-protection (1.5.3)  
> > rake (0.9.6)  
> > rdoc (4.0.0)  
> > sensu (0.19.2)  
> > sensu-em (2.5.2)  
> > sensu-extension (1.1.2)  
> > sensu-extensions (1.2.0)  
> > sensu-logger (1.0.0)  
> > sensu-plugin (1.1.0)  
> > sensu-settings (1.9.0)  
> > sensu-spawn (1.2.0)  
> > sensu-transport (3.0.0)  
> > sinatra (1.4.6)  
> > systemu (2.6.5, 2.5.2)  
> > test-unit (2.0.0.0)  
> > thin (1.6.3)  
> > tilt (2.0.1)  
> > treetop (1.4.15)  
> > uuidtools (2.1.5)  
> > yajl-ruby (1.2.1)
> > 
> > cat /etc/sensu/handlers/ponymailer.rb  
> > #!/usr/bin/env ruby
> > 
> > # 
> > 
> > # Sensu Handler: ponymailer
> > 
> > # 
> > 
> > # This handler formats alerts as mails and sends them off to a pre-defined recipient.
> > 
> > # 
> > 
> > # Copyright 2012 Panagiotis Papadomitsos [p...@ezgr.net](mailto:p...@ezgr.net)
> > 
> > # 
> > 
> > # Released under the same terms as Sensu (the MIT license); see LICENSE
> > 
> > # for details.
> > 
> > require ‘rubygems’ if RUBY\_VERSION \< ‘1.9.0’  
> > require ‘sensu-handler’  
> > require ‘timeout’  
> > require ‘pony’  
> > require ‘date’
> > 
> > class PonyMailer \< Sensu::Handler  
> > STATUSES = {  
> > 0 =\> ‘OK’,  
> > 1 =\> ‘WARNING’,  
> > 2 =\> ‘CRITICAL’  
> > }
> > 
> > def short\_name  
> > @event[‘client’][‘name’] + ‘/’ + @event[‘check’][‘name’]  
> > end
> > 
> > def action\_to\_string  
> > @event[‘action’].eql?(‘resolve’) ? ‘RESOLVED’ : ‘ALERT’  
> > end
> > 
> > def handle  
> > if settings[‘ponymailer’][‘only\_send\_on\_change’]  
> > last\_status = @event[‘check’][‘history’][-2].to\_i  
> > if last\_status == @event[‘check’][‘status’]  
> > return  
> > end  
> > end
> > 
> > ```
> > mail_options = {
> > subject: "Sensu Monitoring Alert: #{action_to_string} :: #{short_name}",
> > from: "#{settings['ponymailer']['fromname']} <#{settings['ponymailer']['from']}>",
> > via: :smtp,
> > via_options: {
> > address: settings['ponymailer']['hostname'],
> > port: settings['ponymailer']['port'],
> > enable_starttls_auto: settings['ponymailer']['tls']
> > },
> > charset: 'utf-8',
> > sender: settings['ponymailer']['from']
> > }
> > mail_options.merge!(via_options: {
> > address: settings['ponymailer']['hostname'],
> > port: settings['ponymailer']['port'],
> > enable_starttls_auto: settings['ponymailer']['tls'],
> > user_name: settings['ponymailer']['username'],
> > password: settings['ponymailer']['password'],
> > authentication: :plain
> > }) if settings['ponymailer']['authenticate']
> > 
> > mail_options[:body] = %(Sensu has detected a failed check. Event analysis follows:
> > 
> > ```
> > 
> > # Event Timestamp: #{Time.at(@event[‘check’][‘issued’].to\_i)} Check That Failed: #{@event[‘check’][‘name’]} Check Command: #{@event[‘check’][‘command’]} Check Flapping: #{@event[‘check’][‘flapping’]} Check Occurrences: #{@event[‘occurrences’]} Check History: #{@event[‘check’][‘history’].map { |h| STATUSES[h.to\_i] }.join(’ =\> ‘)} Node Name: #{@event[‘client’][‘name’]} Node IP Address: #{@event[‘client’][‘address’]} Node LPOL: #{Time.at(@event[‘client’][‘timestamp’].to\_i)} Node Subscriptions: #{@event[‘client’][‘subscriptions’].join(’, ')}
> > 
> > # === Check Output ===
> > 
> > #{@event[‘check’][‘output’]}  
> > )  
> > Pony.options = mail\_options
> > 
> > ```
> > # #YELLOW
> > unless settings['ponymailer']['recipients'].empty? # rubocop:disable GuardClause
> > settings['ponymailer']['recipients'].each do |to|
> > begin
> > Timeout.timeout 10 do
> > Pony.mail(to: to)
> > puts 'mail -- sent alert for ' + short_name + ' to ' + to
> > end
> > rescue Timeout::Error
> > puts 'mail -- timed out while attempting to ' + @event['action'] + ' an incident -- ' + short_name
> > end
> > end
> > end
> > 
> > ```
> > 
> > end  
> > end
> > 
> > /etc/sensu/conf.d/ponymailer.json  
> > {  
> > “ponymailer”: {  
> > “authenticate”:true,  
> > “only\_send\_on\_change”:false,  
> > “[username":"x...@gmail.com](mailto:username%22:%22x...@gmail.com)”,  
> > “tls”:true,  
> > “port”:“587”,  
> > “fromname”:“Operations”,  
> > “hostname”:“[smtp.gmail.com](http://smtp.gmail.com)”,  
> > “password”:“xxxx”,  
> > “[from":"o...@xxxx.net](mailto:from%22:%22o...@xxxx.net)”,  
> > “recipients”:[  
> > “[xx...@gmail.com](mailto:xx...@gmail.com)”  
> > ]  
> > }  
> > }
> > 
> > /etc/sensu/conf.d/handler\_ponymailer.json  
> > {  
> > “handlers”: {  
> > “ponymailer”: {  
> > “type”: “pipe”,  
> > “command”: “/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/ponymailer.rb”  
> > }  
> > }  
> > }
> > 
> > {“timestamp”:“2015-06-20T04:57:00.233492+0000”,“level”:“debug”,“message”:“received result”,“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:“/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800”,“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2}}}  
> > {“timestamp”:“2015-06-20T04:57:00.233610+0000”,“level”:“debug”,“message”:“processing result”,“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:“/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800”,“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2}}}  
> > {“timestamp”:“2015-06-20T04:57:00.234173+0000”,“level”:“debug”,“message”:“storing check result”,“check”:{“handlers”:[“ponymailer”],“command”:“/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800”,“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2}}  
> > {“timestamp”:“2015-06-20T04:57:00.235571+0000”,“level”:“info”,“message”:“processing event”,“event”:{“id”:“b67033bb-9a78-4fd6-a98b-3a525f7bf552”,“client”:{“name”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net)”,“address”:“localhost”,“subscriptions”:[“common”],“version”:“0.19.2”,“timestamp”:1434776206},“check”:{“handlers”:[“ponymailer”],“command”:“/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800”,“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2,“history”:[“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”],“total\_state\_change”:0},“occurrences”:723,“action”:“create”}}  
> > {“timestamp”:“2015-06-20T04:57:00.235927+0000”,“level”:“debug”,“message”:“handling event”,“event\_data”:“{"id":"b67033bb-9a78-4fd6-a98b-3a525f7bf552","client":{"name":"[pdx01.infra.domain.net](http://pdx01.infra.domain.net)","address":"localhost","subscriptions":["common"],"version":"0.19.2","timestamp":1434776206},"check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800","interval":10,"subscribers":["common"],"name":"memory","issued":1434776220,"executed":1434776220,"duration":0.006,"output":"MEM CRITICAL - free system memory: 672 MB\n","status":2,"history":["2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total\_state\_change":0},"occurrences":723,"action":"create"}”,“handler”:{“type”:“pipe”,“command”:“/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/ponymailer.rb”,“name”:“ponymailer”}}  
> > {“timestamp”:“2015-06-20T04:57:00.805423+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:“/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/ponymailer.rb”,“name”:“ponymailer”},“output”:[“only handling every 180 occurrences: [pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)”]}

---

<div class="post-metadata">

**Author:** ![San\_s](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@San\_s](https://discourse.sensu.io/u/San_s)\
**Post date:** [July 24, 2015, 12:51am UTC](https://discourse.sensu.io/t/emails-not-sending-with-both-mailer-rb-and-polymailer-rb/451/10 "2015-07-24T00:51:50Z")

</div>

Try adding “host”: “localhost”, in api config and restart

“api”: {  
**“host”: “localhost”,** “port”: 4567  
}

> **···**
>
> On Jul 23, 2015, at 1:22 PM, James Jelinek [jelinek@gmail.com](mailto:jelinek@gmail.com) wrote:
> 
> > Did you ever figure this one out? I have a similar problem that might be related.
> > 
> > On Saturday, June 20, 2015 at 12:17:38 AM UTC-5, Robert Tsai wrote:
> > 
> > > HI I can’t get either ponymailer nor mailer to send an email out. I have sendmail installed and was able to send an email with mail -s. Below is what I have confgured for ponymailer. Any guideline is welcome.  
> > > Thanks,  
> > > Robert
> > > 
> > > /opt/sensu/embedded/bin/gem list
> > > 
> > > \*\*\* LOCAL GEMS \*\*\*
> > > 
> > > amq-protocol (1.9.2)  
> > > amqp (1.5.0)  
> > > async\_sinatra (1.2.0)  
> > > bigdecimal (1.2.0)  
> > > childprocess (0.5.3)  
> > > daemons (1.2.2)  
> > > em-redis-unified (1.0.0)  
> > > em-worker (0.0.2)  
> > > eventmachine (1.0.3)  
> > > ffi (1.9.8)  
> > > io-console (0.4.2)  
> > > ipaddress (0.8.0)  
> > > json (1.7.7)  
> > > mail (2.5.4)  
> > > mime-types (2.6.1, 1.25.1)  
> > > minitest (4.3.2)  
> > > mixlib-cli (1.5.0)  
> > > mixlib-config (2.2.1)  
> > > mixlib-log (1.6.0)  
> > > mixlib-shellout (2.1.0)  
> > > multi\_json (1.11.0)  
> > > ohai (6.16.0)  
> > > polyglot (0.3.5)  
> > > pony (1.11)  
> > > psych (2.0.0)  
> > > rack (1.6.1)  
> > > rack-protection (1.5.3)  
> > > rake (0.9.6)  
> > > rdoc (4.0.0)  
> > > sensu (0.19.2)  
> > > sensu-em (2.5.2)  
> > > sensu-extension (1.1.2)  
> > > sensu-extensions (1.2.0)  
> > > sensu-logger (1.0.0)  
> > > sensu-plugin (1.1.0)  
> > > sensu-settings (1.9.0)  
> > > sensu-spawn (1.2.0)  
> > > sensu-transport (3.0.0)  
> > > sinatra (1.4.6)  
> > > systemu (2.6.5, 2.5.2)  
> > > test-unit (2.0.0.0)  
> > > thin (1.6.3)  
> > > tilt (2.0.1)  
> > > treetop (1.4.15)  
> > > uuidtools (2.1.5)  
> > > yajl-ruby (1.2.1)
> > > 
> > > cat /etc/sensu/handlers/ponymailer.rb  
> > > #!/usr/bin/env ruby
> > > 
> > > # 
> > > 
> > > # Sensu Handler: ponymailer
> > > 
> > > # 
> > > 
> > > # This handler formats alerts as mails and sends them off to a pre-defined recipient.
> > > 
> > > # 
> > > 
> > > # Copyright 2012 Panagiotis Papadomitsos [p...@ezgr.net](mailto:p...@ezgr.net)
> > > 
> > > # 
> > > 
> > > # Released under the same terms as Sensu (the MIT license); see LICENSE
> > > 
> > > # for details.
> > > 
> > > require ‘rubygems’ if RUBY\_VERSION \< ‘1.9.0’  
> > > require ‘sensu-handler’  
> > > require ‘timeout’  
> > > require ‘pony’  
> > > require ‘date’
> > > 
> > > class PonyMailer \< Sensu::Handler  
> > > STATUSES = {  
> > > 0 =\> ‘OK’,  
> > > 1 =\> ‘WARNING’,  
> > > 2 =\> ‘CRITICAL’  
> > > }
> > > 
> > > def short\_name  
> > > @event[‘client’][‘name’] + ‘/’ + @event[‘check’][‘name’]  
> > > end
> > > 
> > > def action\_to\_string  
> > > @event[‘action’].eql?(‘resolve’) ? ‘RESOLVED’ : ‘ALERT’  
> > > end
> > > 
> > > def handle  
> > > if settings[‘ponymailer’][‘only\_send\_on\_change’]  
> > > last\_status = @event[‘check’][‘history’][-2].to\_i  
> > > if last\_status == @event[‘check’][‘status’]  
> > > return  
> > > end  
> > > end
> > > 
> > > ```
> > > mail_options = {
> > > subject: "Sensu Monitoring Alert: #{action_to_string} :: #{short_name}",
> > > from: "#{settings['ponymailer']['fromname']} <#{settings['ponymailer']['from']}>",
> > > via: :smtp,
> > > via_options: {
> > > address: settings['ponymailer']['hostname'],
> > > port: settings['ponymailer']['port'],
> > > enable_starttls_auto: settings['ponymailer']['tls']
> > > },
> > > charset: 'utf-8',
> > > sender: settings['ponymailer']['from']
> > > }
> > > mail_options.merge!(via_options: {
> > > address: settings['ponymailer']['hostname'],
> > > port: settings['ponymailer']['port'],
> > > enable_starttls_auto: settings['ponymailer']['tls'],
> > > user_name: settings['ponymailer']['username'],
> > > password: settings['ponymailer']['password'],
> > > authentication: :plain
> > > }) if settings['ponymailer']['authenticate']
> > > 
> > > mail_options[:body] = %(Sensu has detected a failed check. Event analysis follows:
> > > 
> > > ```
> > > 
> > > # Event Timestamp: #{[Time.at](http://Time.at)(@event[‘check’][‘issued’].to\_i)} Check That Failed: #{@event[‘check’][‘name’]} Check Command: #{@event[‘check’][‘command’]} Check Flapping: #{@event[‘check’][‘flapping’]} Check Occurrences: #{@event[‘occurrences’]} Check History: #{@event[‘check’][‘history’].map { |h| STATUSES[h.to\_i] }.join(’ =\> ‘)} Node Name: #{@event[‘client’][‘name’]} Node IP Address: #{@event[‘client’][‘address’]} Node LPOL: #{[Time.at](http://Time.at)(@event[‘client’][‘timestamp’].to\_i)} Node Subscriptions: #{@event[‘client’][‘subscriptions’].join(’, ')}
> > > 
> > > # === Check Output ===
> > > 
> > > #{@event[‘check’][‘output’]}  
> > > )  
> > > Pony.options = mail\_options
> > > 
> > > ```
> > > # #YELLOW
> > > unless settings['ponymailer']['recipients'].empty? # rubocop:disable GuardClause
> > > settings['ponymailer']['recipients'].each do |to|
> > > begin
> > > Timeout.timeout 10 do
> > > Pony.mail(to: to)
> > > puts 'mail -- sent alert for ' + short_name + ' to ' + to
> > > end
> > > rescue Timeout::Error
> > > puts 'mail -- timed out while attempting to ' + @event['action'] + ' an incident -- ' + short_name
> > > end
> > > end
> > > end
> > > 
> > > ```
> > > 
> > > end  
> > > end
> > > 
> > > /etc/sensu/conf.d/ponymailer.json  
> > > {  
> > > “ponymailer”: {  
> > > “authenticate”:true,  
> > > “only\_send\_on\_change”:false,  
> > > “[username":"x...@gmail.com](mailto:username%22:%22x...@gmail.com)”,  
> > > “tls”:true,  
> > > “port”:“587”,  
> > > “fromname”:“Operations”,  
> > > “hostname”:“[smtp.gmail.com](http://smtp.gmail.com/)”,  
> > > “password”:“xxxx”,  
> > > “[from":"o...@xxxx.net](mailto:from%22:%22o...@xxxx.net)”,  
> > > “recipients”:[  
> > > “[xx...@gmail.com](mailto:xx...@gmail.com)”  
> > > ]  
> > > }  
> > > }
> > > 
> > > /etc/sensu/conf.d/handler\_ponymailer.json  
> > > {  
> > > “handlers”: {  
> > > “ponymailer”: {  
> > > “type”: “pipe”,  
> > > “command”: “/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/ponymailer.rb”  
> > > }  
> > > }  
> > > }
> > > 
> > > {“timestamp”:“2015-06-20T04:57:00.233492+0000”,“level”:“debug”,“message”:“received result”,“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net/)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:“/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800”,“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2}}}  
> > > {“timestamp”:“2015-06-20T04:57:00.233610+0000”,“level”:“debug”,“message”:“processing result”,“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net/)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:“/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800”,“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2}}}  
> > > {“timestamp”:“2015-06-20T04:57:00.234173+0000”,“level”:“debug”,“message”:“storing check result”,“check”:{“handlers”:[“ponymailer”],“command”:“/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800”,“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2}}  
> > > {“timestamp”:“2015-06-20T04:57:00.235571+0000”,“level”:“info”,“message”:“processing event”,“event”:{“id”:“b67033bb-9a78-4fd6-a98b-3a525f7bf552”,“client”:{“name”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net/)”,“address”:“localhost”,“subscriptions”:[“common”],“version”:“0.19.2”,“timestamp”:1434776206},“check”:{“handlers”:[“ponymailer”],“command”:“/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800”,“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2,“history”:[“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”],“total\_state\_change”:0},“occurrences”:723,“action”:“create”}}  
> > > {“timestamp”:“2015-06-20T04:57:00.235927+0000”,“level”:“debug”,“message”:“handling event”,“event\_data”:“{"id":"b67033bb-9a78-4fd6-a98b-3a525f7bf552","client":{"name":"[pdx01.infra.domain.net](http://pdx01.infra.domain.net/)","address":"localhost","subscriptions":["common"],"version":"0.19.2","timestamp":1434776206},"check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800","interval":10,"subscribers":["common"],"name":"memory","issued":1434776220,"executed":1434776220,"duration":0.006,"output":"MEM CRITICAL - free system memory: 672 MB\n","status":2,"history":["2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total\_state\_change":0},"occurrences":723,"action":"create"}”,“handler”:{“type”:“pipe”,“command”:“/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/ponymailer.rb”,“name”:“ponymailer”}}  
> > > {“timestamp”:“2015-06-20T04:57:00.805423+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:“/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/ponymailer.rb”,“name”:“ponymailer”},“output”:[“only handling every 180 occurrences: [pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)”]}

---

<div class="post-metadata">

**Author:** ![James\_Jelinek](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@James\_Jelinek](https://discourse.sensu.io/u/James_Jelinek)\
**Post date:** [July 24, 2015, 1:44am UTC](https://discourse.sensu.io/t/emails-not-sending-with-both-mailer-rb-and-polymailer-rb/451/11 "2015-07-24T01:44:51Z")

</div>

This was the problem I experienced. It’s not documented that the sensu-plugin doesn’t pick that field up. The Sensu team is going to update the plugin doc to notate that. I spent like 6 hours debugging this today ☹

> **···**
>
> Sent from my iPhone
> 
> On Jul 23, 2015, at 19:51, San s [warpdrive47@gmail.com](mailto:warpdrive47@gmail.com) wrote:
> 
> > Try adding “host”: “localhost”, in api config and restart
> 
> > “api”: {  
> > **“host”: “localhost”,** “port”: 4567  
> > }
> 
> > On Jul 23, 2015, at 1:22 PM, James Jelinek [jelinek@gmail.com](mailto:jelinek@gmail.com) wrote:
> 
> > > Did you ever figure this one out? I have a similar problem that might be related.
> > > 
> > > On Saturday, June 20, 2015 at 12:17:38 AM UTC-5, Robert Tsai wrote:
> > > 
> > > > HI I can’t get either ponymailer nor mailer to send an email out. I have sendmail installed and was able to send an email with mail -s. Below is what I have confgured for ponymailer. Any guideline is welcome.  
> > > > Thanks,  
> > > > Robert
> > > > 
> > > > /opt/sensu/embedded/bin/gem list
> > > > 
> > > > \*\*\* LOCAL GEMS \*\*\*
> > > > 
> > > > amq-protocol (1.9.2)  
> > > > amqp (1.5.0)  
> > > > async\_sinatra (1.2.0)  
> > > > bigdecimal (1.2.0)  
> > > > childprocess (0.5.3)  
> > > > daemons (1.2.2)  
> > > > em-redis-unified (1.0.0)  
> > > > em-worker (0.0.2)  
> > > > eventmachine (1.0.3)  
> > > > ffi (1.9.8)  
> > > > io-console (0.4.2)  
> > > > ipaddress (0.8.0)  
> > > > json (1.7.7)  
> > > > mail (2.5.4)  
> > > > mime-types (2.6.1, 1.25.1)  
> > > > minitest (4.3.2)  
> > > > mixlib-cli (1.5.0)  
> > > > mixlib-config (2.2.1)  
> > > > mixlib-log (1.6.0)  
> > > > mixlib-shellout (2.1.0)  
> > > > multi\_json (1.11.0)  
> > > > ohai (6.16.0)  
> > > > polyglot (0.3.5)  
> > > > pony (1.11)  
> > > > psych (2.0.0)  
> > > > rack (1.6.1)  
> > > > rack-protection (1.5.3)  
> > > > rake (0.9.6)  
> > > > rdoc (4.0.0)  
> > > > sensu (0.19.2)  
> > > > sensu-em (2.5.2)  
> > > > sensu-extension (1.1.2)  
> > > > sensu-extensions (1.2.0)  
> > > > sensu-logger (1.0.0)  
> > > > sensu-plugin (1.1.0)  
> > > > sensu-settings (1.9.0)  
> > > > sensu-spawn (1.2.0)  
> > > > sensu-transport (3.0.0)  
> > > > sinatra (1.4.6)  
> > > > systemu (2.6.5, 2.5.2)  
> > > > test-unit (2.0.0.0)  
> > > > thin (1.6.3)  
> > > > tilt (2.0.1)  
> > > > treetop (1.4.15)  
> > > > uuidtools (2.1.5)  
> > > > yajl-ruby (1.2.1)
> > > > 
> > > > cat /etc/sensu/handlers/ponymailer.rb  
> > > > #!/usr/bin/env ruby
> > > > 
> > > > # 
> > > > 
> > > > # Sensu Handler: ponymailer
> > > > 
> > > > # 
> > > > 
> > > > # This handler formats alerts as mails and sends them off to a pre-defined recipient.
> > > > 
> > > > # 
> > > > 
> > > > # Copyright 2012 Panagiotis Papadomitsos [p...@ezgr.net](mailto:p...@ezgr.net)
> > > > 
> > > > # 
> > > > 
> > > > # Released under the same terms as Sensu (the MIT license); see LICENSE
> > > > 
> > > > # for details.
> > > > 
> > > > require ‘rubygems’ if RUBY\_VERSION \< ‘1.9.0’  
> > > > require ‘sensu-handler’  
> > > > require ‘timeout’  
> > > > require ‘pony’  
> > > > require ‘date’
> > > > 
> > > > class PonyMailer \< Sensu::Handler  
> > > > STATUSES = {  
> > > > 0 =\> ‘OK’,  
> > > > 1 =\> ‘WARNING’,  
> > > > 2 =\> ‘CRITICAL’  
> > > > }
> > > > 
> > > > def short\_name  
> > > > @event[‘client’][‘name’] + ‘/’ + @event[‘check’][‘name’]  
> > > > end
> > > > 
> > > > def action\_to\_string  
> > > > @event[‘action’].eql?(‘resolve’) ? ‘RESOLVED’ : ‘ALERT’  
> > > > end
> > > > 
> > > > def handle  
> > > > if settings[‘ponymailer’][‘only\_send\_on\_change’]  
> > > > last\_status = @event[‘check’][‘history’][-2].to\_i  
> > > > if last\_status == @event[‘check’][‘status’]  
> > > > return  
> > > > end  
> > > > end
> > > > 
> > > > ```
> > > > mail_options = {
> > > > subject: "Sensu Monitoring Alert: #{action_to_string} :: #{short_name}",
> > > > from: "#{settings['ponymailer']['fromname']} <#{settings['ponymailer']['from']}>",
> > > > via: :smtp,
> > > > via_options: {
> > > > address: settings['ponymailer']['hostname'],
> > > > port: settings['ponymailer']['port'],
> > > > enable_starttls_auto: settings['ponymailer']['tls']
> > > > },
> > > > charset: 'utf-8',
> > > > sender: settings['ponymailer']['from']
> > > > }
> > > > mail_options.merge!(via_options: {
> > > > address: settings['ponymailer']['hostname'],
> > > > port: settings['ponymailer']['port'],
> > > > enable_starttls_auto: settings['ponymailer']['tls'],
> > > > user_name: settings['ponymailer']['username'],
> > > > password: settings['ponymailer']['password'],
> > > > authentication: :plain
> > > > }) if settings['ponymailer']['authenticate']
> > > > 
> > > > mail_options[:body] = %(Sensu has detected a failed check. Event analysis follows:
> > > > 
> > > > ```
> > > > 
> > > > # Event Timestamp: #{[Time.at](http://Time.at)(@event[‘check’][‘issued’].to\_i)} Check That Failed: #{@event[‘check’][‘name’]} Check Command: #{@event[‘check’][‘command’]} Check Flapping: #{@event[‘check’][‘flapping’]} Check Occurrences: #{@event[‘occurrences’]} Check History: #{@event[‘check’][‘history’].map { |h| STATUSES[h.to\_i] }.join(’ =\> ‘)} Node Name: #{@event[‘client’][‘name’]} Node IP Address: #{@event[‘client’][‘address’]} Node LPOL: #{[Time.at](http://Time.at)(@event[‘client’][‘timestamp’].to\_i)} Node Subscriptions: #{@event[‘client’][‘subscriptions’].join(’, ')}
> > > > 
> > > > # === Check Output ===
> > > > 
> > > > #{@event[‘check’][‘output’]}  
> > > > )  
> > > > Pony.options = mail\_options
> > > > 
> > > > ```
> > > > # #YELLOW
> > > > unless settings['ponymailer']['recipients'].empty? # rubocop:disable GuardClause
> > > > settings['ponymailer']['recipients'].each do |to|
> > > > begin
> > > > Timeout.timeout 10 do
> > > > Pony.mail(to: to)
> > > > puts 'mail -- sent alert for ' + short_name + ' to ' + to
> > > > end
> > > > rescue Timeout::Error
> > > > puts 'mail -- timed out while attempting to ' + @event['action'] + ' an incident -- ' + short_name
> > > > end
> > > > end
> > > > end
> > > > 
> > > > ```
> > > > 
> > > > end  
> > > > end
> > > > 
> > > > /etc/sensu/conf.d/ponymailer.json  
> > > > {  
> > > > “ponymailer”: {  
> > > > “authenticate”:true,  
> > > > “only\_send\_on\_change”:false,  
> > > > “[username":"x...@gmail.com](mailto:username%22:%22x...@gmail.com)”,  
> > > > “tls”:true,  
> > > > “port”:“587”,  
> > > > “fromname”:“Operations”,  
> > > > “hostname”:“[smtp.gmail.com](http://smtp.gmail.com/)”,  
> > > > “password”:“xxxx”,  
> > > > “[from":"o...@xxxx.net](mailto:from%22:%22o...@xxxx.net)”,  
> > > > “recipients”:[  
> > > > “[xx...@gmail.com](mailto:xx...@gmail.com)”  
> > > > ]  
> > > > }  
> > > > }
> > > > 
> > > > /etc/sensu/conf.d/handler\_ponymailer.json  
> > > > {  
> > > > “handlers”: {  
> > > > “ponymailer”: {  
> > > > “type”: “pipe”,  
> > > > “command”: “/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/ponymailer.rb”  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > {“timestamp”:“2015-06-20T04:57:00.233492+0000”,“level”:“debug”,“message”:“received result”,“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net/)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:“/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800”,“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2}}}  
> > > > {“timestamp”:“2015-06-20T04:57:00.233610+0000”,“level”:“debug”,“message”:“processing result”,“result”:{“client”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net/)”,“check”:{“name”:“memory”,“issued”:1434776220,“command”:“/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800”,“handlers”:[“ponymailer”],“interval”:10,“subscribers”:[“common”],“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2}}}  
> > > > {“timestamp”:“2015-06-20T04:57:00.234173+0000”,“level”:“debug”,“message”:“storing check result”,“check”:{“handlers”:[“ponymailer”],“command”:“/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800”,“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2}}  
> > > > {“timestamp”:“2015-06-20T04:57:00.235571+0000”,“level”:“info”,“message”:“processing event”,“event”:{“id”:“b67033bb-9a78-4fd6-a98b-3a525f7bf552”,“client”:{“name”:“[pdx01.infra.domain.net](http://pdx01.infra.domain.net/)”,“address”:“localhost”,“subscriptions”:[“common”],“version”:“0.19.2”,“timestamp”:1434776206},“check”:{“handlers”:[“ponymailer”],“command”:“/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800”,“interval”:10,“subscribers”:[“common”],“name”:“memory”,“issued”:1434776220,“executed”:1434776220,“duration”:0.006,“output”:“MEM CRITICAL - free system memory: 672 MB\n”,“status”:2,“history”:[“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”],“total\_state\_change”:0},“occurrences”:723,“action”:“create”}}  
> > > > {“timestamp”:“2015-06-20T04:57:00.235927+0000”,“level”:“debug”,“message”:“handling event”,“event\_data”:“{"id":"b67033bb-9a78-4fd6-a98b-3a525f7bf552","client":{"name":"[pdx01.infra.domain.net](http://pdx01.infra.domain.net/)","address":"localhost","subscriptions":["common"],"version":"0.19.2","timestamp":1434776206},"check":{"handlers":["ponymailer"],"command":"/etc/sensu/plugins/check-mem.sh -w 303800 -c 303800","interval":10,"subscribers":["common"],"name":"memory","issued":1434776220,"executed":1434776220,"duration":0.006,"output":"MEM CRITICAL - free system memory: 672 MB\n","status":2,"history":["2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total\_state\_change":0},"occurrences":723,"action":"create"}”,“handler”:{“type”:“pipe”,“command”:“/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/ponymailer.rb”,“name”:“ponymailer”}}  
> > > > {“timestamp”:“2015-06-20T04:57:00.805423+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:“/opt/sensu/embedded/bin/ruby /etc/sensu/handlers/ponymailer.rb”,“name”:“ponymailer”},“output”:[“only handling every 180 occurrences: [pdx01.infra.domain.net/memory\n](http://pdx01.infra.domain.net/memory%5Cn)”]}
> 
> >
