Skip to content

Commit

Permalink
add task
Browse files Browse the repository at this point in the history
  • Loading branch information
shaowenchen committed Sep 13, 2024
1 parent 4c6288e commit cf0af4f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tasks/check-conn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: crd.chenshaowen.com/v1
kind: Task
metadata:
name: check-conn
namespace: ops-system
spec:
desc: check connection to specified hosts
typeRef: cluster
variables:
targets:
display: target hosts
example: 1.1.1.1,2.2.2.2
command:
default: ping -c 2 $target
steps:
- name: Check connection
content: |
targets=$(echo "$targets" | awk -F, '{for (i=1; i<=NF; i++) print $i}')
for target in $targets; do
${command} > /dev/null
if [ $? -eq 0 ]; then
echo "`hostname` -> $target is ok"
else
echo "`hostname` -> $target is not ok"
fi
done

0 comments on commit cf0af4f

Please sign in to comment.