Hello
While looking at the Sensu Plugin Tool on github I noticed that it was possible to create plugins for sensuctl (at least there’s a template for it )
Is there any explanation/example around to see how we can “extend” sensuctl?
Is there any pre-requisite (like only sensuctl version greater than 5.18 or things like this)
Regards
1 Like
I started working on something recently that might make a good example:
Some things I noted along the way:
- Sensu CLI plugin development UX is quite nice thanks to the
sensuctl env
command, as it helps emulate the CLI plugin execution environment. All of the environment variables made available in the command plugin’s execution environment are also available via eval $(sensuctl env)
. This also makes it possible to run any plugins you develop as standalone programs like: eval $(sensuctl env) && do-something.sh --flag foo
- I was able to prototype sensuctl plugins using a simple shell script (this even works with shell scripts that execute multiple sensuctl commands).
- Don’t forget that the executable must be called via
bin/entrypoint
in the resulting Sensu Asset. I haven’t tested using a symlink for this, but I suspect that should work.
I hope this helps!
Thanks!
I will look into this
Hey!
We’ve also penciled time for a sensuctl command plugin hour during the upcoming virtual Sensu Summit, to give people an opportunity to do a little watch and learn. Watch out for more information on proposed Summit workshop topics this week on discourse.
awesome!
It’d be great to have some people attempt to build their own command ahead of the summit so we can get some feedback on the templated process. The command plugin is a pretty new and powerful concept.
For check and handler, if you already “played” a bit with events in order to create your plugins (I did some in perl mainly), using the template is pretty easy.
Especially it’s making it pretty easy to manipulate events and the various fields
I’m not yet using the part for automatic publishing to bonsai, but the rest is very nice
1 Like
So following the webinar where some tips were provided on this topics I’ve been able to build a plugin to list entities with their « global » status. It’s quite easy.
Get the auth bearer key from the environnement, then execute your api request and process the result « et voilà »
This one was more or less a proof of concept for me, but it open for sure a wide range of possibilities for me
1 Like
Cool!
Yeah please post the repo.
Also if you have any suggestions on how we can extend the sensu go plugin SDK to better target sensuctl commands specifically. Right now the template repo uses the check plugin as a primitive, but obviously that’s not ideal. It works, but its an octagonal peg in a round hole sort of deal. I want to extend the SDK to offer a tailored command plugin class, but I’d like some feedback on what that should include to make it useful.
As I’m a total beginner with Go please be kind (I started with go for sensu plugins )
I still have some cleanup other things to do ^^.
Anyway here is the repo
1 Like