fork download
  1. #!/bin/sh
  2.  
  3. FILES=$(find /var/run | grep dpinger | grep sock)
  4.  
  5. Latency_Low=200000
  6. Latency_High=500000
  7. Loss_Low=10
  8. Loss_High=20
  9.  
  10. database=LAGOON
  11. server=10.120.10.16
  12.  
  13. for File in $FILES
  14. do
  15. File_Content=$(cat $File)
  16. Gateway_Name=$(echo $File_Content | cut -d ' ' -f 1)
  17. Part_Mon_IP="${File##*~}"
  18. Monitoring_IP="${Part_Mon_IP%.*}"
  19. Part_Wan_IP=`echo $File:q | sed 's/~/ /g'`
  20. Wan_IP=$(echo $Part_Wan_IP | cut -d ' ' -f 2)
  21. RTT=$(echo $File_Content | cut -d ' ' -f 2)
  22. RTT_SD=$(echo $File_Content | cut -d ' ' -f 3)
  23. Loss=$(echo $File_Content | cut -d ' ' -f 4)
  24.  
  25. Status="Online"
  26. Gate_Health="0"
  27.  
  28. # Gate_Health 0 = Online 1 = Delay 2 = High_Delay 3 = Loss 4 = High_Loss 5 = Down
  29.  
  30. if (test $RTT -gt $Latency_Low) then
  31. Status="Delay"
  32. Gate_Health="1"
  33. fi
  34. if (test $RTT -gt $Latency_High) then
  35. Status="High_Delay"
  36. Gate_Health="2"
  37. fi
  38. if (test $Loss -gt $Loss_Low) then
  39. Status="Loss"
  40. Gate_Health="3"
  41. fi
  42. if (test $Loss -gt $Loss_High) then
  43. Status="High_Loss"
  44. Gate_Health="4"
  45. fi
  46. if (test $Loss -eq "100") then
  47. Status="Down"
  48. Gate_Health="5"
  49. fi
  50.  
  51. output=$(echo "wans_health,host="$(hostname)",gw_name="$Gateway_Name",wan_ip="$Wan_IP",mon_ip="$Monitoring_IP",rtt="$RTT",rrtsd="$RTT_SD",loss="$Loss",status="$Status" value="$Gate_Health"")
  52. url=`echo "http://"${server}":8086/write?db="${database}""`
  53.  
  54. /usr/local/bin/curl -i -XPOST $url --data-binary "$output" -s > /usr/local/tmp/outRTT.txt
  55. done
  56.  
Success #stdin #stdout 0s 19640KB
stdin
Standard input is empty
stdout
Standard output is empty