sensu-plugins / sensu-plugins-microsoft-teams

Sensu plugins for Microsoft Teams

Home Page:http://sensu-plugins.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plugin erroring when being called in Sensu

asachs01 opened this issue · comments

I'm attempting to use the plugin to send a notification in Teams, but am receiving the error below.

Error Message

{"timestamp":"2018-09-11T18:06:45.242590+0000","level":"info","message":"handler output","handler":{"type":"pipe","command":"handler-microsoft-teams.rb","severites":["critical","warning","unknown"],"name":"microsoft-teams"},"event":{"id":"7eb278f7-80dd-4226-9312-d1edc9d39c1b"},"output":["/opt/sensu/embedded/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- erubis (LoadError)\n\tfrom /opt/sensu/embedded/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-microsoft-teams-1.3.0/bin/handler-microsoft-teams.rb:17:in `<top (required)>'\n\tfrom /opt/sensu/embedded/bin/handler-microsoft-teams.rb:22:in `load'\n\tfrom /opt/sensu/embedded/bin/handler-microsoft-teams.rb:22:in `<main>'\nwarning: event filtering in sensu-plugin is deprecated, see http://bit.ly/sensu-plugin\nwarning: occurrence filtering in sensu-plugin is deprecated, see http://bit.ly/sensu-plugin\nonly handling every 60 occurrences: sensu-enterprise-test/testing_ms_teams_1\n"]}

Testing

I'm using the following call test to the local socket to produce the error:

echo '{"name": "testing_ms_teams_1", "status": 2, "outt": "testing ms teams plugin", "handlers": [ "microsoft-teams"]}' | nc 127.0.0.1 3030

Configuration files

The config for the plugin is as follows:

{
  "handlers": {
    "microsoft-teams": {
      "type": "pipe",
      "command": "handler-microsoft-teams.rb",
      "severites": ["critical", "warning", "unknown"]
      }
    },
  "microsoft-teams": {
    "webhook_url": "https://outlook.office.com/webhook/XXXXXXXXXXXXXXXXX",
    "message_template": "/etc/sensu/conf.d/templates/ms_teams.erb"
  }
}

And the template being used looks like:

Sensu has detected a status change of a check.  Please note the following details:

Client: <%= @event[:client][:name] %>

Check: <%= @event[:check][:name] %>

Output: <%= @event[:check][:output] %>

Status: <%= @event[:check][:status] %> -- (0 = OK, 1 = Warning, 2 = Critical.  Any other number = unknown or a custom status)

Instructions (if there is a problem - check output section): <%= @event[:check][:notification] %>

For more information, please consult the Sensu Enterprise dashboard:

http://DASHBOARDURL:3000/#/client/<%= @event[:client][:datacenter] %>/<%= @event[:client][:name] %>?check=<%= @event[:check][:name] %>

System Info:

  • OS: Centos 7
  • Sensu Versions
sensu.x86_64                       1:1.4.2-4.el7               @sensu
sensu-enterprise.noarch            3.0.3-1                     @sensu-enterprise
sensu-enterprise-dashboard.x86_64  1:2.12.0-1                  @sensu-enterprise-dashboard

It's also worth noting that the error happens whether using Sensu Enterprise or Sensu Core.

After some investigation, it looks like erubis isn't apart of the gemspec, and doesn't actually get installed when installing the plugin, which causes the error seen in my initial comment. Adding this to the gemspec in an incoming PR.

I am reporting the same issues (using Sensu Enterprise 3.03). If we remove the Notification from the check, the alert shows up in Teams, but with issues #5 and #6