Last active
April 24, 2019 16:35
-
-
Save nstielau/6096392 to your computer and use it in GitHub Desktop.
Example of Sensu remediation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"checks": { | |
"check_something": { | |
"command": "ps aux | grep cron", | |
"interval": 60, | |
"subscribers": ["application_server"], | |
"handlers": ["debug", "irc", "remediator"], | |
"remediation": { | |
"light_remediation": { | |
"occurrences": [1, 2], | |
"severities": [1] | |
}, | |
"medium_remediation": { | |
"occurrences": ["3-10"], | |
"severities": [1] | |
}, | |
"heavy_remediation": { | |
"occurrences": ["1+"], | |
"severities": [2] | |
} | |
} | |
}, | |
"light_remediation": { | |
"command": "/bin/something", | |
"subscribers": [], | |
"handlers": ["debug", "irc"], | |
"publish": false, | |
}, | |
"medium_remediation": { | |
"command": "/bin/something_else", | |
"subscribers": [], | |
"handlers": ["debug", "irc"], | |
"publish": false, | |
}, | |
"heavy_remediation": { | |
"command": "sudo reboot", | |
"subscribers": [], | |
"handlers": ["debug", "irc"], | |
"publish": false, | |
} | |
} | |
} |
Thanks alot @seth-paxton, the reason why its been failing was because of the subscriber pointing to the client name. I just added it and worked flawlessly.
Thanks alot.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This does work actually and its pretty awesome. Took a bit of time to figure out. First off, you need to remove the commas after the "publish": option in the example above. You can see my fork here. You can also view my example here
I noticed in the sensu-api.log that remediation was POSTing to the API using the hostname of the affected server as the subscriber: {"timestamp":"2014-10-06T18:46:16.656712+0000","level":"info","message":"POST /request","remote_address":"127.0.0.1","user_agent":"Ruby","request_method":"POS
T","request_uri":"/request","request_body":"{"check":"heavy_remediation","subscribers":["hostname.example.com"]}"}
I changed the client to subscribe to hostname.example.com and everything started working. I created a gist outlining the steps to get this running.
As a side note: Pretty clever use of the API to accomplish remediation. Great work!