Struggling to get started

Sorry, this feels fairly basic, however, I’ve been reading through the docs and I’m clearly missing something.
I have a test environment up and running with a Sensu backend and two agents that have registered and are sending keepalive information, so the basics seem to be up and functioning.

The next thing I want to do is set up a Nagios check to monitor something. Based on the docs I’ve tried using the agent API to load a check but it throws the error “check has not been instantiated for this event”, does something else need to be loaded first?

[root@agent1 vagrant]# curl -X POST
-H ‘Content-Type: application/json’
-d ‘{
“type”: “CheckConfig”,
“api_version”: “core/v2”,
“metadata”: {
“name”: “check-path”,
“namespace”: “default”
},
“spec”: {
“command”: “check-path.py -t 1 8.8.8.8”,
“subscriptions”: [“agent1”],
“handlers”: [“slack”],
“interval”: 60,
“publish”: true
}
}’
http://127.0.0.1:3031/events

Hello,
The agent’s event API is pretty advanced feature, and is not something I’d expect someone to try to use first. The agent’s event api makes it possible to let external scripts not run as Sensu checks to generate Sensu events (as if they were checks) It’s a bit advanced, Its probably not what you want. It’s definitely not what you want to use if you are trying to create and schedule Sensu checks.

What you probably want to do is install the sensuctl commandline tool and start creating checks on the Sensu backend, with the correct subscription and scheduling settings to run on the agents. Sensu uses a “subscription” model. Agents register which subscriptions they want to participate in, and checks have a corresponding subscriptions attribute indicating which subscriptions each check will be scheduled for.

You probably want to walk through this guide first:
https://docs.sensu.io/sensu-go/latest/guides/monitor-server-resources/

Then once you’ve used the sensuctl to create your first working Sensu check, you should be able to build the check you want.

1 Like

yup… what Jef says, i’m still struggling quite a bit with the monitoring stuff but what i found is if you build your checks out of files (i prefer yaml) you can just senctl create -f filename then if you have to change it tweak the file a bit, sensuctl check delete checkname then just reimport the file to create the edited one

Actually, the check delete step is not necessary. You can just run create again against your yaml file and it will update your check.

1 Like

thanks very much Todd, just within the last hour i’ve learned that as well, by accident of course but its a good thing (y), good to hear from you

Great information, thank you, I’ll dig into the command line information and see how I go.