Setup own checks

Hi All,

Can anyone help me to set up own checks in sensu-go.
ex:- have a script file
now i need to configure the check using script.

Thanks in advance.

To use your own scripts you have a couple of options.

Option 1:
All you need to do is make sure the scripts are installed on the hosts running the sensu agent that will be subscribed to the check or package the script.

For VMs are bare-metal servers you can do thi as part of your configuration management system that you use to prepare.

For container images or cloud instances like EC2 you’d also have the option to rebuild the image to include your script.

Then in your Check Resource definition you just need to call the script as the check “command.” If the script is not installed in the normal executable path, you can specify the full path.

Here’s a quick example of what that would look like if you needed to reference the full path.

type: CheckConfig
api_version: core/v2
  name: example
  command: /full/path/to/
  interval: 60
  - example

Option 2:
You’d want to turn your script into a Sensu runtime asset that way the script will be installed just-in-time on the agent host. You’ll want take a look at the Sensu Go docs for examples on how to package up an asset.

Hi @jspaleta

Getting below error while running the check. please help.

@sagar.reddy in your screenshot, your pwd is /etc/sensu, but the command is referencing a script in /home/ubuntu. Is that intentional?

@aaronsachs-sensu sorry for wrong screen shot. please see the below screen shot once.

and the error is same like

sh: 1: /etc/sensu/ not found

@aaronsachs-sensu and @jspaleta is there any errors on my config.

It could be file permissions related. Try changing the owner to sensu and see if that helps.

Hmm… if all the agents with the system subscription have that file in place, this should be working unless there is something “interesting” about the host OS that is preventing correct operation of the command.

So lets do some basic troubleshooting here.

  1. Can you run the command as sensu user on that system and make sure it works?
    sudo -u sensu /etc/sensu/ -c4,100,100 -w 3,3,1

  2. Can you provide the entity list for us? Is there only one agent entity using the system subscription?
    sensuctl entity list

  3. Can you provide the sensuctl check info output for that check. I just want to make sure the check looks right
    sensuctl check info check_load --format yaml

Thanks @jspaleta it’s worked for me. issue with my ruby script file.
Thanks for your valuable time.