Created
October 2, 2020 15:08
-
-
Save Gustibimo/f6e8b10a41f0f80c1bb7777c9c7a2326 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/env bash | |
| echo '----' | |
| # Set the path so cron can find jq, necessary for cron depending on your default PATH | |
| export PATH=$PATH:/usr/local/bin/ | |
| date | |
| # List current connectors and status | |
| curl -s "http://localhost:8083/connectors?expand=info&expand=status" | \ | |
| jq '. | to_entries[] | [ .value.info.type, .key, .value.status.connector.state,.value.status.tasks[].state,.value.info.config."connector.class"]|join(":|:")' | \ | |
| column -s : -t| sed 's/\"//g'| sort | |
| # Restart any connector tasks that are FAILED | |
| curl -s "http://localhost:8083/connectors?expand=status" | \ | |
| jq -c -M 'map({name: .status.name } + {tasks: .status.tasks}) | .[] | {task: ((.tasks[]) + {name: .name})} | select(.task.state=="FAILED") | {name: .task.name, task_id: .task.id|tostring} | ("/connectors/"+ .name + "/tasks/" + .task_id + "/restart")' | \ | |
| xargs -I{connector_and_task} curl -v -X POST "http://localhost:8083"\{connector_and_task\} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment