sensu-plugins / sensu-plugins-sensu

This plugin provides monitoring and metrics for Sensu.
http://sensu-plugins.io
MIT License
12 stars 35 forks source link

no implicit conversion of Integer into String (TypeError) using handler_sensu #69

Closed csoleimani closed 6 years ago

csoleimani commented 6 years ago

I have been getting an error when trying to use the remediation handler. Here are the configs I'm using check config:

{
    "checks": {
        "check-swap-with-remediation": {
            "command": "/opt/sensu/embedded/bin/ruby /opt/sensu/embedded/bin/check-swap-percent.rb -w 5 -c 10",
            "contact": [
                "default"
            ],
            "handle_when": {
                "occurrences": 2
            },
            "handlers": [
                "remediator",
                "default"
            ],
            "interval": 60,
            "remediation": {
                "remediate-check-swap": {
                    "occurrences": [
                        "1+"
                    ],
                    "severities": [
                        2
                    ]
                }
            },
            "standalone": true,
            "subscribers": [
                "swap"
            ]
        }
    }
}

remediation (unpublished check):

{
    "checks": {
        "remediate-check-swap": {
            "command": "sudo /opt/sensu/embedded/bin/fixswap.sh",
            "handlers": [
               "default"
            ],
            "interval": 60,
            "publish": false,
            "standalone": false,
            "subscribers": [
                "swap"
            ]
        }
    }
}

Here is the error I'm getting:

event":{"id":"752e2445-bd44-464a-8df6-fdd4551fc778"},"output":["/etc/sensu/handlers/remediator.rb:115:in `include?': no implicit conversion of Integer into String (TypeError)\n\tfrom /etc/sensu/handlers/remediator.rb:115:in `block in parse_remediations'\n\tfrom /etc/sensu/handlers/remediator.rb:113:in `each'\n\tfrom /etc/sensu/handlers/remediator.rb:113:in `parse_remediations'\n\tfrom /etc/sensu/handlers/remediator.rb:94:in `handle'\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-2.0.1/lib/sensu-handler.rb:83:in `block in <class:Handler>'\nREMEDIATION: Evaluating remediation: hostname.localdomain check-swap-with-remediation {\"remediate-check-swap\"=>{\"occurrences\"=>\"[1]\", \"severities\"=>\"[2]\"}} #=85 sev=2\n"]}

Please let me know if you need any more info on my end @majormoses

csoleimani commented 6 years ago

Nevermind, I got this working. The fixswap.sh wasn't executable

majormoses commented 6 years ago

Ah I had started looking into it but pretty baffled and planned on taking a closer look over the weekend. Glad I'm not crazy and the code works. That being said we probably should handle that error better. At least now I know how to reproduce it now.