Sensu Emailer `parse_options':无效选项:-j (OptionParser::InvalidOption)

Sensu Emailer `parse_options': invalid option: -j (OptionParser::InvalidOption)

正在尝试为 sensu 设置 amazon ses

设置 1 我有

handler-mailer.rb -j mailme_using_amazonses in my config.json

并且 handler-mailer.rb 在我的 /etc/sensu/plugins 文件夹中

当我在命令行上 运行 时,出现错误

ruby /etc/sensu/plugins/handler-mailer.rb -j mailme_using_amazonses
/var/lib/gems/1.9.1/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:230:in `parse_options': invalid option: -j (OptionParser::InvalidOption)
    from /var/lib/gems/1.9.1/gems/sensu-plugin-1.4.3/lib/sensu-handler.rb:18:in `initialize'
    from /var/lib/gems/1.9.1/gems/sensu-plugin-1.4.3/lib/sensu-handler.rb:78:in `new'
    from /var/lib/gems/1.9.1/gems/sensu-plugin-1.4.3/lib/sensu-handler.rb:78:in `block in <class:Handler>'
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- erubis (LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /etc/sensu/plugins/handler-mailer.rb:20:in `<main>'

我的mailme_using_amazonses有以下

{
    "handlers": {
        "mailer-ses": {
           "mail_from": "from@example.com",
           "mail_to": "to@example.com",
           "use_ami_role": true,
           "secret_key": "MyKey",
           "access_key": "MyAccess",
           "region": "us-west-2"
        }
    }
}

设置 2config.json 我有以下

{
.. other config ..
 "handlers": {
    "handler-ses": {  **HERE I ALSO TRIED "ses"**
      "mail_from": "from@example.com",
      "mail_to": "to@example.com",
      "use_ami_role": true,
      "access_key": "accesskey",
      "secret_key": "secretekey",
      "region": "us-west-2",
      "subscriptions": {
        "subscription_name": {
          "mail_to": "teamemail@example.com"
        }
      }
    }
  }
}

当我重新启动时 sensu-server 我得到以下错误

configuration is invalid
{
  "errors":[
    {
      "object":{
        "mail_from":"from@example.com",
        "mail_to":"to@example.com",
        "use_ami_role":true,
        "access_key":"accesskey",
        "secret_key":"secretkey",
        "region":"us-west-2",
        "subscriptions":{
          "subscription_name":{
            "mail_to":"teamemail@example.com"
          }
        },
        "name":"handler-ses"
      },
      "message":"handler type must be a string"
    },
    {
      "object":{
        "mail_from":"from@example.com",
        "mail_to":"to@example.com",
        "use_ami_role":true,
        "access_key":"accesskey",
        "secret_key":"secretkey",
        "region":"us-west-2",
        "subscriptions":{
          "subscription_name":{
            "mail_to":"teamemail@example.com"
          }
        },
        "name":"handler-ses"
      },
      "message":"unknown handler type"
    }
  ]
}

我在这里错过了什么?

我解决了这个问题。我阅读了 handler-ses.rb 文件。这里注意到配置应该在 ses.json 中。我将 Setup 2 ses 配置从 config.json json 复制到 ses.json 并将其放在 /etc/sensu/handers 文件夹下。错误消失了。不过我还没有收到邮件。

我会在 ses 电子邮件正常工作后更新此答案。