# Setup own checks

**URL:** <https://discourse.sensu.io/t/setup-own-checks/1416>\
**Category:** Migrating to Sensu Go\
**Tags:** sensu-go-release\
**Created:** [October 25, 2019, 4:18am UTC](https://discourse.sensu.io/t/setup-own-checks/1416 "2019-10-25T04:18:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sagar.reddy](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@sagar.reddy](https://discourse.sensu.io/u/sagar.reddy)\
**Post date:** [October 25, 2019, 4:18am UTC](https://discourse.sensu.io/t/setup-own-checks/1416/1 "2019-10-25T04:18:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jspaleta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/jspaleta/32/141_2.png) [@jspaleta](https://discourse.sensu.io/u/jspaleta)\
**Post date:** [October 25, 2019, 4:49am UTC](https://discourse.sensu.io/t/setup-own-checks/1416/2 "2019-10-25T04:49:13Z")

</div>

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/](https://docs.sensu.io/sensu-go/latest/reference/assets/)

---

<div class="post-metadata">

**Author:** ![sagar.reddy](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@sagar.reddy](https://discourse.sensu.io/u/sagar.reddy)\
**Post date:** [October 25, 2019, 7:18am UTC](https://discourse.sensu.io/t/setup-own-checks/1416/3 "2019-10-25T07:18:06Z")

</div>

Hi @jspaleta

Getting below error while running the check. please help.  
[http://52.66.240.120:3000/default/events/SensuGo-Server/check\_load](http://52.66.240.120:3000/default/events/SensuGo-Server/check_load)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/sensu/original/1X/1c76d01babdcc97db5d0d854a2b2d0a5db3f8884.png)

---

<div class="post-metadata">

**Author:** ![aaronsachs](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/aaronsachs/32/47_2.png) [@aaronsachs](https://discourse.sensu.io/u/aaronsachs)\
**Post date:** [October 25, 2019, 2:02pm UTC](https://discourse.sensu.io/t/setup-own-checks/1416/4 "2019-10-25T14:02:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sagar.reddy](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@sagar.reddy](https://discourse.sensu.io/u/sagar.reddy)\
**Post date:** [October 27, 2019, 11:33am UTC](https://discourse.sensu.io/t/setup-own-checks/1416/5 "2019-10-27T11:33:23Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex016/uploads/sensu/original/1X/d9629e755113dabb0444055e0ceb151f221a861e.png)

and the error is same like

```auto
sh: 1: /etc/sensu/check_load.sh: not found

```

---

<div class="post-metadata">

**Author:** ![sagar.reddy](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@sagar.reddy](https://discourse.sensu.io/u/sagar.reddy)\
**Post date:** [October 28, 2019, 10:31am UTC](https://discourse.sensu.io/t/setup-own-checks/1416/6 "2019-10-28T10:31:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![aaronsachs](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/aaronsachs/32/47_2.png) [@aaronsachs](https://discourse.sensu.io/u/aaronsachs)\
**Post date:** [October 29, 2019, 11:30am UTC](https://discourse.sensu.io/t/setup-own-checks/1416/7 "2019-10-29T11:30:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jspaleta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/jspaleta/32/141_2.png) [@jspaleta](https://discourse.sensu.io/u/jspaleta)\
**Post date:** [October 29, 2019, 5:32pm UTC](https://discourse.sensu.io/t/setup-own-checks/1416/8 "2019-10-29T17:32:43Z")

</div>

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/check_load.sh -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`

---

<div class="post-metadata">

**Author:** ![sagar.reddy](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@sagar.reddy](https://discourse.sensu.io/u/sagar.reddy)\
**Post date:** [November 2, 2019, 8:11pm UTC](https://discourse.sensu.io/t/setup-own-checks/1416/9 "2019-11-02T20:11:23Z")

</div>

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