ruby-on-rails – Sensu Emailer`parse_options’:无效选项:-j(OptionParser :: InvalidOption)

试图设置amazon ses for sensu

设置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"
        }
    }
}

设置2
在config.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文件夹下.错误消失了.我还没收到电子邮件.

在我收到电子邮件工作后会更新这个答案.

点赞