Hi All,
Can anyone help me to set up own checks in sensu-go.
ex:- have a script file example.sh
now i need to configure the check using example.sh script.
Thanks in advance.
Hi All,
Can anyone help me to set up own checks in sensu-go.
ex:- have a script file example.sh
now i need to configure the check using example.sh script.
Thanks in advance.
Hey!
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
metadata:
name: example
spec:
command: /full/path/to/example.sh
interval: 60
subscriptions:
- 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.
https://docs.sensu.io/sensu-go/latest/reference/assets/
Hi @jspaleta
Getting below error while running the check. please help.
http://52.66.240.120:3000/default/events/SensuGo-Server/check_load
@sagar.reddy in your screenshot, your pwd
is /etc/sensu
, but the command is referencing a script in /home/ubuntu
. Is that intentional?
@aaronsachs sorry for wrong screen shot. please see the below screen shot once.
and the error is same like
sh: 1: /etc/sensu/check_load.sh: not found
@aaronsachs 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.
Can you run the command as sensu user on that system and make sure it works?
sudo -u sensu /etc/sensu/check_load.sh -c4,100,100 -w 3,3,1
Can you provide the entity list for us? Is there only one agent entity using the system subscription?
sensuctl entity list
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.