-
-
Save nstielau/6096392 to your computer and use it in GitHub Desktop.
{ | |
"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, | |
} | |
} | |
} |
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!
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.
the remediation somehow doesnt work.
Some other people as well like here and there