no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
| — | tech:linux:ping_test [2016/03/03 12:28] (current) – created - external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Ping / TCP Ping Test ====== | ||
| + | Script to check for ping or TCP in a loop and email a limited number of times an error occurs | ||
| + | <code bash> | ||
| + | #!/bin/bash | ||
| + | # | ||
| + | TIMEOUT=2 | ||
| + | PORT=443 | ||
| + | MAXEMAILS=40 | ||
| + | IP=xxx.xxx.xxx.xxx | ||
| + | EMAIL=someone@example.com | ||
| + | SUBJECT=ping_test | ||
| + | # | ||
| + | errcnt=0 | ||
| + | while true; do | ||
| + | / | ||
| + | if [ $? -ne 0 ] | ||
| + | then | ||
| + | (( errcnt += 1 )) | ||
| + | if [ $errcnt -lt $MAXEMAILS ] | ||
| + | then | ||
| + | echo "Error Count: $errcnt" | ||
| + | else | ||
| + | echo " | ||
| + | fi | ||
| + | date >> ch_${PORT}_${TIMEOUT}.log | ||
| + | fi | ||
| + | sleep 1 | ||
| + | done | ||
| + | </ | ||