`require': cannot load such file -- sensu-plugin/metric/cli

Hi,

I’m using Sensu-go: sensu-backend version 5.15.0, build 13884593ee08a7f25d7f66a8b71da61c529de014, built 2019-11-19T20:18:33Z on Ubuntu 18.04

I’m trying to get check running, but i’m runing into not found and cannot load issues.

I have tried installing plugins via sensuctl

sensuctl asset create sensu-ruby-runtime --url 'https://github.com/sensu-plugins/sensu-plugins-nginx/archive/3.0.0.tar.gz' --sha512 'b18ab006ae3edf77a6485eff2b0a2a1f9e653bd5e789eaea6691def592159f322a204d5586d26572c6882dee15e14d5c494159e2b8d5616f41473b1524d3fc8d'

and creating a check:

sensuctl check create check-disk --command "metrics-disk-usage.rb -w 50 -W 80" --interval 60 --subscriptions system --runtime-assets sensu-plugins/sensu-plugins-disk-checks,sensu/sensu-ruby-runtime

When I view the events I see this.

usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in require’: cannot load such file – sensu-plugin/metric/cli (LoadError)
from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in require' from /var/cache/sensu/sensu-agent/0253c3eb83ca95ef21c1aede03f8e7ec80431a1e363246a4eb4c9b6e2d619060f1d06f6c11eef107e7eb8bd9b16be236ca53120839255362699ed4c05644d596/lib/ruby/2.4.0/bundler/gems/sensu-plugins-disk-checks-0bd87037cbdb/bin/metrics-disk-usage.rb:48:in <top (required)>’
from /var/cache/sensu/sensu-agent/0253c3eb83ca95ef21c1aede03f8e7ec80431a1e363246a4eb4c9b6e2d619060f1d06f6c11eef107e7eb8bd9b16be236ca53120839255362699ed4c05644d596/bin/metrics-disk-usage.rb:14:in load' from /var/cache/sensu/sensu-agent/0253c3eb83ca95ef21c1aede03f8e7ec80431a1e363246a4eb4c9b6e2d619060f1d06f6c11eef107e7eb8bd9b16be236ca53120839255362699ed4c05644d596/bin/metrics-disk-usage.rb:14:in

I have also tried to install plugins with sensu-install. but I get this error

sh: 1: check-cpu.rb: not found

I’m not that familiar with Ruby and gems. Can anybody point me to the solution

Hey,
You’ve got a couple of mistakes in your commands.
And on top of that you are probably trying to use the wrong approach over all…there is an easier way to add assets now.

First the mistakes you are making:
Take a look at your asset create command closely.
You are using the nginx plugin tarball but calling it the ‘sensu-ruby-runtime’
You aren’t actually installing the sensu-ruby-runtime binary.

Also you are refering to your asset in your check as ‘sensu/sensu-ruby-runtime’ but you named the asset ‘sensu-ruby-runtime’
Its a good idea to review what the asset names are in your local config by running
‘sensuctl asset list’

As to approach, take a look at the new bonsai integration instead of using the explicit --url and --sha512 options
For example:
senusctl asset add sensu/sensu-ruby-runtime

will have sensuctl talk to bonsai.sensu.io and grab the mult-build asset configuration for sensu-ruby-runtime which will include the asset filters recommended by the maintainers of the assets.

The way you are doing it right now, as you just discovered, is more error prone and will required additional setup to correctly apply asset filters to ensure you arent trying to use a builds on the wrong target platform.

Hope this helps

Hi,

Thanks for the quick reply. I think the nginx and ruby runtime was a copy and paste error. I have tried to use the bonsai asset add syntax. I’ts much easier and cleaner syntax.

I tried this:

sensuctl asset add sensu-plugins/sensu-plugins-aws

sensuctl check create check-aws-instance-health --command 'check-instance-health.rb --aws-region eu-central-1' --interval 60 --subscriptions system,aws-ec2 --runtime-assets sensu-plugins-aws,sensu-ruby-runtime'

in the check I get this error

sh: 1: check-instance-health.rb: not found

Any idea what i’m doing wrong?

Your check create is malformed still

The asset created by the ‘asset add’ command is named ‘sensu-plugins/sensu-plugins-aws’

You are trying to use an asset named ‘sensu-plugins-aws’

It’s a good habit in generate to review your asset inventory before doing the check creates… sensuctl asset list

This will ensure you use the correct name…and if you are using multiple namespaces… help you remember which namespace has which assets already defined.

Thanks for the help. I managed to install the AWS plugin and create a check.
Not all good I get an authentication error from AWS while the plugin has all access.

Thanks again

Yeah, the authentication error thing is a common complication people run into.

There are a couple of ways around this. You can adjust the IAM policy applied to the ec2. Or you can generate the IAM credential tokens for the sensu user to use and place them in
/var/lib/sensu/.aws/credentials on the host running the agent.

I fixed the credentials problem. I was working with IAM roles, but needed to add these roles to all instances that had a reporting agent installed. And after tinkering with the filters I got results, I filtered only instances with certain tags.

But i’m still running into issue with the not found error.

I installed the asset by
sensuctl asset add sensu-plugins/sensu-plugins-memory-checks

checked the names:
sensu-plugins/sensu-plugins-disk-checks
sensu-plugins/sensu-plugins-memory-checks
sensu-plugins/sensu-plugins-network-checks
sensu-plugins/sensu-plugins-process-checks

Added a check
sensuctl check create check-memory --command 'check-memory.rb -w 400 -c 200' --interval 60 --subscriptions system --runtime-assets sensu-plugins/sensu-plugins-memory-checks,sensu/sensu-ruby-runtime

I have tried different variation in naming of the runtime-assets, but no luck

checked the event out put and got this error:
sh: 1: check-memory.rb: not found

I get the same error for the sensu-plugins/sensu-plugins-http plugin. Any idea how to fix this one?

What ec2 instance type are you running? It sounds like your agent is running on an OS that doesn’t match the asset build filters.

For example:
take a look at sensu/sensu-ruby-runtime asset
sensuctl asset info sensu/sensu-ruby-runtime

you’ll see a number of builds defined, each with a different filter definition.
The build filters typically are filtering on the entity information such as os, release, platform and platform_family.

You can check what your agent information with
sensuctl entity info <entity-name>

Hi,

I check the ruby-runtime:

{
  "filters": null,
  "builds": [
    {
      "url": "https://assets.bonsai.sensu.io/5123017d3dadf2067fa90fc28275b92e9b586885/sensu-ruby-runtime_0.0.10_ruby-2.4.4_centos6_linux_amd64.tar.gz",
      "sha512": "cbee19124b7007342ce37ff9dfd4a1dde03beb1e87e61ca2aef606a7ad3c9bd0bba4e53873c07afa5ac46b0861967a9224511b4504dadb1a5e8fb687e9495304",
      "filters": [
        "entity.system.os == 'linux'",
        "entity.system.arch == 'amd64'",
        "entity.system.platform_family == 'rhel'",
        "parseInt(entity.system.platform_version.split('.')[0]) == 6"
      ],
      "headers": null
    },
    {
      "url": "https://assets.bonsai.sensu.io/5123017d3dadf2067fa90fc28275b92e9b586885/sensu-ruby-runtime_0.0.10_ruby-2.4.4_debian_linux_amd64.tar.gz",
      "sha512": "a28952fd93fc63db1f8988c7bc40b0ad815eb9f35ef7317d6caf5d77ecfbfd824a9db54184400aa0c81c29b34cb48c7e8c6e3f17891aaf84cafa3c134266a61a",
      "filters": [
        "entity.system.os == 'linux'",
        "entity.system.arch == 'amd64'",
        "entity.system.platform_family == 'debian'"
      ],
      "headers": null
    },
    {
      "url": "https://assets.bonsai.sensu.io/5123017d3dadf2067fa90fc28275b92e9b586885/sensu-ruby-runtime_0.0.10_ruby-2.4.4_centos_linux_amd64.tar.gz",
      "sha512": "338b88b568a3213fa234640da2e037d1487fc3c639bc62340f2fb71eac8af9a90566cffc768d15035406ac5c049350006d73f3a07ae15f9528e1c6a9af2944cb",
      "filters": [
        "entity.system.os == 'linux'",
        "entity.system.arch == 'amd64'",
        "entity.system.platform_family == 'rhel'",
        "parseInt(entity.system.platform_version.split('.')[0]) > 6"
      ],
      "headers": null
    },
    {
      "url": "https://assets.bonsai.sensu.io/5123017d3dadf2067fa90fc28275b92e9b586885/sensu-ruby-runtime_0.0.10_ruby-2.4.4_alpine_linux_amd64.tar.gz",
      "sha512": "8d768d1fba545898a8d09dca603457eb0018ec6829bc5f609a1ea51a2be0c4b2d13e1aa46139ecbb04873449e4c76f463f0bdfbaf2107caf37ab1c8db87d5250",
      "filters": [
        "entity.system.os == 'linux'",
        "entity.system.arch == 'amd64'",
        "entity.system.platform == 'alpine'",
        "entity.system.platform_version.split('.')[0] == '3'"
      ],
      "headers": null
    }
  ],
  "metadata": {
    "name": "sensu/sensu-ruby-runtime",
    "namespace": "default",
    "annotations": {
      "io.sensu.bonsai.api_url": "https://bonsai.sensu.io/api/v1/assets/sensu/sensu-ruby-runtime",
      "io.sensu.bonsai.name": "sensu-ruby-runtime",
      "io.sensu.bonsai.namespace": "sensu",
      "io.sensu.bonsai.tags": "",
      "io.sensu.bonsai.tier": "Community",
      "io.sensu.bonsai.url": "https://bonsai.sensu.io/assets/sensu/sensu-ruby-runtime",
      "io.sensu.bonsai.version": "0.0.10"
    }
  },
  "headers": null
}

And my instances are running Ubuntu 18.04 (debian)

{
  "entity_class": "agent",
  "system": {
    "hostname": "xxxxx",
    "os": "linux",
    "platform": "ubuntu",
    "platform_family": "debian",
    "platform_version": "18.04",
    "network": {
      "interfaces": [
        {
          "name": "lo",
          "addresses": [
            "xxxxx",
            "xxxxx"
          ]
        },
        {
          "name": "xxxxx",
          "mac": "xxxxx",
          "addresses": [
            "xxxxx",
            "xxxxx"
          ]
        }
      ]
    },
    "arch": "amd64"
  },
  "subscriptions": [
    "system",
    "aws-ec2",
    "frontend",
    "entity:xxxxx.compute.internal"
  ],
  "last_seen": 1577961959,
  "deregister": false,
  "deregistration": {},
  "user": "agent",
  "redact": [
    "password",
    "passwd",
    "pass",
    "api_key",
    "api_token",
    "access_key",
    "secret_key",
    "private_key",
    "secret"
  ],
  "metadata": {
    "name": "xxxxx.compute.internal",
    "namespace": "default"
  },
  "sensu_agent_version": "5.15.0"
}

This should match?

yes… the build for platform_family should match. for the ruby-runtime.

check-memory.rb is from sensu-plugins/sensu-plugins-memory-checks
There might not be a comptible build for that asset yet that matches for Ubuntu.